Class: Pago::V2026_04::Models::DiscountFixedCreate

Inherits:
Model
  • Object
show all
Defined in:
lib/pago/v2026_04/models.rb,
sig/pago/v2026_04/generated.rbs

Overview

Schema to create a fixed amount discount.

Constant Summary collapse

JSON_KEYS =

Returns:

  • (Hash[Symbol, String])
{
  metadata: "metadata",
  name: "name",
  code: "code",
  starts_at: "starts_at",
  ends_at: "ends_at",
  max_redemptions: "max_redemptions",
  products: "products",
  organization_id: "organization_id",
  type: "type",
  duration: "duration",
  duration_in_months: "duration_in_months",
  amount: "amount",
  currency: "currency",
  amounts: "amounts"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
["name", "duration"].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#==, #[], #field_set?, #hash, #inspect, json_keys, required_json_keys, #to_json, #to_json_hash, wrap_raw

Constructor Details

#initialize(metadata: ::Pago::UNSET, name:, code: ::Pago::UNSET, starts_at: ::Pago::UNSET, ends_at: ::Pago::UNSET, max_redemptions: ::Pago::UNSET, products: ::Pago::UNSET, organization_id: ::Pago::UNSET, type: ::Pago::UNSET, duration:, duration_in_months: ::Pago::UNSET, amount: ::Pago::UNSET, currency: ::Pago::UNSET, amounts: ::Pago::UNSET) ⇒ DiscountFixedCreate

Returns a new instance of DiscountFixedCreate.

Parameters:

  • metadata: (Hash[String, untyped], nil) (defaults to: ::Pago::UNSET)
  • name: (String)
  • code: (String, nil) (defaults to: ::Pago::UNSET)
  • starts_at: (String, nil) (defaults to: ::Pago::UNSET)
  • ends_at: (String, nil) (defaults to: ::Pago::UNSET)
  • max_redemptions: (Integer, nil) (defaults to: ::Pago::UNSET)
  • products: (Array[String], nil) (defaults to: ::Pago::UNSET)
  • organization_id: (String, nil) (defaults to: ::Pago::UNSET)
  • type: (String, nil) (defaults to: ::Pago::UNSET)
  • duration: (String)
  • duration_in_months: (Integer, nil) (defaults to: ::Pago::UNSET)
  • amount: (Integer, nil) (defaults to: ::Pago::UNSET)
  • currency: (String, nil) (defaults to: ::Pago::UNSET)
  • amounts: (Hash[String, Integer], nil) (defaults to: ::Pago::UNSET)


22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
# File 'lib/pago/v2026_04/models.rb', line 22439

def initialize(
  metadata: ::Pago::UNSET,
  name:,
  code: ::Pago::UNSET,
  starts_at: ::Pago::UNSET,
  ends_at: ::Pago::UNSET,
  max_redemptions: ::Pago::UNSET,
  products: ::Pago::UNSET,
  organization_id: ::Pago::UNSET,
  type: ::Pago::UNSET,
  duration:,
  duration_in_months: ::Pago::UNSET,
  amount: ::Pago::UNSET,
  currency: ::Pago::UNSET,
  amounts: ::Pago::UNSET
)
  super()
  assign(:metadata, )
  assign(:name, name)
  assign(:code, code)
  assign(:starts_at, starts_at)
  assign(:ends_at, ends_at)
  assign(:max_redemptions, max_redemptions)
  assign(:products, products)
  assign(:organization_id, organization_id)
  assign(:type, type)
  assign(:duration, duration)
  assign(:duration_in_months, duration_in_months)
  assign(:amount, amount)
  assign(:currency, currency)
  assign(:amounts, amounts)
end

Instance Attribute Details

#amountInteger? (readonly)

Deprecated.

Returns:

  • (Integer, nil)


22430
22431
22432
# File 'lib/pago/v2026_04/models.rb', line 22430

def amount
  @amount
end

#amountsHash{String => Integer}? (readonly)

Returns:

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


22437
22438
22439
# File 'lib/pago/v2026_04/models.rb', line 22437

def amounts
  @amounts
end

#codeString? (readonly)

Code customers can use to apply the discount during checkout. Must be between 3 and 256 characters long and contain only alphanumeric characters.If not provided, the discount can only be applied via the API.

Returns:

  • (String, nil)


22392
22393
22394
# File 'lib/pago/v2026_04/models.rb', line 22392

def code
  @code
end

#currencyString? (readonly)

Deprecated.

Returns:

  • (String, nil)


22434
22435
22436
# File 'lib/pago/v2026_04/models.rb', line 22434

def currency
  @currency
end

#durationString (readonly)

Returns:

  • (String)


22417
22418
22419
# File 'lib/pago/v2026_04/models.rb', line 22417

def duration
  @duration
end

#duration_in_monthsInteger? (readonly)

Number of months the discount should be applied.

Required when duration is repeating. Must be omitted otherwise.

For this to work on yearly pricing, you should multiply this by 12. For example, to apply the discount for 2 years, set this to 24.

Returns:

  • (Integer, nil)


22426
22427
22428
# File 'lib/pago/v2026_04/models.rb', line 22426

def duration_in_months
  @duration_in_months
end

#ends_atString? (readonly)

Optional timestamp after which the discount is no longer redeemable.

Returns:

  • (String, nil)


22400
22401
22402
# File 'lib/pago/v2026_04/models.rb', line 22400

def ends_at
  @ends_at
end

#max_redemptionsInteger? (readonly)

Optional maximum number of times the discount can be redeemed.

Returns:

  • (Integer, nil)


22404
22405
22406
# File 'lib/pago/v2026_04/models.rb', line 22404

def max_redemptions
  @max_redemptions
end

#metadataHash{String => String, Integer, Float, Boolean} (readonly)

Key-value object allowing you to store additional information.

The key must be a string with a maximum length of 40 characters. The value must be either:

  • A string with a maximum length of 500 characters
  • An integer
  • A floating-point number
  • A boolean

You can store up to 50 key-value pairs.

Returns:

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


22384
22385
22386
# File 'lib/pago/v2026_04/models.rb', line 22384

def 
  @metadata
end

#nameString (readonly)

Name of the discount. Will be displayed to the customer when the discount is applied.

Returns:

  • (String)


22388
22389
22390
# File 'lib/pago/v2026_04/models.rb', line 22388

def name
  @name
end

#organization_idString? (readonly)

The ID of the organization owning the discount. Required unless you use an organization token.

Returns:

  • (String, nil)


22411
22412
22413
# File 'lib/pago/v2026_04/models.rb', line 22411

def organization_id
  @organization_id
end

#productsArray<String>? (readonly)

Returns:

  • (Array<String>, nil)


22407
22408
22409
# File 'lib/pago/v2026_04/models.rb', line 22407

def products
  @products
end

#starts_atString? (readonly)

Optional timestamp after which the discount is redeemable.

Returns:

  • (String, nil)


22396
22397
22398
# File 'lib/pago/v2026_04/models.rb', line 22396

def starts_at
  @starts_at
end

#typeString (readonly)

Returns:

  • (String)


22414
22415
22416
# File 'lib/pago/v2026_04/models.rb', line 22414

def type
  @type
end

Class Method Details

.from_json(data) ⇒ DiscountFixedCreate?

Parameters:

  • data (Hash, String, nil)

Returns:



22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
# File 'lib/pago/v2026_04/models.rb', line 22474

def self.from_json(data)
  data = ::JSON.parse(data) if data.is_a?(String)
  data = ::Pago::Serde.object(data)
  return nil if data.nil?

  wrap_raw(
    new(
      metadata: (data.key?("metadata") ? data["metadata"] : ::Pago::UNSET),
      name: (data.key?("name") ? data["name"] : ::Pago::UNSET),
      code: (data.key?("code") ? data["code"] : ::Pago::UNSET),
      starts_at: (data.key?("starts_at") ? data["starts_at"] : ::Pago::UNSET),
      ends_at: (data.key?("ends_at") ? data["ends_at"] : ::Pago::UNSET),
      max_redemptions: (data.key?("max_redemptions") ? data["max_redemptions"] : ::Pago::UNSET),
      products: (data.key?("products") ? data["products"] : ::Pago::UNSET),
      organization_id: (data.key?("organization_id") ? data["organization_id"] : ::Pago::UNSET),
      type: (data.key?("type") ? data["type"] : ::Pago::UNSET),
      duration: (data.key?("duration") ? data["duration"] : ::Pago::UNSET),
      duration_in_months: (data.key?("duration_in_months") ? data["duration_in_months"] : ::Pago::UNSET),
      amount: (data.key?("amount") ? data["amount"] : ::Pago::UNSET),
      currency: (data.key?("currency") ? data["currency"] : ::Pago::UNSET),
      amounts: (data.key?("amounts") ? data["amounts"] : ::Pago::UNSET)
    ),
    data
  )
end