class Gitea::User::DeleteService < Gitea::ClientService
  attr_reader :username, :purge

  def initialize(username, purge = false)
    @username  = username
    @purge  = purge
  end

  def call
    response = delete(request_url, params)

    render_status(response)
  end

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

  def request_url
    @purge ? "/admin/users/#{username}?purge=true" : "/admin/users/#{username}"
  end

  def params 
    Hash.new.merge(token: token)
  end
  

end
