class Gitea::Accelerator::GetService < Gitea::Accelerator::BaseService

  attr_reader :user_name, :repo_name

  def initialize(user_name, repo_name)
    @user_name = user_name
    @repo_name = repo_name
  end

  def call
    return error('[gitea:] accelerator config missing') if check_accelerator!
    response = get(url, {})
    render_result(response)
  end

  private

  def url
    "/repos/#{user_name}/#{repo_name}".freeze
  end

  def render_result(response)
    case response.status
    when 200
      JSON.parse(response.body)
    else
      nil
    end
  end
end