Class: DNSimple::User

Inherits:
Base
  • Object
show all
Defined in:
lib/dnsimple/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from DNSimple::Base

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



10
11
12
# File 'lib/dnsimple/user.rb', line 10

def created_at
  @created_at
end

#domain_countObject

Returns the value of attribute domain_count.



6
7
8
# File 'lib/dnsimple/user.rb', line 6

def domain_count
  @domain_count
end

#domain_limitObject

Returns the value of attribute domain_limit.



7
8
9
# File 'lib/dnsimple/user.rb', line 7

def domain_limit
  @domain_limit
end

#emailObject

Returns the value of attribute email.



5
6
7
# File 'lib/dnsimple/user.rb', line 5

def email
  @email
end

#failed_login_countObject

Returns the value of attribute failed_login_count.



9
10
11
# File 'lib/dnsimple/user.rb', line 9

def 
  @failed_login_count
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/dnsimple/user.rb', line 4

def id
  @id
end

#login_countObject

Returns the value of attribute login_count.



8
9
10
# File 'lib/dnsimple/user.rb', line 8

def 
  @login_count
end

#updated_atObject

Returns the value of attribute updated_at.



11
12
13
# File 'lib/dnsimple/user.rb', line 11

def updated_at
  @updated_at
end

Class Method Details

.meUser

Gets the information about the authenticated user.

Returns:

  • (User)

    the authenticated user

Raises:



18
19
20
21
22
23
24
25
26
27
# File 'lib/dnsimple/user.rb', line 18

def self.me
  response = DNSimple::Client.get("/v1/user")

  case response.code
  when 200
    new(response["user"])
  else
    raise RequestError.new("Error finding account", response)
  end
end

.two_factor_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"

Parameters:

  • otp_token (String)

    the two-factor one time (OTP) token

Returns:

  • (String)

    the two-factor API exchange token

Raises:

See Also:



45
46
47
48
# File 'lib/dnsimple/user.rb', line 45

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