Class: Dodopayments::Models::DiscountCreateParams::CurrencyOption

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/dodopayments/models/discount_create_params.rb,
sig/dodopayments/models/discount_create_params.rbs

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:, type:, code: nil, currency_options: nil, customer_eligibility: nil, expires_at: nil, metadata: nil, name: nil, per_customer_usage_limit: nil, preserve_on_plan_change: nil, restricted_to: nil, starts_at: nil, subscription_cycles: nil, usage_limit: nil, request_options: {}) ⇒ Object

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

Parameters:

  • amount (Integer)

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

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

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

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

    Optionally supply a code (will be uppercased).

  • currency_options (Array<Dodopayments::Models::DiscountCreateParams::CurrencyOption>, nil) (defaults to: nil)

    Per-currency options (flat deduction / percentage cap + minimum subtotal).

  • customer_eligibility (Symbol, Dodopayments::Models::DiscountCreateParams::CustomerEligibility, nil) (defaults to: nil)

    Who may redeem this discount code. Defaults to any (unrestricted).

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

    When the discount expires, if ever.

  • metadata (Hash{Symbol=>String, Float, Boolean}) (defaults to: nil)

    Additional metadata for the discount

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

    Maximum number of times a single customer may redeem this discount.

  • preserve_on_plan_change (Boolean) (defaults to: nil)

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

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

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

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

    When the discount becomes active, if scheduled for the future.

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

    Number of subscription billing cycles this discount is valid for.

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

    How many times this discount can be used (if any).

  • request_options (Dodopayments::RequestOptions, Hash{Symbol=>Object}) (defaults to: {})


149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/dodopayments/models/discount_create_params.rb', line 149

class CurrencyOption < Dodopayments::Internal::Type::BaseModel
  # @!attribute currency
  #   The currency this option applies to.
  #
  #   @return [Symbol, Dodopayments::Models::Currency]
  required :currency, enum: -> { Dodopayments::Currency }

  # @!attribute is_default
  #   Whether this row is the default to convert from for unconfigured currencies. At
  #   most one row per discount may be default.
  #
  #   @return [Boolean, nil]
  optional :is_default, Dodopayments::Internal::Type::Boolean

  # @!attribute max_amount_possible
  #   The most this code discounts in this currency's subunits. For `flat` codes this
  #   is the deduction; for `percentage` codes it is the max-discount cap. Must be > 0
  #   if provided.
  #
  #   @return [Integer, nil]
  optional :max_amount_possible, Integer, nil?: true

  # @!attribute minimum_subtotal
  #   Eligible-cart threshold in this currency's subunits (0 = no minimum).
  #
  #   @return [Integer, nil]
  optional :minimum_subtotal, Integer

  # @!method initialize(currency:, is_default: nil, max_amount_possible: nil, minimum_subtotal: nil)
  #   Some parameter documentations has been truncated, see
  #   {Dodopayments::Models::DiscountCreateParams::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.
  #
  #   @param currency [Symbol, Dodopayments::Models::Currency] The currency this option applies to.
  #
  #   @param is_default [Boolean] Whether this row is the default to convert from for unconfigured
  #
  #   @param max_amount_possible [Integer, nil] The most this code discounts in this currency's subunits. For `flat` codes
  #
  #   @param minimum_subtotal [Integer] Eligible-cart threshold in this currency's subunits (0 = no minimum).
end

Instance Attribute Details

#currencySymbol, Dodopayments::Models::Currency

The currency this option applies to.

Parameters:

  • value (Dodopayments::Models::currency)

Returns:



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

required :currency, enum: -> { Dodopayments::Currency }

#is_defaultBoolean?

Whether this row is the default to convert from for unconfigured currencies. At most one row per discount may be default.

Parameters:

  • (Boolean)

Returns:

  • (Boolean, nil)


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

optional :is_default, Dodopayments::Internal::Type::Boolean

#max_amount_possibleInteger?

The most this code discounts in this currency's subunits. For flat codes this is the deduction; for percentage codes it is the max-discount cap. Must be > 0 if provided.

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


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

optional :max_amount_possible, Integer, nil?: true

#minimum_subtotalInteger?

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

Parameters:

  • (Integer)

Returns:

  • (Integer, nil)


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

optional :minimum_subtotal, Integer

Instance Method Details

#to_hash{

Returns:

  • ({)


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

def to_hash: -> {