Class: Pago::V2026_04::Models::DiscountFixedCreate
- 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 =
{ 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 =
["name", "duration"].freeze
Instance Attribute Summary collapse
- #amount ⇒ Integer? readonly deprecated Deprecated.
- #amounts ⇒ Hash{String => Integer}? readonly
-
#code ⇒ String?
readonly
Code customers can use to apply the discount during checkout.
- #currency ⇒ String? readonly deprecated Deprecated.
- #duration ⇒ String readonly
-
#duration_in_months ⇒ Integer?
readonly
Number of months the discount should be applied.
-
#ends_at ⇒ String?
readonly
Optional timestamp after which the discount is no longer redeemable.
-
#max_redemptions ⇒ Integer?
readonly
Optional maximum number of times the discount can be redeemed.
-
#metadata ⇒ Hash{String => String, Integer, Float, Boolean}
readonly
Key-value object allowing you to store additional information.
-
#name ⇒ String
readonly
Name of the discount.
-
#organization_id ⇒ String?
readonly
The ID of the organization owning the discount.
- #products ⇒ Array<String>? readonly
-
#starts_at ⇒ String?
readonly
Optional timestamp after which the discount is redeemable.
- #type ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#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
constructor
A new instance of DiscountFixedCreate.
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.
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
#amount ⇒ Integer? (readonly)
22430 22431 22432 |
# File 'lib/pago/v2026_04/models.rb', line 22430 def amount @amount end |
#amounts ⇒ Hash{String => Integer}? (readonly)
22437 22438 22439 |
# File 'lib/pago/v2026_04/models.rb', line 22437 def amounts @amounts end |
#code ⇒ String? (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.
22392 22393 22394 |
# File 'lib/pago/v2026_04/models.rb', line 22392 def code @code end |
#currency ⇒ String? (readonly)
22434 22435 22436 |
# File 'lib/pago/v2026_04/models.rb', line 22434 def currency @currency end |
#duration ⇒ String (readonly)
22417 22418 22419 |
# File 'lib/pago/v2026_04/models.rb', line 22417 def duration @duration end |
#duration_in_months ⇒ Integer? (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.
22426 22427 22428 |
# File 'lib/pago/v2026_04/models.rb', line 22426 def duration_in_months @duration_in_months end |
#ends_at ⇒ String? (readonly)
Optional timestamp after which the discount is no longer redeemable.
22400 22401 22402 |
# File 'lib/pago/v2026_04/models.rb', line 22400 def ends_at @ends_at end |
#max_redemptions ⇒ Integer? (readonly)
Optional maximum number of times the discount can be redeemed.
22404 22405 22406 |
# File 'lib/pago/v2026_04/models.rb', line 22404 def max_redemptions @max_redemptions end |
#metadata ⇒ Hash{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.
22384 22385 22386 |
# File 'lib/pago/v2026_04/models.rb', line 22384 def @metadata end |
#name ⇒ String (readonly)
Name of the discount. Will be displayed to the customer when the discount is applied.
22388 22389 22390 |
# File 'lib/pago/v2026_04/models.rb', line 22388 def name @name end |
#organization_id ⇒ String? (readonly)
The ID of the organization owning the discount. Required unless you use an organization token.
22411 22412 22413 |
# File 'lib/pago/v2026_04/models.rb', line 22411 def organization_id @organization_id end |
#products ⇒ Array<String>? (readonly)
22407 22408 22409 |
# File 'lib/pago/v2026_04/models.rb', line 22407 def products @products end |
#starts_at ⇒ String? (readonly)
Optional timestamp after which the discount is redeemable.
22396 22397 22398 |
# File 'lib/pago/v2026_04/models.rb', line 22396 def starts_at @starts_at end |
#type ⇒ String (readonly)
22414 22415 22416 |
# File 'lib/pago/v2026_04/models.rb', line 22414 def type @type end |
Class Method Details
.from_json(data) ⇒ DiscountFixedCreate?
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 |