class Gitea::Repository::Branches::ListService < Gitea::ClientService
  attr_reader :user, :repo, :name

  def initialize(user, repo, name=nil)
    @user = user
    @repo = repo
    @name = name
  end

  def call
    response = get(url, params)
    render_200_response(response)
  end

  private
  def params
    Hash.new.merge(token: user.gitea_token, name: name)
  end

  def url
    "/repos/#{user.login}/#{repo}/branches".freeze
  end
end
