Class: Dodopayments::Models::Discount

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/dodopayments/models/discount.rb

Overview

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(amount:, business_id:, code:, created_at:, discount_id:, metadata:, preserve_on_plan_change:, restricted_to:, times_used:, type:, expires_at: nil, name: nil, subscription_cycles: nil, usage_limit: nil) ⇒ Object

Some parameter documentations has been truncated, see Dodopayments::Models::Discount for more details.

Parameters:

  • amount (Integer)

    The discount amount in **basis points** (e.g., 540 => 5.4%).

  • business_id (String)

    The business this discount belongs to.

  • code (String)

    The discount code (up to 16 chars).

  • created_at (Time)

    Timestamp when the discount is created

  • discount_id (String)

    The unique discount ID

  • metadata (Hash{Symbol=>String})
  • preserve_on_plan_change (Boolean)

    Whether this discount should be preserved when a subscription changes plans.

  • restricted_to (Array<String>)

    List of product IDs to which this discount is restricted.

  • times_used (Integer)

    How many times this discount has been used.

  • type (Symbol, Dodopayments::Models::DiscountType)

    The type of discount. Currently only ‘percentage` is supported.

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

    Optional date/time after which discount is expired.

  • name (String, nil) (defaults to: nil)

    Name for the Discount

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

    Number of subscription billing cycles this discount is valid for.

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

    Usage limit for this discount, if any.



# File 'lib/dodopayments/models/discount.rb', line 93

Instance Attribute Details

#amountInteger

The discount amount in **basis points** (e.g., 540 => 5.4%).

Returns:

  • (Integer)


11
# File 'lib/dodopayments/models/discount.rb', line 11

required :amount, Integer

#business_idString

The business this discount belongs to.

Returns:

  • (String)


17
# File 'lib/dodopayments/models/discount.rb', line 17

required :business_id, String

#codeString

The discount code (up to 16 chars).

Returns:

  • (String)


23
# File 'lib/dodopayments/models/discount.rb', line 23

required :code, String

#created_atTime

Timestamp when the discount is created

Returns:

  • (Time)


29
# File 'lib/dodopayments/models/discount.rb', line 29

required :created_at, Time

#discount_idString

The unique discount ID

Returns:

  • (String)


35
# File 'lib/dodopayments/models/discount.rb', line 35

required :discount_id, String

#expires_atTime?

Optional date/time after which discount is expired.

Returns:

  • (Time, nil)


71
# File 'lib/dodopayments/models/discount.rb', line 71

optional :expires_at, Time, nil?: true

#metadataHash{Symbol=>String}

Returns:

  • (Hash{Symbol=>String})


40
# File 'lib/dodopayments/models/discount.rb', line 40

required :metadata, Dodopayments::Internal::Type::HashOf[String]

#nameString?

Name for the Discount

Returns:

  • (String, nil)


77
# File 'lib/dodopayments/models/discount.rb', line 77

optional :name, String, nil?: true

#preserve_on_plan_changeBoolean

Whether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change)

Returns:

  • (Boolean)


47
# File 'lib/dodopayments/models/discount.rb', line 47

required :preserve_on_plan_change, Dodopayments::Internal::Type::Boolean

#restricted_toArray<String>

List of product IDs to which this discount is restricted.

Returns:

  • (Array<String>)


53
# File 'lib/dodopayments/models/discount.rb', line 53

required :restricted_to, Dodopayments::Internal::Type::ArrayOf[String]

#subscription_cyclesInteger?

Number of subscription billing cycles this discount is valid for. If not provided, the discount will be applied indefinitely to all recurring payments related to the subscription.

Returns:

  • (Integer, nil)


85
# File 'lib/dodopayments/models/discount.rb', line 85

optional :subscription_cycles, Integer, nil?: true

#times_usedInteger

How many times this discount has been used.

Returns:

  • (Integer)


59
# File 'lib/dodopayments/models/discount.rb', line 59

required :times_used, Integer

#typeSymbol, Dodopayments::Models::DiscountType

The type of discount. Currently only ‘percentage` is supported.



65
# File 'lib/dodopayments/models/discount.rb', line 65

required :type, enum: -> { Dodopayments::DiscountType }

#usage_limitInteger?

Usage limit for this discount, if any.

Returns:

  • (Integer, nil)


91
# File 'lib/dodopayments/models/discount.rb', line 91

optional :usage_limit, Integer, nil?: true