Class: Raas::CustomerModel
- Defined in:
- lib/raas/models/customer_model.rb
Overview
Represents a Customer/Group
Instance Attribute Summary collapse
-
#accounts ⇒ List of AccountSummaryModel
An array of AccountSummary objects.
-
#created_at ⇒ DateTime
The date the customer was created.
-
#customer_identifier ⇒ String
The customer identifier.
-
#display_name ⇒ String
The display name.
-
#status ⇒ String
The status of the customer.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(customer_identifier = nil, display_name = nil, status = nil, created_at = nil, accounts = nil) ⇒ CustomerModel
constructor
A new instance of CustomerModel.
Methods inherited from BaseModel
Constructor Details
#initialize(customer_identifier = nil, display_name = nil, status = nil, created_at = nil, accounts = nil) ⇒ CustomerModel
Returns a new instance of CustomerModel.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/raas/models/customer_model.rb', line 39 def initialize(customer_identifier = nil, display_name = nil, status = nil, created_at = nil, accounts = nil) @customer_identifier = customer_identifier @display_name = display_name @status = status @created_at = created_at @accounts = accounts end |
Instance Attribute Details
#accounts ⇒ List of AccountSummaryModel
An array of AccountSummary objects
26 27 28 |
# File 'lib/raas/models/customer_model.rb', line 26 def accounts @accounts end |
#created_at ⇒ DateTime
The date the customer was created
22 23 24 |
# File 'lib/raas/models/customer_model.rb', line 22 def created_at @created_at end |
#customer_identifier ⇒ String
The customer identifier
10 11 12 |
# File 'lib/raas/models/customer_model.rb', line 10 def customer_identifier @customer_identifier end |
#display_name ⇒ String
The display name
14 15 16 |
# File 'lib/raas/models/customer_model.rb', line 14 def display_name @display_name end |
#status ⇒ String
The status of the customer
18 19 20 |
# File 'lib/raas/models/customer_model.rb', line 18 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/raas/models/customer_model.rb', line 52 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. customer_identifier = hash['customerIdentifier'] display_name = hash['displayName'] status = hash['status'] created_at = APIHelper.rfc3339(hash['createdAt']) if hash['createdAt'] # Parameter is an array, so we need to iterate through it accounts = nil unless hash['accounts'].nil? accounts = [] hash['accounts'].each do |structure| accounts << (AccountSummaryModel.from_hash(structure) if structure) end end # Create object from extracted values. CustomerModel.new(customer_identifier, display_name, status, created_at, accounts) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 37 |
# File 'lib/raas/models/customer_model.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['customer_identifier'] = 'customerIdentifier' @_hash['display_name'] = 'displayName' @_hash['status'] = 'status' @_hash['created_at'] = 'createdAt' @_hash['accounts'] = 'accounts' @_hash end |