Class: Dnsimple::Client::UsersService

Inherits:
ClientService show all
Defined in:
lib/dnsimple/client/users_service.rb

Instance Attribute Summary

Attributes inherited from ClientService

#client

Instance Method Summary collapse

Instance Method Details

#exchange_token(otp_token) ⇒ String

Requests a new two-factor authentication exchange token.

The exchange-token is required to validate API requests using HTTP Basic Authentication when the account has two-factor authentication enabled.

Examples:

Request an Exchange Token

Dnsimple::User.two_factor_exchange_token('0000000')
# => "cda038832591e34f5df642ce2b61dc78"

Raises:

See Also:



30
31
32
33
# File 'lib/dnsimple/client/users_service.rb', line 30

def exchange_token(otp_token)
  response = client.get("v1/user", headers: { Client::HEADER_2FA_STRICT => "1", Client::HEADER_OTP_TOKEN => otp_token })
  response.headers[Client::HEADER_EXCHANGE_TOKEN]
end

#userUser

Fetches the information about the authenticated user.

Raises:



9
10
11
12
13
# File 'lib/dnsimple/client/users_service.rb', line 9

def user
  response = client.get("v1/user")

  User.new(response["user"])
end