Class: ApiReference::AddPriceIntervalParams

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

Overview

AddPriceIntervalParams 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(start_date:, usage_customer_ids: SKIP, filter: SKIP, price_id: SKIP, external_price_id: SKIP, price: SKIP, allocation_price: SKIP, end_date: SKIP, can_defer_billing: SKIP, fixed_fee_quantity_transitions: SKIP, discounts: SKIP, minimum_amount: SKIP, maximum_amount: SKIP, metric_parameter_overrides: SKIP, additional_properties: nil) ⇒ AddPriceIntervalParams

Returns a new instance of AddPriceIntervalParams.



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/add_price_interval_params.rb', line 145

def initialize(start_date:, usage_customer_ids: SKIP, filter: SKIP,
               price_id: SKIP, external_price_id: SKIP, price: SKIP,
               allocation_price: SKIP, end_date: SKIP,
               can_defer_billing: SKIP,
               fixed_fee_quantity_transitions: SKIP, discounts: SKIP,
               minimum_amount: SKIP, maximum_amount: SKIP,
               metric_parameter_overrides: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @usage_customer_ids = usage_customer_ids unless usage_customer_ids == SKIP
  @filter = filter unless filter == SKIP
  @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
  @end_date = end_date unless end_date == SKIP
  @can_defer_billing = can_defer_billing unless can_defer_billing == SKIP
  unless fixed_fee_quantity_transitions == SKIP
    @fixed_fee_quantity_transitions =
      fixed_fee_quantity_transitions
  end
  @discounts = discounts unless discounts == SKIP
  @minimum_amount = minimum_amount unless minimum_amount == SKIP
  @maximum_amount = maximum_amount unless maximum_amount == 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:



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

def allocation_price
  @allocation_price
end

#can_defer_billingTrueClass | FalseClass

If true, an in-arrears price interval ending mid-cycle will defer billing the final line item until the next scheduled invoice. If false, it will be billed on its end date.

Returns:

  • (TrueClass | FalseClass)


60
61
62
# File 'lib/api_reference/models/add_price_interval_params.rb', line 60

def can_defer_billing
  @can_defer_billing
end

#discountsArray[Object]

A list of discounts to initialize on the price interval.

Returns:

  • (Array[Object])


69
70
71
# File 'lib/api_reference/models/add_price_interval_params.rb', line 69

def discounts
  @discounts
end

#end_dateObject

The end date of the price interval. This is the date that the price will stop billing on the subscription.

Returns:

  • (Object)


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

def end_date
  @end_date
end

#external_price_idString

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

Returns:

  • (String)


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

def external_price_id
  @external_price_id
end

#filterString

An additional filter to apply to usage queries. This filter must be expressed as a boolean computed property. If null, usage queries will not include any additional filter.

Returns:

  • (String)


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

def filter
  @filter
end

#fixed_fee_quantity_transitionsArray[PriceIntervalFixedFeeQuantityTransitionParams]

A list of fixed fee quantity transitions to initialize on the price interval.



65
66
67
# File 'lib/api_reference/models/add_price_interval_params.rb', line 65

def fixed_fee_quantity_transitions
  @fixed_fee_quantity_transitions
end

#maximum_amountFloat

The maximum amount that will be billed for this price interval for a given billing period.

Returns:

  • (Float)


79
80
81
# File 'lib/api_reference/models/add_price_interval_params.rb', line 79

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 (number or string).

Returns:

  • (Object)


84
85
86
# File 'lib/api_reference/models/add_price_interval_params.rb', line 84

def metric_parameter_overrides
  @metric_parameter_overrides
end

#minimum_amountFloat

The minimum amount that will be billed for this price interval for a given billing period.

Returns:

  • (Float)


74
75
76
# File 'lib/api_reference/models/add_price_interval_params.rb', line 74

def minimum_amount
  @minimum_amount
end

#priceObject

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

Returns:

  • (Object)


39
40
41
# File 'lib/api_reference/models/add_price_interval_params.rb', line 39

def price
  @price
end

#price_idString

The id of the price to add to the subscription.

Returns:

  • (String)


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

def price_id
  @price_id
end

#start_dateObject

The start date of the price interval. This is the date that the price will start billing on the subscription.

Returns:

  • (Object)


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

def start_date
  @start_date
end

#usage_customer_idsArray[String]

A list of customer IDs whose usage events will be aggregated and billed under this subscription. By default, a subscription only considers usage events associated with its attached customer's customer_id. When usage_customer_ids is provided, the subscription includes usage events from the specified customers only. Provided usage_customer_ids must be either the customer for this subscription itself, or any of that customer's children.

Returns:

  • (Array[String])


20
21
22
# File 'lib/api_reference/models/add_price_interval_params.rb', line 20

def usage_customer_ids
  @usage_customer_ids
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/api_reference/models/add_price_interval_params.rb', line 179

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  start_date = hash.key?('start_date') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:AddPriceIntervalParamsStartDate), hash['start_date']
  ) : nil
  usage_customer_ids =
    hash.key?('usage_customer_ids') ? hash['usage_customer_ids'] : SKIP
  filter = hash.key?('filter') ? hash['filter'] : SKIP
  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') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:NewFloatingPrice), hash['price']
  ) : SKIP
  allocation_price = NewAllocationPrice.from_hash(hash['allocation_price']) if
    hash['allocation_price']
  end_date = hash.key?('end_date') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:AddPriceIntervalParamsEndDate), hash['end_date']
  ) : SKIP
  can_defer_billing =
    hash.key?('can_defer_billing') ? hash['can_defer_billing'] : SKIP
  # Parameter is an array, so we need to iterate through it
  fixed_fee_quantity_transitions = nil
  unless hash['fixed_fee_quantity_transitions'].nil?
    fixed_fee_quantity_transitions = []
    hash['fixed_fee_quantity_transitions'].each do |structure|
      fixed_fee_quantity_transitions << (PriceIntervalFixedFeeQuantityTransitionParams.from_hash(structure) if structure)
    end
  end

  fixed_fee_quantity_transitions = SKIP unless hash.key?('fixed_fee_quantity_transitions')
  discounts = hash.key?('discounts') ? hash['discounts'] : SKIP
  minimum_amount =
    hash.key?('minimum_amount') ? hash['minimum_amount'] : SKIP
  maximum_amount =
    hash.key?('maximum_amount') ? hash['maximum_amount'] : SKIP
  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.
  AddPriceIntervalParams.new(start_date: start_date,
                             usage_customer_ids: usage_customer_ids,
                             filter: filter,
                             price_id: price_id,
                             external_price_id: external_price_id,
                             price: price,
                             allocation_price: allocation_price,
                             end_date: end_date,
                             can_defer_billing: can_defer_billing,
                             fixed_fee_quantity_transitions: fixed_fee_quantity_transitions,
                             discounts: discounts,
                             minimum_amount: minimum_amount,
                             maximum_amount: maximum_amount,
                             metric_parameter_overrides: metric_parameter_overrides,
                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/api_reference/models/add_price_interval_params.rb', line 87

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['usage_customer_ids'] = 'usage_customer_ids'
  @_hash['filter'] = 'filter'
  @_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['can_defer_billing'] = 'can_defer_billing'
  @_hash['fixed_fee_quantity_transitions'] =
    'fixed_fee_quantity_transitions'
  @_hash['discounts'] = 'discounts'
  @_hash['minimum_amount'] = 'minimum_amount'
  @_hash['maximum_amount'] = 'maximum_amount'
  @_hash['metric_parameter_overrides'] = 'metric_parameter_overrides'
  @_hash
end

.nullablesObject

An array for nullable fields



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/api_reference/models/add_price_interval_params.rb', line 127

def self.nullables
  %w[
    usage_customer_ids
    filter
    price_id
    external_price_id
    price
    allocation_price
    end_date
    can_defer_billing
    fixed_fee_quantity_transitions
    discounts
    minimum_amount
    maximum_amount
    metric_parameter_overrides
  ]
end

.optionalsObject

An array for optional fields



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/api_reference/models/add_price_interval_params.rb', line 108

def self.optionals
  %w[
    usage_customer_ids
    filter
    price_id
    external_price_id
    price
    allocation_price
    end_date
    can_defer_billing
    fixed_fee_quantity_transitions
    discounts
    minimum_amount
    maximum_amount
    metric_parameter_overrides
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



259
260
261
262
263
264
265
266
267
268
269
# File 'lib/api_reference/models/add_price_interval_params.rb', line 259

def self.validate(value)
  if value.instance_of? self
    return UnionTypeLookUp.get(:AddPriceIntervalParamsStartDate)
                          .validate(value.start_date)
  end

  return false unless value.instance_of? Hash

  UnionTypeLookUp.get(:AddPriceIntervalParamsStartDate)
                 .validate(value['start_date'])
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/api_reference/models/add_price_interval_params.rb', line 284

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} usage_customer_ids: #{@usage_customer_ids.inspect}, filter:"\
  " #{@filter.inspect}, 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}, can_defer_billing: #{@can_defer_billing.inspect},"\
  " fixed_fee_quantity_transitions: #{@fixed_fee_quantity_transitions.inspect}, discounts:"\
  " #{@discounts.inspect}, minimum_amount: #{@minimum_amount.inspect}, maximum_amount:"\
  " #{@maximum_amount.inspect}, metric_parameter_overrides:"\
  " #{@metric_parameter_overrides.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



272
273
274
275
276
277
278
279
280
281
# File 'lib/api_reference/models/add_price_interval_params.rb', line 272

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

#to_union_type_end_dateObject



251
252
253
254
255
# File 'lib/api_reference/models/add_price_interval_params.rb', line 251

def to_union_type_end_date
  UnionTypeLookUp.get(:AddPriceIntervalParamsEndDate)
                 .validate(end_date)
                 .serialize(end_date)
end

#to_union_type_start_dateObject



245
246
247
248
249
# File 'lib/api_reference/models/add_price_interval_params.rb', line 245

def to_union_type_start_date
  UnionTypeLookUp.get(:AddPriceIntervalParamsStartDate)
                 .validate(start_date)
                 .serialize(start_date)
end