Class: Dodopayments::Models::DiscountCreateParams

Inherits:
Internal::Type::BaseModel show all
Extended by:
Internal::Type::RequestParameters::Converter
Includes:
Internal::Type::RequestParameters
Defined in:
lib/dodopayments/models/discount_create_params.rb,
sig/dodopayments/models/discount_create_params.rbs

Overview

See Also:

  • Dodopayments::Resources::Discounts#create

Defined Under Namespace

Modules: CustomerEligibility Classes: CurrencyOption

Constant Summary

Constants included from Internal::Type::RequestParameters

Internal::Type::RequestParameters::Dodopayments

Instance Attribute Summary collapse

Attributes included from Internal::Type::RequestParameters

#request_options

Instance Method Summary collapse

Methods included from Internal::Type::RequestParameters::Converter

dump_request

Methods included from Internal::Type::RequestParameters

included

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(currency:, is_default: nil, max_amount_possible: nil, minimum_subtotal: nil) ⇒ Object

Some parameter documentations has been truncated, see CurrencyOption for more details.

A per-currency discount option (request shape).

max_amount_possible is the most this code discounts in this currency — the flat deduction for flat codes, or the max-discount cap for percentage codes. Maps to the DB column of the same name.

Parameters:

  • currency (Symbol, Dodopayments::Models::Currency)

    The currency this option applies to.

  • is_default (Boolean) (defaults to: nil)

    Whether this row is the default to convert from for unconfigured

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

    The most this code discounts in this currency's subunits. For flat codes

  • minimum_subtotal (Integer) (defaults to: nil)

    Eligible-cart threshold in this currency's subunits (0 = no minimum).



# File 'lib/dodopayments/models/discount_create_params.rb', line 177

Instance Attribute Details

#amountInteger

The discount amount in basis points (e.g. 540 means 5.4%, 10000 means 100%).

Must be at least 1.

Parameters:

  • value (Integer)

Returns:

  • (Integer)


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

required :amount, Integer

#codeString?

Optionally supply a code (will be uppercased).

  • Must be at least 3 characters if provided.
  • If omitted, a random 16-character code is generated.

Parameters:

  • value (String, nil)

Returns:

  • (String, nil)


32
# File 'lib/dodopayments/models/discount_create_params.rb', line 32

optional :code, String, nil?: true

#currency_optionsArray<Dodopayments::Models::DiscountCreateParams::CurrencyOption>?

Per-currency options (flat deduction / percentage cap + minimum subtotal). Required for flat codes (must include a resolvable default); optional per-currency caps for percentage codes. Per-row invariants are checked in normalize_currency_options, not via #[validate(nested)].

Parameters:

  • value (::Array[Dodopayments::DiscountCreateParams::CurrencyOption], nil)

Returns:



41
42
43
44
45
# File 'lib/dodopayments/models/discount_create_params.rb', line 41

optional :currency_options,
-> {
  Dodopayments::Internal::Type::ArrayOf[Dodopayments::DiscountCreateParams::CurrencyOption]
},
nil?: true

#customer_eligibilitySymbol, ...

Who may redeem this discount code. Defaults to any (unrestricted). specific starts with zero attached customers (fails closed) until customers are attached via POST /discounts/{id}/customers.

Parameters:

  • value (Dodopayments::Models::DiscountCreateParams::customer_eligibility, nil)

Returns:



53
54
55
# File 'lib/dodopayments/models/discount_create_params.rb', line 53

optional :customer_eligibility,
enum: -> { Dodopayments::DiscountCreateParams::CustomerEligibility },
nil?: true

#expires_atTime?

When the discount expires, if ever.

Parameters:

  • value (Time, nil)

Returns:

  • (Time, nil)


61
# File 'lib/dodopayments/models/discount_create_params.rb', line 61

optional :expires_at, Time, nil?: true

#metadataHash{Symbol=>String, Float, Boolean}?

Additional metadata for the discount

Returns:

  • (Hash{Symbol=>String, Float, Boolean}, nil)


67
# File 'lib/dodopayments/models/discount_create_params.rb', line 67

optional :metadata, -> { Dodopayments::Internal::Type::HashOf[union: Dodopayments::MetadataItem] }

#nameString?

Parameters:

  • value (String, nil)

Returns:

  • (String, nil)


72
# File 'lib/dodopayments/models/discount_create_params.rb', line 72

optional :name, String, nil?: true

#per_customer_usage_limitInteger?

Maximum number of times a single customer may redeem this discount. Must be <= usage_limit when both are set.

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


79
# File 'lib/dodopayments/models/discount_create_params.rb', line 79

optional :per_customer_usage_limit, Integer, 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)

Parameters:

  • (Boolean)

Returns:

  • (Boolean, nil)


86
# File 'lib/dodopayments/models/discount_create_params.rb', line 86

optional :preserve_on_plan_change, Dodopayments::Internal::Type::Boolean

#restricted_toArray<String>?

List of product IDs to restrict usage (if any).

Parameters:

  • value (::Array[String], nil)

Returns:

  • (Array<String>, nil)


92
# File 'lib/dodopayments/models/discount_create_params.rb', line 92

optional :restricted_to, Dodopayments::Internal::Type::ArrayOf[String], nil?: true

#starts_atTime?

When the discount becomes active, if scheduled for the future. NULL = active immediately. Must be strictly before expires_at when both are set.

Parameters:

  • value (Time, nil)

Returns:

  • (Time, nil)


99
# File 'lib/dodopayments/models/discount_create_params.rb', line 99

optional :starts_at, Time, nil?: true

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

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


107
# File 'lib/dodopayments/models/discount_create_params.rb', line 107

optional :subscription_cycles, Integer, nil?: true

#typeSymbol, Dodopayments::Models::DiscountType

The discount type: percentage or flat (flat_per_unit stays blocked).

Parameters:

  • value (Dodopayments::Models::discount_type)

Returns:



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

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

#usage_limitInteger?

How many times this discount can be used (if any). Must be >= 1 if provided.

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


113
# File 'lib/dodopayments/models/discount_create_params.rb', line 113

optional :usage_limit, Integer, nil?: true

Instance Method Details

#to_hash{

Returns:

  • ({)


78
# File 'sig/dodopayments/models/discount_create_params.rbs', line 78

def to_hash: -> {