class Reposync::GetLogsService < Reposync::ClientService

  attr_accessor :repo_name, :branch_id, :page_num, :page_size

  def initialize(repo_name=nil, branch_id=nil, page_num=1, page_size=10)
    @repo_name = repo_name
    @branch_id = branch_id
    @page_num = page_num
    @page_size = page_size
  end

  def call 
    result = get(url, request_params)
    response = render_list_response(result)
  end

  private
  def request_params
    params = {
      page_num: page_num,
      page_size: page_size,
      create_sort: true
    }
    params.merge!(repo_name: repo_name) if repo_name.present? 
    params.merge!(branch_id: branch_id) if branch_id.present? 

    return params.stringify_keys
  end

  def url 
    "/cerobot/sync/repo/logs"
  end
end