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, metadata: nil, name: nil, preserve_on_plan_change: 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)

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

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

    The discount type. Currently only ‘percentage` is supported.

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

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

    Additional metadata for the discount

  • name (String, nil) (defaults to: nil)
  • 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).

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

Instance Attribute Details

#amountInteger

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

Must be at least 1.

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.

Returns:

  • (String, nil)


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

optional :code, String, nil?: true

#expires_atTime?

When the discount expires, if ever.

Returns:

  • (Time, nil)


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

optional :expires_at, Time, nil?: true

#metadataHash{Symbol=>String}?

Additional metadata for the discount

Returns:

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


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

optional :metadata, Dodopayments::Internal::Type::HashOf[String]

#nameString?

Returns:

  • (String, nil)


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

optional :name, String, 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)

Returns:

  • (Boolean, nil)


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

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

#restricted_toArray<String>?

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

Returns:

  • (Array<String>, nil)


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

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)


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

optional :subscription_cycles, Integer, nil?: true

#typeSymbol, Dodopayments::Models::DiscountType

The discount type. Currently only ‘percentage` is supported.



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.

Returns:

  • (Integer, nil)


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

optional :usage_limit, Integer, nil?: true