Class: Authenticator::Client::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/authenticator/client/account.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, password = nil) ⇒ Account

Returns a new instance of Account.



5
6
7
8
9
10
11
# File 'lib/authenticator/client/account.rb', line 5

def initialize(params, password=nil)
  if password.nil?
    new_initialize(params)
  else
    old_initialize(params, password)
  end
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



4
5
6
# File 'lib/authenticator/client/account.rb', line 4

def created_at
  @created_at
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/authenticator/client/account.rb', line 4

def id
  @id
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/authenticator/client/account.rb', line 4

def password
  @password
end

#updated_atObject

Returns the value of attribute updated_at.



4
5
6
# File 'lib/authenticator/client/account.rb', line 4

def updated_at
  @updated_at
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/authenticator/client/account.rb', line 4

def username
  @username
end

Class Method Details

.from_json(json) ⇒ Object



26
27
28
29
30
31
# File 'lib/authenticator/client/account.rb', line 26

def self.from_json(json)
  params = json.each_with_object({}) do |(key, value), hash|
    hash[key.to_sym] = value
  end
  new(params)
end

Instance Method Details

#new_initialize(params) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/authenticator/client/account.rb', line 13

def new_initialize(params)
  @id = params[:id]
  @username = params[:username]
  @password = params[:password]
  @created_at = params[:created_at]
  @updated_at = params[:updated_at]
end

#old_initialize(username, password) ⇒ Object



21
22
23
24
# File 'lib/authenticator/client/account.rb', line 21

def old_initialize(username, password)
  @username = username
  @password = password
end

#to_paramsObject Also known as: to_h



33
34
35
36
37
38
39
40
# File 'lib/authenticator/client/account.rb', line 33

def to_params
  {
    account: {
      username: username,
      password: password
    }
  }
end