Class: Dodopayments::Models::DiscountCreateParams
- Inherits:
-
Internal::Type::BaseModel
- Object
- Internal::Type::BaseModel
- Dodopayments::Models::DiscountCreateParams
- 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
Defined Under Namespace
Modules: CustomerEligibility Classes: CurrencyOption
Constant Summary
Constants included from Internal::Type::RequestParameters
Internal::Type::RequestParameters::Dodopayments
Instance Attribute Summary collapse
-
#amount ⇒ Integer
The discount amount in basis points (e.g.
540means5.4%,10000means100%). -
#code ⇒ String?
Optionally supply a code (will be uppercased).
-
#currency_options ⇒ Array<Dodopayments::Models::DiscountCreateParams::CurrencyOption>?
Per-currency options (flat deduction / percentage cap + minimum subtotal).
-
#customer_eligibility ⇒ Symbol, ...
Who may redeem this discount code.
-
#expires_at ⇒ Time?
When the discount expires, if ever.
-
#metadata ⇒ Hash{Symbol=>String, Float, Boolean}?
Additional metadata for the discount.
- #name ⇒ String?
-
#per_customer_usage_limit ⇒ Integer?
Maximum number of times a single customer may redeem this discount.
-
#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 restrict usage (if any).
-
#starts_at ⇒ Time?
When the discount becomes active, if scheduled for the future.
-
#subscription_cycles ⇒ Integer?
Number of subscription billing cycles this discount is valid for.
-
#type ⇒ Symbol, Dodopayments::Models::DiscountType
The discount type:
percentageorflat(flat_per_unitstays blocked). -
#usage_limit ⇒ Integer?
How many times this discount can be used (if any).
Attributes included from Internal::Type::RequestParameters
Instance Method Summary collapse
-
#initialize(currency:, is_default: nil, max_amount_possible: nil, minimum_subtotal: nil) ⇒ Object
constructor
Some parameter documentations has been truncated, see CurrencyOption for more details.
- #to_hash ⇒ {
Methods included from Internal::Type::RequestParameters::Converter
Methods included from Internal::Type::RequestParameters
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.
|
|
# File 'lib/dodopayments/models/discount_create_params.rb', line 177
|
Instance Attribute Details
#amount ⇒ Integer
The discount amount in basis points (e.g. 540 means 5.4%, 10000 means
100%).
Must be at least 1.
17 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 17 required :amount, Integer |
#code ⇒ String?
Optionally supply a code (will be uppercased).
- Must be at least 3 characters if provided.
- If omitted, a random 16-character code is generated.
32 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 32 optional :code, String, nil?: true |
#currency_options ⇒ Array<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)].
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_eligibility ⇒ Symbol, ...
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.
53 54 55 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 53 optional :customer_eligibility, enum: -> { Dodopayments::DiscountCreateParams::CustomerEligibility }, nil?: true |
#expires_at ⇒ Time?
When the discount expires, if ever.
61 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 61 optional :expires_at, Time, nil?: true |
#metadata ⇒ Hash{Symbol=>String, Float, Boolean}?
Additional metadata for the discount
67 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 67 optional :metadata, -> { Dodopayments::Internal::Type::HashOf[union: Dodopayments::MetadataItem] } |
#name ⇒ String?
72 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 72 optional :name, String, nil?: true |
#per_customer_usage_limit ⇒ Integer?
Maximum number of times a single customer may redeem this discount. Must be
<= usage_limit when both are set.
79 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 79 optional :per_customer_usage_limit, Integer, nil?: true |
#preserve_on_plan_change ⇒ Boolean?
Whether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change)
86 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 86 optional :preserve_on_plan_change, Dodopayments::Internal::Type::Boolean |
#restricted_to ⇒ Array<String>?
List of product IDs to restrict usage (if any).
92 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 92 optional :restricted_to, Dodopayments::Internal::Type::ArrayOf[String], nil?: true |
#starts_at ⇒ Time?
When the discount becomes active, if scheduled for the future. NULL = active
immediately. Must be strictly before expires_at when both are set.
99 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 99 optional :starts_at, Time, nil?: true |
#subscription_cycles ⇒ Integer?
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.
107 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 107 optional :subscription_cycles, Integer, nil?: true |
#type ⇒ Symbol, Dodopayments::Models::DiscountType
The discount type: percentage or flat (flat_per_unit stays blocked).
23 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 23 required :type, enum: -> { Dodopayments::DiscountType } |
#usage_limit ⇒ Integer?
How many times this discount can be used (if any). Must be >= 1 if provided.
113 |
# File 'lib/dodopayments/models/discount_create_params.rb', line 113 optional :usage_limit, Integer, nil?: true |
Instance Method Details
#to_hash ⇒ {
78 |
# File 'sig/dodopayments/models/discount_create_params.rbs', line 78
def to_hash: -> {
|