
class Gitea::User::GetTokenService < Gitea::ClientService
  attr_reader :username

  def initialize(username)
    @username  = username
  end

  def call
    params = {}
    url = "/users/#{username}/tokens".freeze
    params = params.merge(sudo: username, page: 1, limit: 200, token: token)
    response = get(url, params)
    render_status(response)
  end

  private
  def token
    {
      username: GiteaService.gitea_config[:access_key_id],
      password: GiteaService.gitea_config[:access_key_secret]
    }
  end
end
