Class: ApiReference::NewPlanVersion

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/new_plan_version.rb

Overview

NewPlanVersion 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(version:, add_prices: SKIP, remove_prices: SKIP, replace_prices: SKIP, add_adjustments: SKIP, remove_adjustments: SKIP, replace_adjustments: SKIP, set_as_default: SKIP) ⇒ NewPlanVersion

Returns a new instance of NewPlanVersion.



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/api_reference/models/new_plan_version.rb', line 84

def initialize(version:, add_prices: SKIP, remove_prices: SKIP,
               replace_prices: SKIP, add_adjustments: SKIP,
               remove_adjustments: SKIP, replace_adjustments: SKIP,
               set_as_default: SKIP)
  @add_prices = add_prices unless add_prices == SKIP
  @remove_prices = remove_prices unless remove_prices == SKIP
  @replace_prices = replace_prices unless replace_prices == SKIP
  @add_adjustments = add_adjustments unless add_adjustments == SKIP
  @remove_adjustments = remove_adjustments unless remove_adjustments == SKIP
  @replace_adjustments = replace_adjustments unless replace_adjustments == SKIP
  @set_as_default = set_as_default unless set_as_default == SKIP
  @version = version
end

Instance Attribute Details

#add_adjustmentsArray[AddPlanAdjustmentParams]

Additional adjustments to be added to the plan.

Returns:



26
27
28
# File 'lib/api_reference/models/new_plan_version.rb', line 26

def add_adjustments
  @add_adjustments
end

#add_pricesArray[AddPlanPriceParams]

Additional prices to be added to the plan.

Returns:



14
15
16
# File 'lib/api_reference/models/new_plan_version.rb', line 14

def add_prices
  @add_prices
end

#remove_adjustmentsArray[RemovePlanAdjustmentParams]

Adjustments to be removed from the plan.

Returns:



30
31
32
# File 'lib/api_reference/models/new_plan_version.rb', line 30

def remove_adjustments
  @remove_adjustments
end

#remove_pricesArray[RemovePlanPriceParams]

Prices to be removed from the plan.

Returns:



18
19
20
# File 'lib/api_reference/models/new_plan_version.rb', line 18

def remove_prices
  @remove_prices
end

#replace_adjustmentsArray[ReplacePlanAdjustmentParams]

Adjustments to be replaced with additional adjustments on the plan.

Returns:



34
35
36
# File 'lib/api_reference/models/new_plan_version.rb', line 34

def replace_adjustments
  @replace_adjustments
end

#replace_pricesArray[ReplacePlanPriceParams]

Prices to be replaced with additional prices on the plan.

Returns:



22
23
24
# File 'lib/api_reference/models/new_plan_version.rb', line 22

def replace_prices
  @replace_prices
end

#set_as_defaultTrueClass | FalseClass

Set this new plan version as the default

Returns:

  • (TrueClass | FalseClass)


38
39
40
# File 'lib/api_reference/models/new_plan_version.rb', line 38

def set_as_default
  @set_as_default
end

#versionInteger

New version number.

Returns:

  • (Integer)


42
43
44
# File 'lib/api_reference/models/new_plan_version.rb', line 42

