Class: Verizon::ServicePlan

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

Overview

Details of the service plan.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(carrier_service_plan_code = SKIP, code = SKIP, extended_attributes = SKIP, name = SKIP, size_kb = SKIP) ⇒ ServicePlan

Returns a new instance of ServicePlan.



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/verizon/models/service_plan.rb', line 59

def initialize(carrier_service_plan_code = SKIP, code = SKIP,
               extended_attributes = SKIP, name = SKIP, size_kb = SKIP)
  unless carrier_service_plan_code == SKIP
    @carrier_service_plan_code =
      carrier_service_plan_code
  end
  @code = code unless code == SKIP
  @extended_attributes = extended_attributes unless extended_attributes == SKIP
  @name = name unless name == SKIP
  @size_kb = size_kb unless size_kb == SKIP
end

Instance Attribute Details

#carrier_service_plan_codeString

The code that is used by the carrier for the service plan.

Returns:

  • (String)


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

def carrier_service_plan_code
  @carrier_service_plan_code
end

#codeString

The code of the service plan, which may not be the same as the name.

Returns:

  • (String)


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

def code
  @code
end

#extended_attributesArray[CustomFields]

Any extended attributes for the service plan, as Key and Value pairs.

Returns:



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

def extended_attributes
  @extended_attributes
end

#nameString

The name of the service plan.

Returns:

  • (String)


26
27
28
# File 'lib/verizon/models/service_plan.rb', line 26

def name
  @name
end

#size_kbInteger

The size of the service plan in kilobytes.

Returns:

  • (Integer)


30
31
32
# File 'lib/verizon/models/service_plan.rb', line 30

def size_kb
  @size_kb
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/verizon/models/service_plan.rb', line 72

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  carrier_service_plan_code =
    hash.key?('carrierServicePlanCode') ? hash['carrierServicePlanCode'] : SKIP
  code = hash.key?('code') ? hash['code'] : SKIP
  # Parameter is an array, so we need to iterate through it
  extended_attributes = nil
  unless hash['extendedAttributes'].nil?
    extended_attributes = []
    hash['extendedAttributes'].each do |structure|
      extended_attributes << (CustomFields.from_hash(structure) if structure)
    end
  end

  extended_attributes = SKIP unless hash.key?('extendedAttributes')
  name = hash.key?('name') ? hash['name'] : SKIP
  size_kb = hash.key?('sizeKb') ? hash['sizeKb'] : SKIP

  # Create object from extracted values.
  ServicePlan.new(carrier_service_plan_code,
                  code,
                  extended_attributes,
                  name,
                  size_kb)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/verizon/models/service_plan.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['carrier_service_plan_code'] = 'carrierServicePlanCode'
  @_hash['code'] = 'code'
  @_hash['extended_attributes'] = 'extendedAttributes'
  @_hash['name'] = 'name'
  @_hash['size_kb'] = 'sizeKb'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/verizon/models/service_plan.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
47
48
49
50
51
52
# File 'lib/verizon/models/service_plan.rb', line 44

def self.optionals
  %w[
    carrier_service_plan_code
    code
    extended_attributes
    name
    size_kb
  ]
end