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

Overview

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(amount: , type: , code: nil, expires_at: nil, name: nil, restricted_to: 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) (defaults to: )

    The discount amount.

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

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

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

    Optionally supply a code (will be uppercased).

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

    When the discount expires, if ever.

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

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

  • 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: {})


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

Instance Attribute Details

#amountInteger

The discount amount.

  • If ‘discount_type` is not `percentage`, `amount` is in **USD cents**. For example, `100` means `$1.00`. Only USD is allowed.

  • If ‘discount_type` is `percentage`, `amount` is in **basis points**. For example, `540` means `5.4%`.

Must be at least 1.

Returns:

  • (Integer)


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

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.

Returns:

  • (String, nil)


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

optional :code, String, nil?: true

#expires_atTime?

When the discount expires, if ever.

Returns:

  • (Time, nil)


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

optional :expires_at, Time, nil?: true

#nameString?

Returns:

  • (String, nil)


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

optional :name, String, nil?: true

#restricted_toArray<String>?

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

Returns:

  • (Array<String>, nil)


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

optional :restricted_to, Dodopayments::Internal::Type::ArrayOf[String], 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.

Returns:

  • (Integer, nil)


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

optional :subscription_cycles, Integer, nil?: true

#typeSymbol, Dodopayments::Models::DiscountType

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



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

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

#usage_limitInteger?

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

Returns:

  • (Integer, nil)


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

optional :usage_limit, Integer, nil?: true