Class: Dodopayments::Models::Subscription::Discount

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/dodopayments/models/subscription.rb

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:, business_id:, code:, created_at:, discount_id:, metadata:, position:, preserve_on_plan_change:, restricted_to:, times_used:, type:, cycles_remaining: nil, expires_at: nil, name: nil, subscription_cycles: nil, usage_limit: nil) ⇒ Object

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

Response struct for a discount with its position in a stack and optional cycle-tracking information (for subscriptions).

Parameters:

  • amount (Integer)

    The discount amount (basis points for percentage, USD cents for flat)

  • business_id (String)

    The business this discount belongs to

  • code (String)

    The discount code

  • created_at (Time)

    Timestamp when the discount was created

  • discount_id (String)

    The unique discount ID

  • metadata (Hash{Symbol=>String})

    Additional metadata

  • position (Integer)

    Position of this discount in the stack (0-based)

  • 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 which this discount is restricted

  • times_used (Integer)

    How many times this discount has been used

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

    The type of discount

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

    Remaining billing cycles for this discount on this subscription (None for one-ti

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

    Optional date/time after which discount is expired

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

    Name for the Discount

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

    Number of subscription billing cycles this discount is valid for

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

    Usage limit for this discount, if any



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'lib/dodopayments/models/subscription.rb', line 301

class Discount < Dodopayments::Internal::Type::BaseModel
  # @!attribute amount
  #   The discount amount (basis points for percentage, USD cents for flat)
  #
  #   @return [Integer]
  required :amount, Integer

  # @!attribute business_id
  #   The business this discount belongs to
  #
  #   @return [String]
  required :business_id, String

  # @!attribute code
  #   The discount code
  #
  #   @return [String]
  required :code, String

  # @!attribute created_at
  #   Timestamp when the discount was created
  #
  #   @return [Time]
  required :created_at, Time

  # @!attribute discount_id
  #   The unique discount ID
  #
  #   @return [String]
  required :discount_id, String

  # @!attribute metadata
  #   Additional metadata
  #
  #   @return [Hash{Symbol=>String}]
  required :metadata, Dodopayments::Internal::Type::HashOf[String]

  # @!attribute position
  #   Position of this discount in the stack (0-based)
  #
  #   @return [Integer]
  required :position, Integer

  # @!attribute preserve_on_plan_change
  #   Whether this discount should be preserved when a subscription changes plans
  #
  #   @return [Boolean]
  required :preserve_on_plan_change, Dodopayments::Internal::Type::Boolean

  # @!attribute restricted_to
  #   List of product IDs to which this discount is restricted
  #
  #   @return [Array<String>]
  required :restricted_to, Dodopayments::Internal::Type::ArrayOf[String]

  # @!attribute times_used
  #   How many times this discount has been used
  #
  #   @return [Integer]
  required :times_used, Integer

  # @!attribute type
  #   The type of discount
  #
  #   @return [Symbol, Dodopayments::Models::DiscountType]
  required :type, enum: -> { Dodopayments::DiscountType }

  # @!attribute cycles_remaining
  #   Remaining billing cycles for this discount on this subscription (None for
  #   one-time payments)
  #
  #   @return [Integer, nil]
  optional :cycles_remaining, Integer, nil?: true

  # @!attribute expires_at
  #   Optional date/time after which discount is expired
  #
  #   @return [Time, nil]
  optional :expires_at, Time, nil?: true

  # @!attribute name
  #   Name for the Discount
  #
  #   @return [String, nil]
  optional :name, String, nil?: true

  # @!attribute subscription_cycles
  #   Number of subscription billing cycles this discount is valid for
  #
  #   @return [Integer, nil]
  optional :subscription_cycles, Integer, nil?: true

  # @!attribute usage_limit
  #   Usage limit for this discount, if any
  #
  #   @return [Integer, nil]
  optional :usage_limit, Integer, nil?: true

  # @!method initialize(amount:, business_id:, code:, created_at:, discount_id:, metadata:, position:, preserve_on_plan_change:, restricted_to:, times_used:, type:, cycles_remaining: nil, expires_at: nil, name: nil, subscription_cycles: nil, usage_limit: nil)
  #   Some parameter documentations has been truncated, see
  #   {Dodopayments::Models::Subscription::Discount} for more details.
  #
  #   Response struct for a discount with its position in a stack and optional
  #   cycle-tracking information (for subscriptions).
  #
  #   @param amount [Integer] The discount amount (basis points for percentage, USD cents for flat)
  #
  #   @param business_id [String] The business this discount belongs to
  #
  #   @param code [String] The discount code
  #
  #   @param created_at [Time] Timestamp when the discount was created
  #
  #   @param discount_id [String] The unique discount ID
  #
  #   @param metadata [Hash{Symbol=>String}] Additional metadata
  #
  #   @param position [Integer] Position of this discount in the stack (0-based)
  #
  #   @param preserve_on_plan_change [Boolean] Whether this discount should be preserved when a subscription changes plans
  #
  #   @param restricted_to [Array<String>] List of product IDs to which this discount is restricted
  #
  #   @param times_used [Integer] How many times this discount has been used
  #
  #   @param type [Symbol, Dodopayments::Models::DiscountType] The type of discount
  #
  #   @param cycles_remaining [Integer, nil] Remaining billing cycles for this discount on this subscription (None for one-ti
  #
  #   @param expires_at [Time, nil] Optional date/time after which discount is expired
  #
  #   @param name [String, nil] Name for the Discount
  #
  #   @param subscription_cycles [Integer, nil] Number of subscription billing cycles this discount is valid for
  #
  #   @param usage_limit [Integer, nil] Usage limit for this discount, if any
end

Instance Attribute Details

#amountInteger

The discount amount (basis points for percentage, USD cents for flat)

Returns:

  • (Integer)


306
# File 'lib/dodopayments/models/subscription.rb', line 306

required :amount, Integer

#business_idString

The business this discount belongs to

Returns:

  • (String)


312
# File 'lib/dodopayments/models/subscription.rb', line 312

required :business_id, String

#codeString

The discount code

Returns:

  • (String)


318
# File 'lib/dodopayments/models/subscription.rb', line 318

required :code, String

#created_atTime

Timestamp when the discount was created

Returns:

  • (Time)


324
# File 'lib/dodopayments/models/subscription.rb', line 324

required :created_at, Time

#cycles_remainingInteger?

Remaining billing cycles for this discount on this subscription (None for one-time payments)

Returns:

  • (Integer, nil)


373
# File 'lib/dodopayments/models/subscription.rb', line 373

optional :cycles_remaining, Integer, nil?: true

#discount_idString

The unique discount ID

Returns:

  • (String)


330
# File 'lib/dodopayments/models/subscription.rb', line 330

required :discount_id, String

#expires_atTime?

Optional date/time after which discount is expired

Returns:

  • (Time, nil)


379
# File 'lib/dodopayments/models/subscription.rb', line 379

optional :expires_at, Time, nil?: true

#metadataHash{Symbol=>String}

Additional metadata

Returns:

  • (Hash{Symbol=>String})


336
# File 'lib/dodopayments/models/subscription.rb', line 336

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

#nameString?

Name for the Discount

Returns:

  • (String, nil)


385
# File 'lib/dodopayments/models/subscription.rb', line 385

optional :name, String, nil?: true

#positionInteger

Position of this discount in the stack (0-based)

Returns:

  • (Integer)


342
# File 'lib/dodopayments/models/subscription.rb', line 342

required :position, Integer

#preserve_on_plan_changeBoolean

Whether this discount should be preserved when a subscription changes plans

Returns:

  • (Boolean)


348
# File 'lib/dodopayments/models/subscription.rb', line 348

required :preserve_on_plan_change, Dodopayments::Internal::Type::Boolean

#restricted_toArray<String>

List of product IDs to which this discount is restricted

Returns:

  • (Array<String>)


354
# File 'lib/dodopayments/models/subscription.rb', line 354

required :restricted_to, Dodopayments::Internal::Type::ArrayOf[String]

#subscription_cyclesInteger?

Number of subscription billing cycles this discount is valid for

Returns:

  • (Integer, nil)


391
# File 'lib/dodopayments/models/subscription.rb', line 391

optional :subscription_cycles, Integer, nil?: true

#times_usedInteger

How many times this discount has been used

Returns:

  • (Integer)


360
# File 'lib/dodopayments/models/subscription.rb', line 360

required :times_used, Integer

#typeSymbol, Dodopayments::Models::DiscountType

The type of discount



366
# File 'lib/dodopayments/models/subscription.rb', line 366

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

#usage_limitInteger?

Usage limit for this discount, if any

Returns:

  • (Integer, nil)


397
# File 'lib/dodopayments/models/subscription.rb', line 397

optional :usage_limit, Integer, nil?: true