class Gitea::User::GetService < Gitea::ClientService
  attr_reader :username, :password
  # params:
  # username*	string # required
  def initialize(username, password = "")
    @username = username
    @password = password
  end

  def call
    params = Hash.new.merge(token: token_params, data: params)
    response = get(url, params)

    status, message, body = render_response(response)
    json_format(status, message, body)
  end

  private
  def url
    "/users/#{username}"
  end

  def token_params
    {
        username: username,
        password: password
    }
  end

  def params
    {username: username}
  end


  def json_format(status, message, body)
    case status
    when 200 then success(body)
    else
      error(message, status)
    end
  end
end