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

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

Constructor Details

#initialize(carrier_service_plan_code: SKIP, code: SKIP, extended_attributes: SKIP, name: SKIP, size_kb: SKIP, additional_properties: nil) ⇒ ServicePlan

Returns a new instance of ServicePlan.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# 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,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  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
  @additional_properties = additional_properties
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.



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
102
103
104
105
106
107
108
109
110
111
# File 'lib/verizon/models/service_plan.rb', line 77

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 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.
  ServicePlan.new(carrier_service_plan_code: carrier_service_plan_code,
                  code: code,
                  extended_attributes: extended_attributes,
                  name: name,
                  size_kb: size_kb,
                  additional_properties: additional_properties)
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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



122
123
124
125
126
127
128
# File 'lib/verizon/models/service_plan.rb', line 122

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} carrier_service_plan_code: #{@carrier_service_plan_code.inspect}, code:"\
  " #{@code.inspect}, extended_attributes: #{@extended_attributes.inspect}, name:"\
  " #{@name.inspect}, size_kb: #{@size_kb.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



114
115
116
117
118
119
# File 'lib/verizon/models/service_plan.rb', line 114

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} carrier_service_plan_code: #{@carrier_service_plan_code}, code: #{@code},"\
  " extended_attributes: #{@extended_attributes}, name: #{@name}, size_kb: #{@size_kb},"\
  " additional_properties: #{@additional_properties}>"
end