Class: Verizon::ServicePlan
- Defined in:
- lib/verizon/models/service_plan.rb
Overview
Details of the service plan.
Instance Attribute Summary collapse
-
#carrier_service_plan_code ⇒ String
The code that is used by the carrier for the service plan.
-
#code ⇒ String
The code of the service plan, which may not be the same as the name.
-
#extended_attributes ⇒ Array[CustomFields]
Any extended attributes for the service plan, as Key and Value pairs.
-
#name ⇒ String
The name of the service plan.
-
#size_kb ⇒ Integer
The size of the service plan in kilobytes.
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(carrier_service_plan_code = SKIP, code = SKIP, extended_attributes = SKIP, name = SKIP, size_kb = SKIP) ⇒ ServicePlan
constructor
A new instance of ServicePlan.
Methods inherited from BaseModel
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 70 71 72 |
# 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_code ⇒ String
The code that is used by the carrier for the service plan.
14 15 16 |
# File 'lib/verizon/models/service_plan.rb', line 14 def carrier_service_plan_code @carrier_service_plan_code end |
#code ⇒ String
The code of the service plan, which may not be the same as the name.
18 19 20 |
# File 'lib/verizon/models/service_plan.rb', line 18 def code @code end |
#extended_attributes ⇒ Array[CustomFields]
Any extended attributes for the service plan, as Key and Value pairs.
22 23 24 |
# File 'lib/verizon/models/service_plan.rb', line 22 def extended_attributes @extended_attributes end |
#name ⇒ String
The name of the service plan.
26 27 28 |
# File 'lib/verizon/models/service_plan.rb', line 26 def name @name end |
#size_kb ⇒ Integer
The size of the service plan in kilobytes.
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.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/verizon/models/service_plan.rb', line 75 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 |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
55 56 57 |
# File 'lib/verizon/models/service_plan.rb', line 55 def self.nullables [] end |
.optionals ⇒ Object
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 |