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, #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.



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

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)


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

def archived_at
  @archived_at
end

#created_atDateTime

Timestamp indicating when this price point was created

Returns:

  • (DateTime)


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

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:



122
123
124
# File 'lib/advanced_billing/models/product_price_point.rb', line 122

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)


76
77
78
# File 'lib/advanced_billing/models/product_price_point.rb', line 76

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



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

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)


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

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)


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

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)


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

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)


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

def product_id
  @product_id
end

#subscription_idInteger

The subscription id this price point belongs to

Returns:

  • (Integer)


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

def subscription_id
  @subscription_id
end

#tax_includedTrueClass | FalseClass

Whether or not the price point includes tax

Returns:

  • (TrueClass | FalseClass)


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

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_typeString

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

Returns:

  • (String)


58
59
60
# File 'lib/advanced_billing/models/product_price_point.rb', line 58

def trial_type
  @trial_type
end

#typePricePointType

The type of price point

Returns:



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

def type
  @type
end

#updated_atDateTime

Timestamp indicating when this price point was last updated

Returns:

  • (DateTime)


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

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)


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

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.



247
248
249
250
251
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
# File 'lib/advanced_billing/models/product_price_point.rb', line 247

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.



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

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



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/advanced_billing/models/product_price_point.rb', line 185

def self.nullables
  %w[
    handle
    trial_price_in_cents
    trial_interval
    trial_interval_unit
    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



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

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

#to_custom_archived_atObject



339
340
341
# File 'lib/advanced_billing/models/product_price_point.rb', line 339

def to_custom_archived_at
  DateTimeHelper.to_rfc3339(archived_at)
end

#to_custom_created_atObject



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

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_updated_atObject



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

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end