Class: ApiReference::AddSubscriptionPriceParams

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

Overview

AddSubscriptionPriceParams 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(price_id: SKIP, external_price_id: SKIP, price: SKIP, allocation_price: SKIP, start_date: SKIP, end_date: SKIP, plan_phase_order: SKIP, minimum_amount: SKIP, maximum_amount: SKIP, discounts: SKIP, metric_parameter_overrides: SKIP, additional_properties: nil) ⇒ AddSubscriptionPriceParams

Returns a new instance of AddSubscriptionPriceParams.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 117

def initialize(price_id: SKIP, external_price_id: SKIP, price: SKIP,
               allocation_price: SKIP, start_date: SKIP, end_date: SKIP,
               plan_phase_order: 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
  @start_date = start_date unless start_date == SKIP
  @end_date = end_date unless end_date == SKIP
  @plan_phase_order = plan_phase_order unless plan_phase_order == SKIP
  @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:



28
29
30
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 28

def allocation_price
  @allocation_price
end

#discountsArray[DiscountOverride]

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

Returns:



59
60
61
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 59

def discounts
  @discounts
end

#end_dateDateTime

The end date of the price interval. This is the date that the price will stop billing on the subscription. If null, billing will end when the phase or subscription ends.

Returns:

  • (DateTime)


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

def end_date
  @end_date
end

#external_price_idString

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

Returns:

  • (String)


19
20
21
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 19

def external_price_id
  @external_price_id
end

#maximum_amountString

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

Returns:

  • (String)


54
55
56
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 54

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)


64
65
66
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 64

def metric_parameter_overrides
  @metric_parameter_overrides
end

#minimum_amountString

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

Returns:

  • (String)


49
50
51
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 49

def minimum_amount
  @minimum_amount
end

#plan_phase_orderInteger

The phase to add this price to.

Returns:

  • (Integer)


44
45
46
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 44

def plan_phase_order
  @plan_phase_order
end

#priceObject

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

Returns:

  • (Object)


23
24
25
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 23

def price
  @price
end

#price_idString

The id of the price to add to the subscription.

Returns:

  • (String)


15
16
17
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 15

def price_id
  @price_id
end

#start_dateDateTime

The start date of the price interval. This is the date that the price will start billing on the subscription. If null, billing will start when the phase or subscription starts.

Returns:

  • (DateTime)


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

def start_date
  @start_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 143

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  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']
  start_date = if hash.key?('start_date')
                 (DateTimeHelper.from_rfc3339(hash['start_date']) if hash['start_date'])
               else
                 SKIP
               end
  end_date = if hash.key?('end_date')
               (DateTimeHelper.from_rfc3339(hash['end_date']) if hash['end_date'])
             else
               SKIP
             end
  plan_phase_order =
    hash.key?('plan_phase_order') ? hash['plan_phase_order'] : 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.
  AddSubscriptionPriceParams.new(price_id: price_id,
                                 external_price_id: external_price_id,
                                 price: price,
                                 allocation_price: allocation_price,
                                 start_date: start_date,
                                 end_date: end_date,
                                 plan_phase_order: plan_phase_order,
                                 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.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 67

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['start_date'] = 'start_date'
  @_hash['end_date'] = 'end_date'
  @_hash['plan_phase_order'] = 'plan_phase_order'
  @_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



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 101

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

.optionalsObject

An array for optional fields



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

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



223
224
225
226
227
228
229
230
231
232
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 223

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}, start_date: #{@start_date.inspect}, end_date:"\
  " #{@end_date.inspect}, plan_phase_order: #{@plan_phase_order.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_custom_end_dateObject



208
209
210
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 208

def to_custom_end_date
  DateTimeHelper.to_rfc3339(end_date)
end

#to_custom_start_dateObject



204
205
206
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 204

def to_custom_start_date
  DateTimeHelper.to_rfc3339(start_date)
end

#to_sObject

Provides a human-readable string representation of the object.



213
214
215
216
217
218
219
220
# File 'lib/api_reference/models/add_subscription_price_params.rb', line 213

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}, start_date: #{@start_date}, end_date:"\
  " #{@end_date}, plan_phase_order: #{@plan_phase_order}, minimum_amount: #{@minimum_amount},"\
  " maximum_amount: #{@maximum_amount}, discounts: #{@discounts}, metric_parameter_overrides:"\
  " #{@metric_parameter_overrides}, additional_properties: #{@additional_properties}>"
end