Class: DNSimple::User

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ User

Returns a new instance of User.



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

def initialize(attributes)
  attributes.each do |key, value|
    m = "#{key}=".to_sym
    self.send(m, value) if self.respond_to?(m)
  end
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#domain_countObject

Returns the value of attribute domain_count.



17
18
19
# File 'lib/dnsimple/user.rb', line 17

def domain_count
  @domain_count
end

#domain_limitObject

Returns the value of attribute domain_limit.



19
20
21
# File 'lib/dnsimple/user.rb', line 19

def domain_limit
  @domain_limit
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#failed_login_countObject

Returns the value of attribute failed_login_count.



15
16
17
# File 'lib/dnsimple/user.rb', line 15

def 
  @failed_login_count
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#login_countObject

Returns the value of attribute login_count.



13
14
15
# File 'lib/dnsimple/user.rb', line 13

def 
  @login_count
end

#updated_atObject

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

Class Method Details

.me(options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dnsimple/user.rb', line 28

def self.me(options={})
  options.merge!({:basic_auth => Client.credentials})
  response = self.get("#{Client.base_uri}/users/me.json", options)

  case response.code
  when 200
    return User.new(response["user"])
  when 401
    raise DNSimple::AuthenticationFailed, "Authentication failed"
  when 404
    raise DNSimple::UserNotFound, "Could not find user"
  else
    raise DNSimple::Error, "Error: #{response.code} #{response.message}"
  end
end