Class: Orb::Models::Coupon

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/orb/models/coupon.rb

Overview

Defined Under Namespace

Modules: Discount

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, fields, hash, #hash, inherited, inspect, #inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

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

Methods included from Internal::Util::SorbetRuntimeSupport

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

Constructor Details

#initialize(id: , archived_at: , discount: , duration_in_months: , max_redemptions: , redemption_code: , times_redeemed: ) ⇒ Object

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

A coupon represents a reusable discount configuration that can be applied either as a fixed or percentage amount to an invoice or subscription. Coupons are activated using a redemption code, which applies the discount to a subscription or invoice. The duration of a coupon determines how long it remains available for use by end users.

Parameters:

  • id (String) (defaults to: )

    Also referred to as coupon_id in this documentation.

  • archived_at (Time, nil) (defaults to: )

    An archived coupon can no longer be redeemed. Active coupons will have a value o

  • discount (Orb::Models::PercentageDiscount, Orb::Models::AmountDiscount) (defaults to: )
  • duration_in_months (Integer, nil) (defaults to: )

    This allows for a coupon’s discount to apply for a limited time (determined in m

  • max_redemptions (Integer, nil) (defaults to: )

    The maximum number of redemptions allowed for this coupon before it is exhausted

  • redemption_code (String) (defaults to: )

    This string can be used to redeem this coupon for a given subscription.

  • times_redeemed (Integer) (defaults to: )

    The number of times this coupon has been redeemed.



# File 'lib/orb/models/coupon.rb', line 51

Instance Attribute Details

#archived_atTime?

An archived coupon can no longer be redeemed. Active coupons will have a value of null for ‘archived_at`; this field will be non-null for archived coupons.

Returns:

  • (Time, nil)


18
# File 'lib/orb/models/coupon.rb', line 18

required :archived_at, Time, nil?: true

#discountOrb::Models::PercentageDiscount, Orb::Models::AmountDiscount



23
# File 'lib/orb/models/coupon.rb', line 23

required :discount, union: -> { Orb::Coupon::Discount }

#duration_in_monthsInteger?

This allows for a coupon’s discount to apply for a limited time (determined in months); a ‘null` value here means “unlimited time”.

Returns:

  • (Integer, nil)


30
# File 'lib/orb/models/coupon.rb', line 30

required :duration_in_months, Integer, nil?: true

#idString

Also referred to as coupon_id in this documentation.

Returns:

  • (String)


11
# File 'lib/orb/models/coupon.rb', line 11

required :id, String

#max_redemptionsInteger?

The maximum number of redemptions allowed for this coupon before it is exhausted; ‘null` here means “unlimited”.

Returns:

  • (Integer, nil)


37
# File 'lib/orb/models/coupon.rb', line 37

required :max_redemptions, Integer, nil?: true

#redemption_codeString

This string can be used to redeem this coupon for a given subscription.

Returns:

  • (String)


43
# File 'lib/orb/models/coupon.rb', line 43

required :redemption_code, String

#times_redeemedInteger

The number of times this coupon has been redeemed.

Returns:

  • (Integer)


49
# File 'lib/orb/models/coupon.rb', line 49

required :times_redeemed, Integer