def version
  @version
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/api_reference/models/new_plan_version.rb', line 99

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  version = hash.key?('version') ? hash['version'] : nil
  # Parameter is an array, so we need to iterate through it
  add_prices = nil
  unless hash['add_prices'].nil?
    add_prices = []
    hash['add_prices'].each do |structure|
      add_prices << (AddPlanPriceParams.from_hash(structure) if structure)
    end
  end

  add_prices = SKIP unless hash.key?('add_prices')
  # Parameter is an array, so we need to iterate through it
  remove_prices = nil
  unless hash['remove_prices'].nil?
    remove_prices = []
    hash['remove_prices'].each do |structure|
      remove_prices << (RemovePlanPriceParams.from_hash(structure) if structure)
    end
  end

  remove_prices = SKIP unless hash.key?('remove_prices')
  # Parameter is an array, so we need to iterate through it
  replace_prices = nil
  unless hash['replace_prices'].nil?
    replace_prices = []
    hash['replace_prices'].each do |structure|
      replace_prices << (ReplacePlanPriceParams.from_hash(structure) if structure)
    end
  end

  replace_prices = SKIP unless hash.key?('replace_prices')
  # Parameter is an array, so we need to iterate through it
  add_adjustments = nil
  unless hash['add_adjustments'].nil?
    add_adjustments = []
    hash['add_adjustments'].each do |structure|
      add_adjustments << (AddPlanAdjustmentParams.from_hash(structure) if structure)
    end
  end

  add_adjustments = SKIP unless hash.key?('add_adjustments')
  # Parameter is an array, so we need to iterate through it
  remove_adjustments = nil
  unless hash['remove_adjustments'].nil?
    remove_adjustments = []
    hash['remove_adjustments'].each do |structure|
      remove_adjustments << (RemovePlanAdjustmentParams.from_hash(structure) if structure)
    end
  end

  remove_adjustments = SKIP unless hash.key?('remove_adjustments')
  # Parameter is an array, so we need to iterate through it
  replace_adjustments = nil
  unless hash['replace_adjustments'].nil?
    replace_adjustments = []
    hash['replace_adjustments'].each do |structure|
      replace_adjustments << (ReplacePlanAdjustmentParams.from_hash(structure) if structure)
    end
  end

  replace_adjustments = SKIP unless hash.key?('replace_adjustments')
  set_as_default =
    hash.key?('set_as_default') ? hash['set_as_default'] : SKIP

  # Create object from extracted values.
  NewPlanVersion.new(version: version,
                     add_prices: add_prices,
                     remove_prices: remove_prices,
                     replace_prices: replace_prices,
                     add_adjustments: add_adjustments,
                     remove_adjustments: remove_adjustments,
                     replace_adjustments: replace_adjustments,
                     set_as_default: set_as_default)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/api_reference/models/new_plan_version.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['add_prices'] = 'add_prices'
  @_hash['remove_prices'] = 'remove_prices'
  @_hash['replace_prices'] = 'replace_prices'
  @_hash['add_adjustments'] = 'add_adjustments'
  @_hash['remove_adjustments'] = 'remove_adjustments'
  @_hash['replace_adjustments'] = 'replace_adjustments'
  @_hash['set_as_default'] = 'set_as_default'
  @_hash['version'] = 'version'
  @_hash
end

.nullablesObject

An array for nullable fields



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/api_reference/models/new_plan_version.rb', line 72

def self.nullables
  %w[
    add_prices
    remove_prices
    replace_prices
    add_adjustments
    remove_adjustments
    replace_adjustments
    set_as_default
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    add_prices
    remove_prices
    replace_prices
    add_adjustments
    remove_adjustments
    replace_adjustments
    set_as_default
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



188
189
190
191
192
193
194
195
# File 'lib/api_reference/models/new_plan_version.rb', line 188

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} add_prices: #{@add_prices.inspect}, remove_prices:"\
  " #{@remove_prices.inspect}, replace_prices: #{@replace_prices.inspect}, add_adjustments:"\
  " #{@add_adjustments.inspect}, remove_adjustments: #{@remove_adjustments.inspect},"\
  " replace_adjustments: #{@replace_adjustments.inspect}, set_as_default:"\
  " #{@set_as_default.inspect}, version: #{@version.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



179
180
181
182
183
184
185
# File 'lib/api_reference/models/new_plan_version.rb', line 179

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} add_prices: #{@add_prices}, remove_prices: #{@remove_prices},"\
  " replace_prices: #{@replace_prices}, add_adjustments: #{@add_adjustments},"\
  " remove_adjustments: #{@remove_adjustments}, replace_adjustments: #{@replace_adjustments},"\
  " set_as_default: #{@set_as_default}, version: #{@version}>"
end