Class: Verizon::AccountDetails

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/account_details.rb

Overview

AccountDetails Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(account_name: SKIP, account_number: SKIP, organization_name: SKIP, is_provisioning_allowed: SKIP, carriers: SKIP, features: SKIP, service_plans: SKIP, additional_properties: nil) ⇒ AccountDetails

Returns a new instance of AccountDetails.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 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,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @account_name =  unless  == SKIP
  @account_number =  unless  == 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
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_nameString

The numeric name of the account, in the format “0000123456-00001”. Leading zeros must be included.

Returns:

  • (String)


15
16
17
# File 'lib/verizon/models/account_details.rb', line 15

def 
  @account_name
end

#account_numberString

The numeric name of the account, in the format “0000123456-00001”. Leading zeros must be included.

Returns:

  • (String)


20
21
22
# File 'lib/verizon/models/account_details.rb', line 20

def 
  @account_number
end

#carriersArray[Carrier]

Flag set to indicate if account details can be edited or not. Default is “true”.

Returns:



34
35
36
# File 'lib/verizon/models/account_details.rb', line 34

def carriers
  @carriers
end

#featuresArray[Feature]

Flag set to indicate if account details can be edited or not. Default is “true”.

Returns:



39
40
41
# File 'lib/verizon/models/account_details.rb', line 39

def features
  @features
end

#is_provisioning_allowedTrueClass | FalseClass

Flag set to indicate if account details can be edited or not. Default is “true”.

Returns:

  • (TrueClass | FalseClass)


29
30
31
# File 'lib/verizon/models/account_details.rb', line 29

def is_provisioning_allowed
  @is_provisioning_allowed
end

#organization_nameString

user defined name of organization

Returns:

  • (String)


24
25
26
# File 'lib/verizon/models/account_details.rb', line 24

def organization_name
  @organization_name
end

#service_plansArray[CarrierServicePlan]

Flag set to indicate if account details can be edited or not. Default is “true”.

Returns:



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.



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
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/verizon/models/account_details.rb', line 95

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = hash.key?('accountName') ? hash['accountName'] : SKIP
   = 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 a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  AccountDetails.new(account_name: ,
                     account_number: ,
                     organization_name: organization_name,
                     is_provisioning_allowed: is_provisioning_allowed,
                     carriers: carriers,
                     features: features,
                     service_plans: service_plans,
                     additional_properties: additional_properties)
end

.namesObject

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

.nullablesObject

An array for nullable fields



73
74
75
# File 'lib/verizon/models/account_details.rb', line 73

def self.nullables
  []
end

.optionalsObject

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



164
165
166
167
168
169
170
171
# File 'lib/verizon/models/account_details.rb', line 164

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_name: #{@account_name.inspect}, account_number:"\
  " #{@account_number.inspect}, organization_name: #{@organization_name.inspect},"\
  " is_provisioning_allowed: #{@is_provisioning_allowed.inspect}, carriers:"\
  " #{@carriers.inspect}, features: #{@features.inspect}, service_plans:"\
  " #{@service_plans.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



155
156
157
158
159
160
161
# File 'lib/verizon/models/account_details.rb', line 155

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} account_name: #{@account_name}, account_number: #{@account_number},"\
  " organization_name: #{@organization_name}, is_provisioning_allowed:"\
  " #{@is_provisioning_allowed}, carriers: #{@carriers}, features: #{@features},"\
  " service_plans: #{@service_plans}, additional_properties: #{@additional_properties}>"
end