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

#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) ⇒ 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( = SKIP,  = SKIP,
               organization_name = SKIP, is_provisioning_allowed = SKIP,
               carriers = SKIP, features = SKIP, service_plans = SKIP)
  @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
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.



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.
   = 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 object from extracted values.
  AccountDetails.new(,
                     ,
                     organization_name,
                     is_provisioning_allowed,
                     carriers,
                     features,
                     service_plans)
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