Class: Raas::AccountModel

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

Overview

Represents an Account

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, account_number = 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.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/raas/models/account_model.rb', line 54

def initialize( = nil,
                = nil,
               display_name = nil,
               currency_code = 'USD',
               current_balance = nil,
               created_at = nil,
               status = nil,
               contact_email = nil)
  @account_identifier = 
  @account_number = 
  @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

An account identifier

Returns:



10
11
12
# File 'lib/raas/models/account_model.rb', line 10

def 
  @account_identifier
end

#account_numberString

An account number

Returns:



14
15
16
# File 'lib/raas/models/account_model.rb', line 14

def 
  @account_number
end

#contact_emailString

The contact email on file for the account

Returns:



38
39
40
# File 'lib/raas/models/account_model.rb', line 38

def contact_email
  @contact_email
end

#created_atDateTime

The date the account was created

Returns:

  • (DateTime)


30
31
32
# File 'lib/raas/models/account_model.rb', line 30

def created_at
  @created_at
end

#currency_codeString

The currency code for the account

Returns:



22
23
24
# File 'lib/raas/models/account_model.rb', line 22

def currency_code
  @currency_code
end

#current_balanceFloat

The current balance of the account

Returns:

  • (Float)


26
27
28
# File 'lib/raas/models/account_model.rb', line 26

def current_balance
  @current_balance
end

#display_nameString

A display name

Returns:



18
19
20
# File 'lib/raas/models/account_model.rb', line 18

def display_name
  @display_name
end

#statusString

The status of the account

Returns:



34
35
36
# File 'lib/raas/models/account_model.rb', line 34

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/raas/models/account_model.rb', line 73

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = hash['accountIdentifier']
   = hash['accountNumber']
  display_name = hash['displayName']
  currency_code = hash['currencyCode'] ||= 'USD'
  current_balance = hash['currentBalance']
  created_at = APIHelper.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.



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/raas/models/account_model.rb', line 41

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