# 代码溯源 查询检测结果
class Trace::CheckResultService < Trace::ClientService

  attr_accessor :token, :project, :file_name, :page_num, :page_size

  def initialize(token, project, file_name=nil, page_num=1, page_size=15) 
    @token = token 
    @project = project
    @file_name = file_name
    @page_num = page_num
    @page_size = page_size
  end

  def call
    result = authed_get(token, url, request_params)
    reponse = render_response(result)
  end

  private 
  def request_params 
    {
      product_name: Digest::MD5.hexdigest(project&.id.to_s)[0...20], 
      file_name: file_name,
      pageNum: page_num,
      pageSize: page_size,
    }
  end

  def url 
    "/user/checkresult".freeze
  end
end

