Class: Verizon::AccountDetails
- Defined in:
- lib/verizon/models/account_details.rb
Overview
AccountDetails Model.
Instance Attribute Summary collapse
-
#account_name ⇒ String
The numeric name of the account, in the format “0000123456-00001”.
-
#account_number ⇒ String
The numeric name of the account, in the format “0000123456-00001”.
-
#carriers ⇒ Array[Carrier]
Flag set to indicate if account details can be edited or not.
-
#features ⇒ Array[Feature]
Flag set to indicate if account details can be edited or not.
-
#is_provisioning_allowed ⇒ TrueClass | FalseClass
Flag set to indicate if account details can be edited or not.
-
#organization_name ⇒ String
user defined name of organization.
-
#service_plans ⇒ Array[CarrierServicePlan]
Flag set to indicate if account details can be edited or not.
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.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(account_name = SKIP, account_number = SKIP, organization_name = SKIP, is_provisioning_allowed = SKIP, carriers = SKIP, features = SKIP, service_plans = SKIP) ⇒ AccountDetails
constructor
A new instance of AccountDetails.
Methods inherited from BaseModel
Constructor Details
#initialize(account_name = SKIP, account_number = SKIP, organization_name = SKIP, is_provisioning_allowed = SKIP, carriers = SKIP, features = SKIP, service_plans = SKIP) ⇒ AccountDetails
Returns a new instance of AccountDetails.
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/verizon/models/account_details.rb', line 77 def initialize(account_name = SKIP, account_number = SKIP, organization_name = SKIP, is_provisioning_allowed = SKIP, carriers = SKIP, features = SKIP, service_plans = SKIP) @account_name = account_name unless account_name == SKIP @account_number = account_number unless account_number == SKIP @organization_name = organization_name unless organization_name == SKIP @is_provisioning_allowed = is_provisioning_allowed unless is_provisioning_allowed == SKIP @carriers = carriers unless carriers == SKIP @features = features unless features == SKIP @service_plans = service_plans unless service_plans == SKIP end |
Instance Attribute Details
#account_name ⇒ String
The numeric name of the account, in the format “0000123456-00001”. Leading zeros must be included.
15 16 17 |
# File 'lib/verizon/models/account_details.rb', line 15 def account_name @account_name end |
#account_number ⇒ String
The numeric name of the account, in the format “0000123456-00001”. Leading zeros must be included.
20 21 22 |
# File 'lib/verizon/models/account_details.rb', line 20 def account_number @account_number end |
#carriers ⇒ Array[Carrier]
Flag set to indicate if account details can be edited or not. Default is “true”.
34 35 36 |
# File 'lib/verizon/models/account_details.rb', line 34 def carriers @carriers end |
#features ⇒ Array[Feature]
Flag set to indicate if account details can be edited or not. Default is “true”.
39 40 41 |
# File 'lib/verizon/models/account_details.rb', line 39 def features @features end |
#is_provisioning_allowed ⇒ TrueClass | FalseClass
Flag set to indicate if account details can be edited or not. Default is “true”.
29 30 31 |
# File 'lib/verizon/models/account_details.rb', line 29 def is_provisioning_allowed @is_provisioning_allowed end |
#organization_name ⇒ String
user defined name of organization
24 25 26 |
# File 'lib/verizon/models/account_details.rb', line 24 def organization_name @organization_name end |
#service_plans ⇒ Array[CarrierServicePlan]
Flag set to indicate if account details can be edited or not. Default is “true”.
44 45 46 |
# File 'lib/verizon/models/account_details.rb', line 44 def service_plans @service_plans end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/verizon/models/account_details.rb', line 90 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. account_name = hash.key?('accountName') ? hash['accountName'] : SKIP account_number = hash.key?('accountNumber') ? hash['accountNumber'] : SKIP organization_name = hash.key?('organizationName') ? hash['organizationName'] : SKIP is_provisioning_allowed = hash.key?('isProvisioningAllowed') ? hash['isProvisioningAllowed'] : SKIP # Parameter is an array, so we need to iterate through it carriers = nil unless hash['carriers'].nil? carriers = [] hash['carriers'].each do |structure| carriers << (Carrier.from_hash(structure) if structure) end end carriers = SKIP unless hash.key?('carriers') # Parameter is an array, so we need to iterate through it features = nil unless hash['features'].nil? features = [] hash['features'].each do |structure| features << (Feature.from_hash(structure) if structure) end end features = SKIP unless hash.key?('features') # Parameter is an array, so we need to iterate through it service_plans = nil unless hash['servicePlans'].nil? service_plans = [] hash['servicePlans'].each do |structure| service_plans << (CarrierServicePlan.from_hash(structure) if structure) end end service_plans = SKIP unless hash.key?('servicePlans') # Create object from extracted values. AccountDetails.new(account_name, account_number, organization_name, is_provisioning_allowed, carriers, features, service_plans) end |
.names ⇒ Object
A mapping from model property names to API property names.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/verizon/models/account_details.rb', line 47 def self.names @_hash = {} if @_hash.nil? @_hash['account_name'] = 'accountName' @_hash['account_number'] = 'accountNumber' @_hash['organization_name'] = 'organizationName' @_hash['is_provisioning_allowed'] = 'isProvisioningAllowed' @_hash['carriers'] = 'carriers' @_hash['features'] = 'features' @_hash['service_plans'] = 'servicePlans' @_hash end |
.nullables ⇒ Object
An array for nullable fields
73 74 75 |
# File 'lib/verizon/models/account_details.rb', line 73 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/verizon/models/account_details.rb', line 60 def self.optionals %w[ account_name account_number organization_name is_provisioning_allowed carriers features service_plans ] end |