Class: Verizon::Account

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

Overview

Returns information about a specified 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_name = SKIP, account_number = SKIP, organization_name = SKIP, is_provisioning_allowed = SKIP, carriers = SKIP, features = SKIP, i_p_pools = SKIP, service_plans = SKIP) ⇒ Account

Returns a new instance of Account.



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/verizon/models/account.rb', line 79

def initialize( = SKIP,  = SKIP,
               organization_name = SKIP, is_provisioning_allowed = SKIP,
               carriers = SKIP, features = SKIP, i_p_pools = 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
  @i_p_pools = i_p_pools unless i_p_pools == SKIP
  @service_plans = service_plans unless service_plans == SKIP
end

Instance Attribute Details

#account_nameString

The name of the account.

Returns:

  • (String)


14
15
16
# File 'lib/verizon/models/account.rb', line 14

def 
  @account_name
end

#account_numberString

The billing number of the account.

Returns:

  • (String)


18
19
20
# File 'lib/verizon/models/account.rb', line 18

def 
  @account_number
end

#carriersArray[String]

The names of all carriers for the account.

Returns:

  • (Array[String])


32
33
34
# File 'lib/verizon/models/account.rb', line 32

def carriers
  @carriers
end

#featuresArray[String]

The names of features that are enabled for the account.

Returns:

  • (Array[String])


36
37
38
# File 'lib/verizon/models/account.rb', line 36

def features
  @features
end

#i_p_poolsArray[IPPool]

Array of IP pools that are available to the account.

Returns:



40
41
42
# File 'lib/verizon/models/account.rb', line 40

def i_p_pools
  @i_p_pools
end

#is_provisioning_allowedTrueClass | FalseClass

True if devices can be added to the account and activated with a single request. False if devices must be added to the account before they can be activated.

Returns:

  • (TrueClass | FalseClass)


28
29
30
# File 'lib/verizon/models/account.rb', line 28

def is_provisioning_allowed
  @is_provisioning_allowed
end

#organization_nameString

The name of the organization that the account is part of.

Returns:

  • (String)


22
23
24
# File 'lib/verizon/models/account.rb', line 22

def organization_name
  @organization_name
end

#service_plansArray[ServicePlan]

Array of service plans that are available to the account.

Returns:



44
45
46
# File 'lib/verizon/models/account.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.



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
# File 'lib/verizon/models/account.rb', line 94

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
  carriers = hash.key?('carriers') ? hash['carriers'] : SKIP
  features = hash.key?('features') ? hash['features'] : SKIP
  # Parameter is an array, so we need to iterate through it
  i_p_pools = nil
  unless hash['iPPools'].nil?
    i_p_pools = []
    hash['iPPools'].each do |structure|
      i_p_pools << (IPPool.from_hash(structure) if structure)
    end
  end

  i_p_pools = SKIP unless hash.key?('iPPools')
  # 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 << (ServicePlan.from_hash(structure) if structure)
    end
  end

  service_plans = SKIP unless hash.key?('servicePlans')

  # Create object from extracted values.
  Account.new(,
              ,
              organization_name,
              is_provisioning_allowed,
              carriers,
              features,
              i_p_pools,
              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
58
# File 'lib/verizon/models/account.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['i_p_pools'] = 'iPPools'
  @_hash['service_plans'] = 'servicePlans'
  @_hash
end

.nullablesObject

An array for nullable fields



75
76
77
# File 'lib/verizon/models/account.rb', line 75

def self.nullables
  []
end

.optionalsObject

An array for optional fields



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/verizon/models/account.rb', line 61

def self.optionals
  %w[
    account_name
    account_number
    organization_name
    is_provisioning_allowed
    carriers
    features
    i_p_pools
    service_plans
  ]
end