Module: Orb::Models::Subscription::DiscountInterval

Extended by:
Internal::Type::Union
Defined in:
lib/orb/models/subscription.rb,
sig/orb/models/subscription.rbs

Defined Under Namespace

Classes: TieredPercentage

Instance Method Summary collapse

Methods included from Internal::Type::Union

==, ===, coerce, derefed_variants, dump, hash, inspect, to_sorbet_type, variants, variants

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, #inspect, inspect, meta_info, new_coerce_state, type_info

Instance Method Details

#initialize(id:, active_plan_phase_order:, adjustment_intervals:, auto_collection:, auto_issuance:, billing_cycle_anchor_configuration:, billing_cycle_day:, created_at:, current_billing_period_end_date:, current_billing_period_start_date:, customer:, default_invoice_memo:, discount_intervals:, end_date:, fixed_fee_quantity_schedule:, invoicing_threshold:, maximum_intervals:, metadata:, minimum_intervals:, name:, net_terms:, pending_subscription_change:, plan:, price_intervals:, redeemed_coupon:, start_date:, status:, trial_info:) ⇒ Object

Some parameter documentations has been truncated, see Orb::Models::Subscription for more details.

A subscription represents the purchase of a plan by a customer.

By default, subscriptions begin on the day that they're created and renew automatically for each billing cycle at the cadence that's configured in the plan definition.

Subscriptions also default to beginning of month alignment, which means the first invoice issued for the subscription will have pro-rated charges between the start_date and the first of the following month. Subsequent billing periods will always start and end on a month boundary (e.g. subsequent month starts for monthly billing).

Depending on the plan configuration, any flat recurring fees will be billed either at the beginning (in-advance) or end (in-arrears) of each billing cycle. Plans default to in-advance billing. Usage-based fees are billed in arrears as usage is accumulated. In the normal course of events, you can expect an invoice to contain usage-based charges for the previous period, and a recurring fee for the following period.

Parameters:

  • id (String)
  • active_plan_phase_order (Integer, nil)

    The current plan phase that is active, only if the subscription's plan has phase

  • adjustment_intervals (Array<Orb::Models::AdjustmentInterval>)

    The adjustment intervals for this subscription sorted by the start_date of the a

  • auto_collection (Boolean, nil)

    Determines whether issued invoices for this subscription will automatically be c

  • auto_issuance (Boolean, nil)

    Determines whether invoices for this subscription will be automatically issued.

  • billing_cycle_anchor_configuration (Orb::Models::BillingCycleAnchorConfiguration)
  • billing_cycle_day (Integer)

    The day of the month on which the billing cycle is anchored. If the maximum numb

  • created_at (Time)
  • current_billing_period_end_date (Time, nil)

    The end of the current billing period. This is an exclusive timestamp, such that

  • current_billing_period_start_date (Time, nil)

    The start date of the current billing period. This is an inclusive timestamp; th

  • customer (Orb::Models::Customer)

    A customer is a buyer of your products, and the other party to the billing relat

  • default_invoice_memo (String, nil)

    Determines the default memo on this subscriptions' invoices. Note that if this i

  • discount_intervals (Array<Orb::Models::AmountDiscountInterval, Orb::Models::PercentageDiscountInterval, Orb::Models::UsageDiscountInterval, Orb::Models::Subscription::DiscountInterval::TieredPercentage>)

    The discount intervals for this subscription sorted by the start_date. This fiel

  • end_date (Time, nil)

    The date Orb stops billing for this subscription.

  • fixed_fee_quantity_schedule (Array<Orb::Models::FixedFeeQuantityScheduleEntry>)
  • invoicing_threshold (String, nil)
  • maximum_intervals (Array<Orb::Models::MaximumInterval>)

    The maximum intervals for this subscription sorted by the start_date. This field

  • metadata (Hash{Symbol=>String})

    User specified key-value pairs for the resource. If not present, this defaults t

  • minimum_intervals (Array<Orb::Models::MinimumInterval>)

    The minimum intervals for this subscription sorted by the start_date. This field

  • name (String)

    The name of the subscription.

  • net_terms (Integer)

    Determines the difference between the invoice issue date for subscription invoic

  • pending_subscription_change (Orb::Models::SubscriptionChangeMinified, nil)

    A pending subscription change if one exists on this subscription.

  • plan (Orb::Models::Plan, nil)

    The Plan resource represents a plan that can be

  • price_intervals (Array<Orb::Models::PriceInterval>)

    The price intervals for this subscription.

  • redeemed_coupon (Orb::Models::CouponRedemption, nil)
  • start_date (Time)

    The date Orb starts billing for this subscription.

  • status (Symbol, Orb::Models::Subscription::Status)
  • trial_info (Orb::Models::SubscriptionTrialInfo)


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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'lib/orb/models/subscription.rb', line 299

