Class: Dodopayments::Models::DiscountUpdateParams

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

Overview

See Also:

  • Dodopayments::Resources::Discounts#update

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_update_params.rb', line 180

Instance Attribute Details

#amountInteger?

If present, update the discount amount in basis points (e.g., 540 = 5.4%, 10000 = 100%).

Must be at least 1 if provided.

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


22
# File 'lib/dodopayments/models/discount_update_params.rb', line 22

optional :amount, Integer, nil?: true

#codeString?

If present, update the discount code (uppercase).

Parameters:

  • value (String, nil)

Returns:

  • (String, nil)


28
# File 'lib/dodopayments/models/discount_update_params.rb', line 28

optional :code, String, nil?: true

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

If present, fully replaces the discount's currency options (replace-set semantics, like restricted_to). Send an empty array to clear them.

Parameters:

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

Returns:



35
36
37
38
39
# File 'lib/dodopayments/models/discount_update_params.rb', line 35

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

#customer_eligibilitySymbol, ...

If present, update who may redeem this discount. Plain field (not double-option): the DB column is NOT NULL, so it can never be cleared back to unset, only changed to another CustomerEligibility value.

Parameters:

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

Returns:



47
48
49
# File 'lib/dodopayments/models/discount_update_params.rb', line 47

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

#discount_idString

Parameters:

  • value (String)

Returns:

  • (String)


13
# File 'lib/dodopayments/models/discount_update_params.rb', line 13

required :discount_id, String

#expires_atTime?

Parameters:

  • value (Time, nil)

Returns:

  • (Time, nil)


54
# File 'lib/dodopayments/models/discount_update_params.rb', line 54

optional :expires_at, Time, nil?: true

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

Additional metadata for the discount

Parameters:

  • value (Dodopayments::Models::metadata, nil)

Returns:

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


60
61
62
# File 'lib/dodopayments/models/discount_update_params.rb', line 60

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

#nameString?

Parameters:

  • value (String, nil)

Returns:

  • (String, nil)


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

optional :name, String, nil?: true

#per_customer_usage_limitInteger?

If present, update the per-customer usage limit (double-option: send null to clear it back to unlimited). Must be <= usage_limit (the value in effect after this patch) when both are set.

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


75
# File 'lib/dodopayments/models/discount_update_params.rb', line 75

optional :per_customer_usage_limit, Integer, nil?: true

#preserve_on_plan_changeBoolean?

Whether this discount should be preserved when a subscription changes plans. If not provided, the existing value is kept.

Parameters:

  • value (Boolean, nil)

Returns:

  • (Boolean, nil)


82
# File 'lib/dodopayments/models/discount_update_params.rb', line 82

optional :preserve_on_plan_change, Dodopayments::Internal::Type::Boolean, nil?: true

#restricted_toArray<String>?

If present, replaces all restricted product IDs with this new set. To remove all restrictions, send empty array

Parameters:

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

Returns:

  • (Array<String>, nil)


89
# File 'lib/dodopayments/models/discount_update_params.rb', line 89

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

#starts_atTime?

If present, update starts_at (double-option: send null to clear it).

Parameters:

  • value (Time, nil)

Returns:

  • (Time, nil)


95
# File 'lib/dodopayments/models/discount_update_params.rb', line 95

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)


103
# File 'lib/dodopayments/models/discount_update_params.rb', line 103

optional :subscription_cycles, Integer, nil?: true

#typeSymbol, ...

If present, update the discount type (percentage or flat).

Parameters:

  • value (Dodopayments::Models::discount_type, nil)

Returns:



109
# File 'lib/dodopayments/models/discount_update_params.rb', line 109

optional :type, enum: -> { Dodopayments::DiscountType }, nil?: true

#usage_limitInteger?

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


114
# File 'lib/dodopayments/models/discount_update_params.rb', line 114

optional :usage_limit, Integer, nil?: true

Instance Method Details

#to_hash{

Returns:

  • ({)


76
# File 'sig/dodopayments/models/discount_update_params.rbs', line 76

def to_hash: -> {