Class: Pago::V2026_04::Models::DiscountUpdate

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

Overview

Schema to update a 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",
  duration: "duration",
  duration_in_months: "duration_in_months",
  type: "type",
  amount: "amount",
  currency: "currency",
  amounts: "amounts",
  basis_points: "basis_points",
  products: "products"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
[].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: ::Pago::UNSET, code: ::Pago::UNSET, starts_at: ::Pago::UNSET, ends_at: ::Pago::UNSET, max_redemptions: ::Pago::UNSET, duration: ::Pago::UNSET, duration_in_months: ::Pago::UNSET, type: ::Pago::UNSET, amount: ::Pago::UNSET, currency: ::Pago::UNSET, amounts: ::Pago::UNSET, basis_points: ::Pago::UNSET, products: ::Pago::UNSET) ⇒ DiscountUpdate

Returns a new instance of DiscountUpdate.

Parameters:

  • metadata: (Hash[String, untyped], nil) (defaults to: ::Pago::UNSET)
  • name: (String, nil) (defaults to: ::Pago::UNSET)
  • 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)
  • duration: (String, nil) (defaults to: ::Pago::UNSET)
  • duration_in_months: (Integer, nil) (defaults to: ::Pago::UNSET)
  • type: (String, 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)
  • basis_points: (Integer, nil) (defaults to: ::Pago::UNSET)
  • products: (Array[String], nil) (defaults to: ::Pago::UNSET)


24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
# File 'lib/pago/v2026_04/models.rb', line 24067

def initialize(
  metadata: ::Pago::UNSET,
  name: ::Pago::UNSET,
  code: ::Pago::UNSET,
  starts_at: ::Pago::UNSET,
  ends_at: ::Pago::UNSET,
  max_redemptions: ::Pago::UNSET,
  duration: ::Pago::UNSET,
  duration_in_months: ::Pago::UNSET,
  type: ::Pago::UNSET,
  amount: ::Pago::UNSET,
  currency: ::Pago::UNSET,
  amounts: ::Pago::UNSET,
  basis_points: ::Pago::UNSET,
  products: ::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(:duration, duration)
  assign(:duration_in_months, duration_in_months)
  assign(:type, type)
  assign(:amount, amount)
  assign(:currency, currency)
  assign(:amounts, amounts)
  assign(:basis_points, basis_points)
  assign(:products, products)
end

Instance Attribute Details

#amountInteger? (readonly)

Deprecated.

Returns:

  • (Integer, nil)


24052
24053
24054
# File 'lib/pago/v2026_04/models.rb', line 24052

def amount
  @amount
end

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

Returns:

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


24059
24060
24061
# File 'lib/pago/v2026_04/models.rb', line 24059

def amounts
  @amounts
end

#basis_pointsInteger? (readonly)

Returns:

  • (Integer, nil)


24062
24063
24064
# File 'lib/pago/v2026_04/models.rb', line 24062

def basis_points
  @basis_points
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)


24027
24028
24029
# File 'lib/pago/v2026_04/models.rb', line 24027

def code
  @code
end

#currencyString? (readonly)

Deprecated.

Returns:

  • (String, nil)


24056
24057
24058
# File 'lib/pago/v2026_04/models.rb', line 24056

def currency
  @currency
end

#durationString? (readonly)

Returns:

  • (String, nil)


24042
24043
24044
# File 'lib/pago/v2026_04/models.rb', line 24042

def duration
  @duration
end

#duration_in_monthsInteger? (readonly)

Returns:

  • (Integer, nil)


24045
24046
24047
# File 'lib/pago/v2026_04/models.rb', line 24045

def duration_in_months
  @duration_in_months
end

#ends_atString? (readonly)

Optional timestamp after which the discount is no longer redeemable.

Returns:

  • (String, nil)


24035
24036
24037
# File 'lib/pago/v2026_04/models.rb', line 24035

def ends_at
  @ends_at
end

#max_redemptionsInteger? (readonly)

Optional maximum number of times the discount can be redeemed.

Returns:

  • (Integer, nil)


24039
24040
24041
# File 'lib/pago/v2026_04/models.rb', line 24039

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})


24020
24021
24022
# File 'lib/pago/v2026_04/models.rb', line 24020

def 
  @metadata
end

#nameString? (readonly)

Returns:

  • (String, nil)


24023
24024
24025
# File 'lib/pago/v2026_04/models.rb', line 24023

def name
  @name
end

#productsArray<String>? (readonly)

Returns:

  • (Array<String>, nil)


24065
24066
24067
# File 'lib/pago/v2026_04/models.rb', line 24065

def products
  @products
end

#starts_atString? (readonly)

Optional timestamp after which the discount is redeemable.

Returns:

  • (String, nil)


24031
24032
24033
# File 'lib/pago/v2026_04/models.rb', line 24031

def starts_at
  @starts_at
end

#typeString? (readonly)

Returns:

  • (String, nil)


24048
24049
24050
# File 'lib/pago/v2026_04/models.rb', line 24048

def type
  @type
end

Class Method Details

.from_json(data) ⇒ DiscountUpdate?

Parameters:

  • data (Hash, String, nil)

Returns:



24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
# File 'lib/pago/v2026_04/models.rb', line 24102

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),
      duration: (data.key?("duration") ? data["duration"] : ::Pago::UNSET),
      duration_in_months: (data.key?("duration_in_months") ? data["duration_in_months"] : ::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),
      basis_points: (data.key?("basis_points") ? data["basis_points"] : ::Pago::UNSET),
      products: (data.key?("products") ? data["products"] : ::Pago::UNSET)
    ),
    data
  )
end