Class: Pago::V2026_04::Models::CheckoutDiscountFixedOnceForeverDuration

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

Overview

Schema for a fixed amount discount that is applied once or forever.

Constant Summary collapse

JSON_KEYS =

Returns:

  • (Hash[Symbol, String])
{
  duration: "duration",
  type: "type",
  amount: "amount",
  currency: "currency",
  amounts: "amounts",
  id: "id",
  name: "name",
  code: "code"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
["duration", "type", "amount", "currency", "amounts", "id", "name", "code"].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(duration:, type:, amount:, currency:, amounts:, id:, name:, code:) ⇒ CheckoutDiscountFixedOnceForeverDuration

Returns a new instance of CheckoutDiscountFixedOnceForeverDuration.

Parameters:

  • duration: (String)
  • type: (String)
  • amount: (Integer)
  • currency: (String)
  • amounts: (Hash[String, Integer])
  • id: (String)
  • name: (String)
  • code: (String, nil)


10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
# File 'lib/pago/v2026_04/models.rb', line 10278

def initialize(
  duration:,
  type:,
  amount:,
  currency:,
  amounts:,
  id:,
  name:,
  code:
)
  super()
  assign(:duration, duration)
  assign(:type, type)
  assign(:amount, amount)
  assign(:currency, currency)
  assign(:amounts, amounts)
  assign(:id, id)
  assign(:name, name)
  assign(:code, code)
end

Instance Attribute Details

#amountInteger (readonly)

Deprecated.

Returns:

  • (Integer)


10258
10259
10260
# File 'lib/pago/v2026_04/models.rb', line 10258

def amount
  @amount
end

#amountsHash{String => Integer} (readonly)

Map of currency to fixed amount to discount from the total.

Returns:

  • (Hash{String => Integer})


10266
10267
10268
# File 'lib/pago/v2026_04/models.rb', line 10266

def amounts
  @amounts
end

#codeString? (readonly)

Returns:

  • (String, nil)


10276
10277
10278
# File 'lib/pago/v2026_04/models.rb', line 10276

def code
  @code
end

#currencyString (readonly)

Deprecated.

Returns:

  • (String)


10262
10263
10264
# File 'lib/pago/v2026_04/models.rb', line 10262

def currency
  @currency
end

#durationString (readonly)

Returns:

  • (String)


10251
10252
10253
# File 'lib/pago/v2026_04/models.rb', line 10251

def duration
  @duration
end

#idString (readonly)

The ID of the object.

Returns:

  • (String)


10270
10271
10272
# File 'lib/pago/v2026_04/models.rb', line 10270

def id
  @id
end

#nameString (readonly)

Returns:

  • (String)


10273
10274
10275
# File 'lib/pago/v2026_04/models.rb', line 10273

def name
  @name
end

#typeString (readonly)

Returns:

  • (String)


10254
10255
10256
# File 'lib/pago/v2026_04/models.rb', line 10254

def type
  @type
end

Class Method Details

.from_json(data) ⇒ CheckoutDiscountFixedOnceForeverDuration?

Parameters:

  • data (Hash, String, nil)

Returns:



10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
# File 'lib/pago/v2026_04/models.rb', line 10301

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(
      duration: (data.key?("duration") ? data["duration"] : ::Pago::UNSET),
      type: (data.key?("type") ? data["type"] : ::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),
      id: (data.key?("id") ? data["id"] : ::Pago::UNSET),
      name: (data.key?("name") ? data["name"] : ::Pago::UNSET),
      code: (data.key?("code") ? data["code"] : ::Pago::UNSET)
    ),
    data
  )
end