Class: Verizon::CarrierServicePlan

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

Overview

CarrierServicePlan Model.

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(name: SKIP, code: SKIP, size_kb: SKIP, carrier_service_plan_code: SKIP, additional_properties: nil) ⇒ CarrierServicePlan

Returns a new instance of CarrierServicePlan.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/verizon/models/carrier_service_plan.rb', line 54

def initialize(name: SKIP, code: SKIP, size_kb: SKIP,
               carrier_service_plan_code: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @name = name unless name == SKIP
  @code = code unless code == SKIP
  @size_kb = size_kb unless size_kb == SKIP
  unless carrier_service_plan_code == SKIP
    @carrier_service_plan_code =
      carrier_service_plan_code
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#carrier_service_plan_codeString

The billing record ID. This can be numeric, alpha or alphanumeric.

Returns:

  • (String)


27
28
29
# File 'lib/verizon/models/carrier_service_plan.rb', line 27

def carrier_service_plan_code
  @carrier_service_plan_code
end

#codeString

The inventory name or system name of the service plan

Returns:

  • (String)


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

def code
  @code
end

#nameString

The name of the service plan

Returns:

  • (String)


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

def name
  @name
end

#size_kbString

The ammount of space the service plan will occupy on the Subscriber Information Module (SIM)

Returns:

  • (String)


23
24
25
# File 'lib/verizon/models/carrier_service_plan.rb', line 23

def size_kb
  @size_kb
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/verizon/models/carrier_service_plan.rb', line 70

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : SKIP
  code = hash.key?('code') ? hash['code'] : SKIP
  size_kb = hash.key?('sizeKb') ? hash['sizeKb'] : SKIP
  carrier_service_plan_code =
    hash.key?('carrierServicePlanCode') ? hash['carrierServicePlanCode'] : 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.
  CarrierServicePlan.new(name: name,
                         code: code,
                         size_kb: size_kb,
                         carrier_service_plan_code: carrier_service_plan_code,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/verizon/models/carrier_service_plan.rb', line 30

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

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/verizon/models/carrier_service_plan.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
46
47
# File 'lib/verizon/models/carrier_service_plan.rb', line 40

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



104
105
106
107
108
109
# File 'lib/verizon/models/carrier_service_plan.rb', line 104

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

#to_sObject

Provides a human-readable string representation of the object.



96
97
98
99
100
101
# File 'lib/verizon/models/carrier_service_plan.rb', line 96

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