module DiscountInterval
  extend Orb::Internal::Type::Union

  discriminator :discount_type

  variant :amount, -> { Orb::AmountDiscountInterval }

  variant :percentage, -> { Orb::PercentageDiscountInterval }

  variant :usage, -> { Orb::UsageDiscountInterval }

  variant :tiered_percentage, -> { Orb::Subscription::DiscountInterval::TieredPercentage }

  class TieredPercentage < Orb::Internal::Type::BaseModel
    # @!attribute applies_to_price_interval_ids
    #   The price interval ids that this discount interval applies to.
    #
    #   @return [Array<String>]
    required :applies_to_price_interval_ids, Orb::Internal::Type::ArrayOf[String]

    # @!attribute discount_type
    #
    #   @return [Symbol, :tiered_percentage]
    required :discount_type, const: :tiered_percentage

    # @!attribute end_date
    #   The end date of the discount interval.
    #
    #   @return [Time, nil]
    required :end_date, Time, nil?: true

    # @!attribute filters
    #   The filters that determine which prices this discount interval applies to.
    #
    #   @return [Array<Orb::Models::Subscription::DiscountInterval::TieredPercentage::Filter>]
    required :filters,
             -> { Orb::Internal::Type::ArrayOf[Orb::Subscription::DiscountInterval::TieredPercentage::Filter] }

    # @!attribute start_date
    #   The start date of the discount interval.
    #
    #   @return [Time]
    required :start_date, Time

    # @!attribute tiers
    #   Only available if discount_type is `tiered_percentage`. The ordered, contiguous
    #   bands of cumulative eligible spend, each discounted at its own percentage.
    #
    #   @return [Array<Orb::Models::Subscription::DiscountInterval::TieredPercentage::Tier>]
    required :tiers,
             -> { Orb::Internal::Type::ArrayOf[Orb::Subscription::DiscountInterval::TieredPercentage::Tier] }

    # @!method initialize(applies_to_price_interval_ids:, end_date:, filters:, start_date:, tiers:, discount_type: :tiered_percentage)
    #   Some parameter documentations has been truncated, see
    #   {Orb::Models::Subscription::DiscountInterval::TieredPercentage} for more
    #   details.
    #
    #   @param applies_to_price_interval_ids [Array<String>] The price interval ids that this discount interval applies to.
    #
    #   @param end_date [Time, nil] The end date of the discount interval.
    #
    #   @param filters [Array<Orb::Models::Subscription::DiscountInterval::TieredPercentage::Filter>] The filters that determine which prices this discount interval applies to.
    #
    #   @param start_date [Time] The start date of the discount interval.
    #
    #   @param tiers [Array<Orb::Models::Subscription::DiscountInterval::TieredPercentage::Tier>] Only available if discount_type is `tiered_percentage`. The ordered, contiguous
    #
    #   @param discount_type [Symbol, :tiered_percentage]

    class Filter < Orb::Internal::Type::BaseModel
      # @!attribute field
      #   The property of the price to filter on.
      #
      #   @return [Symbol, Orb::Models::Subscription::DiscountInterval::TieredPercentage::Filter::Field]
      required :field, enum: -> { Orb::Subscription::DiscountInterval::TieredPercentage::Filter::Field }

      # @!attribute operator
      #   Should prices that match the filter be included or excluded.
      #
      #   @return [Symbol, Orb::Models::Subscription::DiscountInterval::TieredPercentage::Filter::Operator]
      required :operator, enum: -> { Orb::Subscription::DiscountInterval::TieredPercentage::Filter::Operator }

      # @!attribute values
      #   The IDs or values that match this filter.
      #
      #   @return [Array<String>]
      required :values, Orb::Internal::Type::ArrayOf[String]

      # @!method initialize(field:, operator:, values:)
      #   @param field [Symbol, Orb::Models::Subscription::DiscountInterval::TieredPercentage::Filter::Field] The property of the price to filter on.
      #
      #   @param operator [Symbol, Orb::Models::Subscription::DiscountInterval::TieredPercentage::Filter::Operator] Should prices that match the filter be included or excluded.
      #
      #   @param values [Array<String>] The IDs or values that match this filter.

      # The property of the price to filter on.
      #
      # @see Orb::Models::Subscription::DiscountInterval::TieredPercentage::Filter#field
      module Field
        extend Orb::Internal::Type::Enum

        PRICE_ID = :price_id
        ITEM_ID = :item_id
        PRICE_TYPE = :price_type
        CURRENCY = :currency
        PRICING_UNIT_ID = :pricing_unit_id

        # @!method self.values
        #   @return [Array<Symbol>]
      end

      # Should prices that match the filter be included or excluded.
      #
      # @see Orb::Models::Subscription::DiscountInterval::TieredPercentage::Filter#operator
      module Operator
        extend Orb::Internal::Type::Enum

        INCLUDES = :includes
        EXCLUDES = :excludes

        # @!method self.values
        #   @return [Array<Symbol>]
      end
    end

    class Tier < Orb::Internal::Type::BaseModel
      # @!attribute lower_bound
      #   Exclusive lower bound of cumulative spend for this tier.
      #
      #   @return [Float]
      required :lower_bound, Float

      # @!attribute percentage
      #   The percentage (between 0 and 1) discounted from spend that falls within this
      #   tier.
      #
      #   @return [Float]
      required :percentage, Float

      # @!attribute upper_bound
      #   Inclusive upper bound of cumulative spend for this tier; null for the final
      #   open-ended tier.
      #
      #   @return [Float, nil]
      optional :upper_bound, Float, nil?: true

      # @!method initialize(lower_bound:, percentage:, upper_bound: nil)
      #   Some parameter documentations has been truncated, see
      #   {Orb::Models::Subscription::DiscountInterval::TieredPercentage::Tier} for more
      #   details.
      #
      #   One band of a tiered percentage discount. Bounds are denominated in the
      #   discount's currency. `lower_bound` is the exclusive start of the band and
      #   `upper_bound` is the inclusive end; `upper_bound` is null only for the
      #   open-ended final tier.
      #
      #   @param lower_bound [Float] Exclusive lower bound of cumulative spend for this tier.
      #
      #   @param percentage [Float] The percentage (between 0 and 1) discounted from spend that falls within this ti
      #
      #   @param upper_bound [Float, nil] Inclusive upper bound of cumulative spend for this tier; null for the final open
    end
  end

  # @!method self.variants
  #   @return [Array(Orb::Models::AmountDiscountInterval, Orb::Models::PercentageDiscountInterval, Orb::Models::UsageDiscountInterval, Orb::Models::Subscription::DiscountInterval::TieredPercentage)]
end

#self?.variants::Array[Orb::Models::Subscription::discount_interval]

Returns:

  • (::Array[Orb::Models::Subscription::discount_interval])


281
# File 'sig/orb/models/subscription.rbs', line 281

def self?.variants: -> ::Array[Orb::Models::Subscription::discount_interval]