Class: ApiReference::ReplaceSubscriptionPriceParams

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

Overview

ReplaceSubscriptionPriceParams 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(replaces_price_id:, price_id: SKIP, external_price_id: SKIP, price: SKIP, allocation_price: SKIP, fixed_price_quantity: SKIP, minimum_amount: SKIP, maximum_amount: SKIP, discounts: SKIP, metric_parameter_overrides: SKIP, additional_properties: nil) ⇒ ReplaceSubscriptionPriceParams

Returns a new instance of ReplaceSubscriptionPriceParams.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 103

def initialize(replaces_price_id:, price_id: SKIP, external_price_id: SKIP,
               price: SKIP, allocation_price: SKIP,
               fixed_price_quantity: SKIP, minimum_amount: SKIP,
               maximum_amount: SKIP, discounts: SKIP,
               metric_parameter_overrides: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @price_id = price_id unless price_id == SKIP
  @external_price_id = external_price_id unless external_price_id == SKIP
  @price = price unless price == SKIP
  @allocation_price = allocation_price unless allocation_price == SKIP
  @fixed_price_quantity = fixed_price_quantity unless fixed_price_quantity == SKIP
  @replaces_price_id = replaces_price_id
  @minimum_amount = minimum_amount unless minimum_amount == SKIP
  @maximum_amount = maximum_amount unless maximum_amount == SKIP
  @discounts = discounts unless discounts == SKIP
  unless metric_parameter_overrides == SKIP
    @metric_parameter_overrides =
      metric_parameter_overrides
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#allocation_priceNewAllocationPrice

The definition of a new allocation price to create and add to the subscription.

Returns:



27
28
29
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 27

def allocation_price
  @allocation_price
end

#discountsArray[DiscountOverride]

[DEPRECATED] Use add_adjustments instead. The subscription's discounts for the replacement price.

Returns:



50
51
52
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 50

def discounts
  @discounts
end

#external_price_idString

The external price id of the price to add to the subscription.

Returns:

  • (String)


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

def external_price_id
  @external_price_id
end

#fixed_price_quantityFloat

The new quantity of the price, if the price is a fixed price.

Returns:

  • (Float)


31
32
33
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 31

def fixed_price_quantity
  @fixed_price_quantity
end

#maximum_amountString

[DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the replacement price.

Returns:

  • (String)


45
46
47
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 45

def maximum_amount
  @maximum_amount
end

#metric_parameter_overridesObject

Override values for parameterized billable metric variables. Keys are parameter names, values are the override values.

Returns:

  • (Object)


55
56
57
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 55

def metric_parameter_overrides
  @metric_parameter_overrides
end

#minimum_amountString

[DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the replacement price.

Returns:

  • (String)


40
41
42
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 40

def minimum_amount
  @minimum_amount
end

#priceObject

The definition of a new price to create and add to the subscription.

Returns:

  • (Object)


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

def price
  @price
end

#price_idString

The id of the price to add to the subscription.

Returns:

  • (String)


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

def price_id
  @price_id
end

#replaces_price_idString

The id of the price on the plan to replace in the subscription.

Returns:

  • (String)


35
36
37
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 35

def replaces_price_id
  @replaces_price_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
177
178
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 128

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  replaces_price_id =
    hash.key?('replaces_price_id') ? hash['replaces_price_id'] : nil
  price_id = hash.key?('price_id') ? hash['price_id'] : SKIP
  external_price_id =
    hash.key?('external_price_id') ? hash['external_price_id'] : SKIP
  price = hash.key?('price') ? hash['price'] : SKIP
  allocation_price = NewAllocationPrice.from_hash(hash['allocation_price']) if
    hash['allocation_price']
  fixed_price_quantity =
    hash.key?('fixed_price_quantity') ? hash['fixed_price_quantity'] : SKIP
  minimum_amount =
    hash.key?('minimum_amount') ? hash['minimum_amount'] : SKIP
  maximum_amount =
    hash.key?('maximum_amount') ? hash['maximum_amount'] : SKIP
  # Parameter is an array, so we need to iterate through it
  discounts = nil
  unless hash['discounts'].nil?
    discounts = []
    hash['discounts'].each do |structure|
      discounts << (DiscountOverride.from_hash(structure) if structure)
    end
  end

  discounts = SKIP unless hash.key?('discounts')
  metric_parameter_overrides =
    hash.key?('metric_parameter_overrides') ? hash['metric_parameter_overrides'] : 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.
  ReplaceSubscriptionPriceParams.new(replaces_price_id: replaces_price_id,
                                     price_id: price_id,
                                     external_price_id: external_price_id,
                                     price: price,
                                     allocation_price: allocation_price,
                                     fixed_price_quantity: fixed_price_quantity,
                                     minimum_amount: minimum_amount,
                                     maximum_amount: maximum_amount,
                                     discounts: discounts,
                                     metric_parameter_overrides: metric_parameter_overrides,
                                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['price_id'] = 'price_id'
  @_hash['external_price_id'] = 'external_price_id'
  @_hash['price'] = 'price'
  @_hash['allocation_price'] = 'allocation_price'
  @_hash['fixed_price_quantity'] = 'fixed_price_quantity'
  @_hash['replaces_price_id'] = 'replaces_price_id'
  @_hash['minimum_amount'] = 'minimum_amount'
  @_hash['maximum_amount'] = 'maximum_amount'
  @_hash['discounts'] = 'discounts'
  @_hash['metric_parameter_overrides'] = 'metric_parameter_overrides'
  @_hash
end

.nullablesObject

An array for nullable fields



89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 89

def self.nullables
  %w[
    price_id
    external_price_id
    price
    allocation_price
    fixed_price_quantity
    minimum_amount
    maximum_amount
    discounts
    metric_parameter_overrides
  ]
end

.optionalsObject

An array for optional fields



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 74

def self.optionals
  %w[
    price_id
    external_price_id
    price
    allocation_price
    fixed_price_quantity
    minimum_amount
    maximum_amount
    discounts
    metric_parameter_overrides
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



192
193
194
195
196
197
198
199
200
201
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 192

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} price_id: #{@price_id.inspect}, external_price_id:"\
  " #{@external_price_id.inspect}, price: #{@price.inspect}, allocation_price:"\
  " #{@allocation_price.inspect}, fixed_price_quantity: #{@fixed_price_quantity.inspect},"\
  " replaces_price_id: #{@replaces_price_id.inspect}, minimum_amount:"\
  " #{@minimum_amount.inspect}, maximum_amount: #{@maximum_amount.inspect}, discounts:"\
  " #{@discounts.inspect}, metric_parameter_overrides: #{@metric_parameter_overrides.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



181
182
183
184
185
186
187
188
189
# File 'lib/api_reference/models/replace_subscription_price_params.rb', line 181

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} price_id: #{@price_id}, external_price_id: #{@external_price_id}, price:"\
  " #{@price}, allocation_price: #{@allocation_price}, fixed_price_quantity:"\
  " #{@fixed_price_quantity}, replaces_price_id: #{@replaces_price_id}, minimum_amount:"\
  " #{@minimum_amount}, maximum_amount: #{@maximum_amount}, discounts: #{@discounts},"\
  " metric_parameter_overrides: #{@metric_parameter_overrides}, additional_properties:"\
  " #{@additional_properties}>"
end