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: , 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) (defaults to: )

    The discount amount.

  • business_id (String) (defaults to: )

    The business this discount belongs to.

  • code (String) (defaults to: )

    The discount code (up to 16 chars).

  • created_at (Time) (defaults to: )

    Timestamp when the discount is created

  • discount_id (String) (defaults to: )

    The unique discount ID

  • restricted_to (Array<String>) (defaults to: )

    List of product IDs to which this discount is restricted.

  • times_used (Integer) (defaults to: )

    How many times this discount has been used.

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

    The type of discount, e.g. ‘percentage`, `flat`, or `flat_per_unit`.

  • 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 85

Instance Attribute Details

#amountInteger

The discount amount.

  • If ‘discount_type` is `percentage`, this is in **basis points** (e.g., 540 => 5.4%).

  • Otherwise, this is **USD cents** (e.g., 100 => ‘$1.00`).

Returns:

  • (Integer)


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

required :amount, Integer

#business_idString

The business this discount belongs to.

Returns:

  • (String)


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

required :business_id, String

#codeString

The discount code (up to 16 chars).

Returns:

  • (String)


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

required :code, String

#created_atTime

Timestamp when the discount is created

Returns:

  • (Time)


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

required :created_at, Time

#discount_idString

The unique discount ID

Returns:

  • (String)


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

required :discount_id, String

#expires_atTime?

Optional date/time after which discount is expired.

Returns:

  • (Time, nil)


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

optional :expires_at, Time, nil?: true

#nameString?

Name for the Discount

Returns:

  • (String, nil)


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

optional :name, String, nil?: true

#restricted_toArray<String>

List of product IDs to which this discount is restricted.

Returns:

  • (Array<String>)


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

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)


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

optional :subscription_cycles, Integer, nil?: true

#times_usedInteger

How many times this discount has been used.

Returns:

  • (Integer)


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

required :times_used, Integer

#typeSymbol, Dodopayments::Models::DiscountType

The type of discount, e.g. ‘percentage`, `flat`, or `flat_per_unit`.



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

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

#usage_limitInteger?

Usage limit for this discount, if any.

Returns:

  • (Integer, nil)


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

optional :usage_limit, Integer, nil?: true