Class: AdvancedBilling::ProductPricePoint

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/product_price_point.rb

Overview

ProductPricePoint Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id: SKIP, name: SKIP, handle: SKIP, price_in_cents: SKIP, interval: SKIP, interval_unit: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, trial_type: SKIP, introductory_offer: SKIP, initial_charge_in_cents: SKIP, initial_charge_after_trial: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, product_id: SKIP, archived_at: SKIP, created_at: SKIP, updated_at: SKIP, use_site_exchange_rate: SKIP, type: SKIP, tax_included: SKIP, subscription_id: SKIP, currency_prices: SKIP, additional_properties: {}) ⇒ ProductPricePoint

Returns a new instance of ProductPricePoint.



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
244
245
246
247
248
249
# File 'lib/advanced_billing/models/product_price_point.rb', line 206

def initialize(id: SKIP, name: SKIP, handle: SKIP, price_in_cents: SKIP,
               interval: SKIP, interval_unit: SKIP,
               trial_price_in_cents: SKIP, trial_interval: SKIP,
               trial_interval_unit: SKIP, trial_type: SKIP,
               introductory_offer: SKIP, initial_charge_in_cents: SKIP,
               initial_charge_after_trial: SKIP, expiration_interval: SKIP,
               expiration_interval_unit: SKIP, product_id: SKIP,
               archived_at: SKIP, created_at: SKIP, updated_at: SKIP,
               use_site_exchange_rate: SKIP, type: SKIP, tax_included: SKIP,
               subscription_id: SKIP, currency_prices: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @id = id unless id == SKIP
  @name = name unless name == SKIP
  @handle = handle unless handle == SKIP
  @price_in_cents = price_in_cents unless price_in_cents == SKIP
  @interval = interval unless interval == SKIP
  @interval_unit = interval_unit unless interval_unit == SKIP
  @trial_price_in_cents = trial_price_in_cents unless trial_price_in_cents == SKIP
  @trial_interval = trial_interval unless trial_interval == SKIP
  @trial_interval_unit = trial_interval_unit unless trial_interval_unit == SKIP
  @trial_type = trial_type unless trial_type == SKIP
  @introductory_offer = introductory_offer unless introductory_offer == SKIP
  @initial_charge_in_cents = initial_charge_in_cents unless initial_charge_in_cents == SKIP
  unless initial_charge_after_trial == SKIP
    @initial_charge_after_trial =
      initial_charge_after_trial
  end
  @expiration_interval = expiration_interval unless expiration_interval == SKIP
  @expiration_interval_unit = expiration_interval_unit unless expiration_interval_unit == SKIP
  @product_id = product_id unless product_id == SKIP
  @archived_at = archived_at unless archived_at == SKIP
  @created_at = created_at unless created_at == SKIP
  @updated_at = updated_at unless updated_at == SKIP
  @use_site_exchange_rate = use_site_exchange_rate unless use_site_exchange_rate == SKIP
  @type = type unless type == SKIP
  @tax_included = tax_included unless tax_included == SKIP
  @subscription_id = subscription_id unless subscription_id == SKIP
  @currency_prices = currency_prices unless currency_prices == SKIP
end

Instance Attribute Details

#archived_atDateTime

Timestamp indicating when this price point was archived

Returns:

  • (DateTime)


93
94
95
# File 'lib/advanced_billing/models/product_price_point.rb', line 93

def archived_at
  @archived_at
end

#created_atDateTime

Timestamp indicating when this price point was created

Returns:

  • (DateTime)


97
98
99
# File 'lib/advanced_billing/models/product_price_point.rb', line 97

def created_at
  @created_at
end

#currency_pricesArray[CurrencyPrice]

An array of currency pricing data is available when multiple currencies are defined for the site. It varies based on the use_site_exchange_rate setting for the price point. This parameter is present only in the response of read endpoints, after including the appropriate query parameter.

Returns:



126
127
128
# File 'lib/advanced_billing/models/product_price_point.rb', line 126

def currency_prices
  @currency_prices
end

#expiration_intervalInteger

The numerical expiration interval. i.e. an expiration_interval of ‘30’coupled with an expiration_interval_unit of day would mean this product price point would expire after 30 days

Returns:

  • (Integer)


80
81
82
# File 'lib/advanced_billing/models/product_price_point.rb', line 80

def expiration_interval
  @expiration_interval
end

#expiration_interval_unitExpirationIntervalUnit

A string representing the expiration interval unit for this product price point, either month, day or never



85
86
87
# File 'lib/advanced_billing/models/product_price_point.rb', line 85

def expiration_interval_unit
  @expiration_interval_unit
end

#handleString

The product price point API handle

Returns:

  • (String)


23
24
25
# File 'lib/advanced_billing/models/product_price_point.rb', line 23

def handle
  @handle
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


15
16
17
# File 'lib/advanced_billing/models/product_price_point.rb', line 15

def id
  @id
end

#initial_charge_after_trialTrueClass | FalseClass

The product price point initial charge, in integer cents

Returns:

  • (TrueClass | FalseClass)


74
75
76
# File 'lib/advanced_billing/models/product_price_point.rb', line 74

def initial_charge_after_trial
  @initial_charge_after_trial
end

#initial_charge_in_centsInteger

The product price point initial charge, in integer cents

Returns:

  • (Integer)


70
71
72
# File 'lib/advanced_billing/models/product_price_point.rb', line 70

def initial_charge_in_cents
  @initial_charge_in_cents
end

#intervalInteger

The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this product price point would renew every 30 days

Returns:

  • (Integer)


33
34
35
# File 'lib/advanced_billing/models/product_price_point.rb', line 33

def interval
  @interval
end

#interval_unitIntervalUnit

A string representing the interval unit for this product price point, either month or day

Returns:



38
39
40
# File 'lib/advanced_billing/models/product_price_point.rb', line 38

def interval_unit
  @interval_unit
end

#introductory_offerTrueClass | FalseClass

reserved for future use

Returns:

  • (TrueClass | FalseClass)


66
67
68
# File 'lib/advanced_billing/models/product_price_point.rb', line 66

def introductory_offer
  @introductory_offer
end

#nameString

The product price point name

Returns:

  • (String)


19
20
21
# File 'lib/advanced_billing/models/product_price_point.rb', line 19

def name
  @name
end

#price_in_centsInteger

The product price point price, in integer cents

Returns:

  • (Integer)


27
28
29
# File 'lib/advanced_billing/models/product_price_point.rb', line 27

def price_in_cents
  @price_in_cents
end

#product_idInteger

The product id this price point belongs to

Returns:

  • (Integer)


89
90
91
# File 'lib/advanced_billing/models/product_price_point.rb', line 89

def product_id
  @product_id
end

#subscription_idInteger

The subscription id this price point belongs to

Returns:

  • (Integer)


118
119
120
# File 'lib/advanced_billing/models/product_price_point.rb', line 118

def subscription_id
  @subscription_id
end

#tax_includedTrueClass | FalseClass

Whether or not the price point includes tax

Returns:

  • (TrueClass | FalseClass)


114
115
116
# File 'lib/advanced_billing/models/product_price_point.rb', line 114

def tax_included
  @tax_included
end

#trial_intervalInteger

The numerical trial interval. i.e. an interval of ‘30’ coupled with a trial_interval_unit of day would mean this product price point trial would last 30 days

Returns:

  • (Integer)


48
49
50
# File 'lib/advanced_billing/models/product_price_point.rb', line 48

def trial_interval
  @trial_interval
end

#trial_interval_unitIntervalUnit

A string representing the trial interval unit for this product price point, either month or day

Returns:



53
54
55
# File 'lib/advanced_billing/models/product_price_point.rb', line 53

def trial_interval_unit
  @trial_interval_unit
end

#trial_price_in_centsInteger

The product price point trial price, in integer cents

Returns:

  • (Integer)


42
43
44
# File 'lib/advanced_billing/models/product_price_point.rb', line 42

def trial_price_in_cents
  @trial_price_in_cents
end

#trial_typeTrialType

Indicates how a trial is handled when the trail period ends and there is no credit card on file. For ‘no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings.

Returns:



62
63
64
# File 'lib/advanced_billing/models/product_price_point.rb', line 62

def trial_type
  @trial_type
end

#typePricePointType

The type of price point

Returns:



110
111
112
# File 'lib/advanced_billing/models/product_price_point.rb', line 110

def type
  @type
end

#updated_atDateTime

Timestamp indicating when this price point was last updated

Returns:

  • (DateTime)


101
102
103
# File 'lib/advanced_billing/models/product_price_point.rb', line 101

def updated_at
  @updated_at
end

#use_site_exchange_rateTrueClass | FalseClass

Whether or not to use the site’s exchange rate or define your own pricing when your site has multiple currencies defined.

Returns:

  • (TrueClass | FalseClass)


106
107
108
# File 'lib/advanced_billing/models/product_price_point.rb', line 106

def use_site_exchange_rate
  @use_site_exchange_rate
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/advanced_billing/models/product_price_point.rb', line 252

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  handle = hash.key?('handle') ? hash['handle'] : SKIP
  price_in_cents =
    hash.key?('price_in_cents') ? hash['price_in_cents'] : SKIP
  interval = hash.key?('interval') ? hash['interval'] : SKIP
  interval_unit = hash.key?('interval_unit') ? hash['interval_unit'] : SKIP
  trial_price_in_cents =
    hash.key?('trial_price_in_cents') ? hash['trial_price_in_cents'] : SKIP
  trial_interval =
    hash.key?('trial_interval') ? hash['trial_interval'] : SKIP
  trial_interval_unit =
    hash.key?('trial_interval_unit') ? hash['trial_interval_unit'] : SKIP
  trial_type = hash.key?('trial_type') ? hash['trial_type'] : SKIP
  introductory_offer =
    hash.key?('introductory_offer') ? hash['introductory_offer'] : SKIP
  initial_charge_in_cents =
    hash.key?('initial_charge_in_cents') ? hash['initial_charge_in_cents'] : SKIP
  initial_charge_after_trial =
    hash.key?('initial_charge_after_trial') ? hash['initial_charge_after_trial'] : SKIP
  expiration_interval =
    hash.key?('expiration_interval') ? hash['expiration_interval'] : SKIP
  expiration_interval_unit =
    hash.key?('expiration_interval_unit') ? hash['expiration_interval_unit'] : SKIP
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  archived_at = if hash.key?('archived_at')
                  (DateTimeHelper.from_rfc3339(hash['archived_at']) if hash['archived_at'])
                else
                  SKIP
                end
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end
  updated_at = if hash.key?('updated_at')
                 (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
               else
                 SKIP
               end
  use_site_exchange_rate =
    hash.key?('use_site_exchange_rate') ? hash['use_site_exchange_rate'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  tax_included = hash.key?('tax_included') ? hash['tax_included'] : SKIP
  subscription_id =
    hash.key?('subscription_id') ? hash['subscription_id'] : SKIP
  # Parameter is an array, so we need to iterate through it
  currency_prices = nil
  unless hash['currency_prices'].nil?
    currency_prices = []
    hash['currency_prices'].each do |structure|
      currency_prices << (CurrencyPrice.from_hash(structure) if structure)
    end
  end

  currency_prices = SKIP unless hash.key?('currency_prices')

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  ProductPricePoint.new(id: id,
                        name: name,
                        handle: handle,
                        price_in_cents: price_in_cents,
                        interval: interval,
                        interval_unit: interval_unit,
                        trial_price_in_cents: trial_price_in_cents,
                        trial_interval: trial_interval,
                        trial_interval_unit: trial_interval_unit,
                        trial_type: trial_type,
                        introductory_offer: introductory_offer,
                        initial_charge_in_cents: initial_charge_in_cents,
                        initial_charge_after_trial: initial_charge_after_trial,
                        expiration_interval: expiration_interval,
                        expiration_interval_unit: expiration_interval_unit,
                        product_id: product_id,
                        archived_at: archived_at,
                        created_at: created_at,
                        updated_at: updated_at,
                        use_site_exchange_rate: use_site_exchange_rate,
                        type: type,
                        tax_included: tax_included,
                        subscription_id: subscription_id,
                        currency_prices: currency_prices,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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
# File 'lib/advanced_billing/models/product_price_point.rb', line 129

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['name'] = 'name'
  @_hash['handle'] = 'handle'
  @_hash['price_in_cents'] = 'price_in_cents'
  @_hash['interval'] = 'interval'
  @_hash['interval_unit'] = 'interval_unit'
  @_hash['trial_price_in_cents'] = 'trial_price_in_cents'
  @_hash['trial_interval'] = 'trial_interval'
  @_hash['trial_interval_unit'] = 'trial_interval_unit'
  @_hash['trial_type'] = 'trial_type'
  @_hash['introductory_offer'] = 'introductory_offer'
  @_hash['initial_charge_in_cents'] = 'initial_charge_in_cents'
  @_hash['initial_charge_after_trial'] = 'initial_charge_after_trial'
  @_hash['expiration_interval'] = 'expiration_interval'
  @_hash['expiration_interval_unit'] = 'expiration_interval_unit'
  @_hash['product_id'] = 'product_id'
  @_hash['archived_at'] = 'archived_at'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash['use_site_exchange_rate'] = 'use_site_exchange_rate'
  @_hash['type'] = 'type'
  @_hash['tax_included'] = 'tax_included'
  @_hash['subscription_id'] = 'subscription_id'
  @_hash['currency_prices'] = 'currency_prices'
  @_hash
end

.nullablesObject

An array for nullable fields



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/advanced_billing/models/product_price_point.rb', line 189

def self.nullables
  %w[
    handle
    trial_price_in_cents
    trial_interval
    trial_interval_unit
    trial_type
    introductory_offer
    initial_charge_in_cents
    initial_charge_after_trial
    expiration_interval
    expiration_interval_unit
    archived_at
    subscription_id
  ]
end

.optionalsObject

An array for optional fields



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
# File 'lib/advanced_billing/models/product_price_point.rb', line 159

def self.optionals
  %w[
    id
    name
    handle
    price_in_cents
    interval
    interval_unit
    trial_price_in_cents
    trial_interval
    trial_interval_unit
    trial_type
    introductory_offer
    initial_charge_in_cents
    initial_charge_after_trial
    expiration_interval
    expiration_interval_unit
    product_id
    archived_at
    created_at
    updated_at
    use_site_exchange_rate
    type
    tax_included
    subscription_id
    currency_prices
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/advanced_billing/models/product_price_point.rb', line 374

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}, handle: #{@handle.inspect},"\
  " price_in_cents: #{@price_in_cents.inspect}, interval: #{@interval.inspect}, interval_unit:"\
  " #{@interval_unit.inspect}, trial_price_in_cents: #{@trial_price_in_cents.inspect},"\
  " trial_interval: #{@trial_interval.inspect}, trial_interval_unit:"\
  " #{@trial_interval_unit.inspect}, trial_type: #{@trial_type.inspect}, introductory_offer:"\
  " #{@introductory_offer.inspect}, initial_charge_in_cents:"\
  " #{@initial_charge_in_cents.inspect}, initial_charge_after_trial:"\
  " #{@initial_charge_after_trial.inspect}, expiration_interval:"\
  " #{@expiration_interval.inspect}, expiration_interval_unit:"\
  " #{@expiration_interval_unit.inspect}, product_id: #{@product_id.inspect}, archived_at:"\
  " #{@archived_at.inspect}, created_at: #{@created_at.inspect}, updated_at:"\
  " #{@updated_at.inspect}, use_site_exchange_rate: #{@use_site_exchange_rate.inspect}, type:"\
  " #{@type.inspect}, tax_included: #{@tax_included.inspect}, subscription_id:"\
  " #{@subscription_id.inspect}, currency_prices: #{@currency_prices.inspect},"\
  " additional_properties: #{get_additional_properties}>"
end

#to_custom_archived_atObject



344
345
346
# File 'lib/advanced_billing/models/product_price_point.rb', line 344

def to_custom_archived_at
  DateTimeHelper.to_rfc3339(archived_at)
end

#to_custom_created_atObject



348
349
350
# File 'lib/advanced_billing/models/product_price_point.rb', line 348

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_updated_atObject



352
353
354
# File 'lib/advanced_billing/models/product_price_point.rb', line 352

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/advanced_billing/models/product_price_point.rb', line 357

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, name: #{@name}, handle: #{@handle}, price_in_cents:"\
  " #{@price_in_cents}, interval: #{@interval}, interval_unit: #{@interval_unit},"\
  " trial_price_in_cents: #{@trial_price_in_cents}, trial_interval: #{@trial_interval},"\
  " trial_interval_unit: #{@trial_interval_unit}, trial_type: #{@trial_type},"\
  " introductory_offer: #{@introductory_offer}, initial_charge_in_cents:"\
  " #{@initial_charge_in_cents}, initial_charge_after_trial: #{@initial_charge_after_trial},"\
  " expiration_interval: #{@expiration_interval}, expiration_interval_unit:"\
  " #{@expiration_interval_unit}, product_id: #{@product_id}, archived_at: #{@archived_at},"\
  " created_at: #{@created_at}, updated_at: #{@updated_at}, use_site_exchange_rate:"\
  " #{@use_site_exchange_rate}, type: #{@type}, tax_included: #{@tax_included},"\
  " subscription_id: #{@subscription_id}, currency_prices: #{@currency_prices},"\
  " additional_properties: #{get_additional_properties}>"
end