Class: Raas::AccountModel

Inherits:
BaseModel show all
Defined in:
lib/raas/models/account_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(account_identifier = nil, display_name = nil, currency_code = 'USD', current_balance = nil, created_at = nil, status = nil, contact_email = nil) ⇒ AccountModel

Returns a new instance of AccountModel.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/raas/models/account_model.rb', line 49

def initialize( = nil,
               display_name = nil,
               currency_code = 'USD',
               current_balance = nil,
               created_at = nil,
               status = nil,
               contact_email = nil)
  @account_identifier = 
  @display_name = display_name
  @currency_code = currency_code
  @current_balance = current_balance
  @created_at = created_at
  @status = status
  @contact_email = contact_email
end

Instance Attribute Details

#account_identifierString

Account Identifier

Returns:



8
9
10
# File 'lib/raas/models/account_model.rb', line 8

def 
  @account_identifier
end

#contact_emailString

Contact Email

Returns:



32
33
34
# File 'lib/raas/models/account_model.rb', line 32

def contact_email
  @contact_email
end

#created_atDateTime

Date Created

Returns:

  • (DateTime)


24
25
26
# File 'lib/raas/models/account_model.rb', line 24

def created_at
  @created_at
end

#currency_codeString

Currency Code

Returns:



16
17
18
# File 'lib/raas/models/account_model.rb', line 16

def currency_code
  @currency_code
end

#current_balanceFloat

Current Balance

Returns:

  • (Float)


20
21
22
# File 'lib/raas/models/account_model.rb', line 20

def current_balance
  @current_balance
end

#display_nameString

Display Name

Returns:



12
13
14
# File 'lib/raas/models/account_model.rb', line 12

def display_name
  @display_name
end

#statusString

Status

Returns:



28
29
30
# File 'lib/raas/models/account_model.rb', line 28

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/raas/models/account_model.rb', line 66

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash
   = hash['accountIdentifier']
  display_name = hash['displayName']
  currency_code = hash['currencyCode'] ||= 'USD'
  current_balance = hash['currentBalance']
  created_at = DateTime.rfc3339(hash['createdAt']) if hash['createdAt']
  status = hash['status']
  contact_email = hash['contactEmail']

  # Create object from extracted values
  AccountModel.new(,
                   display_name,
                   currency_code,
                   current_balance,
                   created_at,
                   status,
                   contact_email)
end

.namesObject

A mapping from model property names to API property names



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/raas/models/account_model.rb', line 35

def self.names
  if @_hash.nil?
    @_hash = {}
    @_hash["account_identifier"] = "accountIdentifier"
    @_hash["display_name"] = "displayName"
    @_hash["currency_code"] = "currencyCode"
    @_hash["current_balance"] = "currentBalance"
    @_hash["created_at"] = "createdAt"
    @_hash["status"] = "status"
    @_hash["contact_email"] = "contactEmail"
  end
  @_hash
end