Class: Pago::V2026_04::Models::DiscountPercentageCreate
- Defined in:
- lib/pago/v2026_04/models.rb,
sig/pago/v2026_04/generated.rbs
Overview
Schema to create a percentage 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", basis_points: "basis_points" }.freeze
- REQUIRED_KEYS =
["name", "duration", "basis_points"].freeze
Instance Attribute Summary collapse
-
#basis_points ⇒ Integer
readonly
Discount percentage in basis points.
-
#code ⇒ String?
readonly
Code customers can use to apply the discount during checkout.
- #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, basis_points:) ⇒ DiscountPercentageCreate
constructor
A new instance of DiscountPercentageCreate.
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, basis_points:) ⇒ DiscountPercentageCreate
Returns a new instance of DiscountPercentageCreate.
23213 23214 23215 23216 23217 23218 23219 23220 23221 23222 23223 23224 23225 23226 23227 23228 23229 23230 23231 23232 23233 23234 23235 23236 23237 23238 23239 23240 |
# File 'lib/pago/v2026_04/models.rb', line 23213 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, basis_points: ) 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(:basis_points, basis_points) end |
Instance Attribute Details
#basis_points ⇒ Integer (readonly)
Discount percentage in basis points.
A basis point is 1/100th of a percent. For example, to create a 25.5% discount, set this to 2550.
23211 23212 23213 |
# File 'lib/pago/v2026_04/models.rb', line 23211 def basis_points @basis_points 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.
23170 23171 23172 |
# File 'lib/pago/v2026_04/models.rb', line 23170 def code @code end |
#duration ⇒ String (readonly)
23195 23196 23197 |
# File 'lib/pago/v2026_04/models.rb', line 23195 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.
23204 23205 23206 |
# File 'lib/pago/v2026_04/models.rb', line 23204 def duration_in_months @duration_in_months end |
#ends_at ⇒ String? (readonly)
Optional timestamp after which the discount is no longer redeemable.
23178 23179 23180 |
# File 'lib/pago/v2026_04/models.rb', line 23178 def ends_at @ends_at end |
#max_redemptions ⇒ Integer? (readonly)
Optional maximum number of times the discount can be redeemed.
23182 23183 23184 |
# File 'lib/pago/v2026_04/models.rb', line 23182 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.
23162 23163 23164 |
# File 'lib/pago/v2026_04/models.rb', line 23162 def @metadata end |
#name ⇒ String (readonly)
Name of the discount. Will be displayed to the customer when the discount is applied.
23166 23167 23168 |
# File 'lib/pago/v2026_04/models.rb', line 23166 def name @name end |
#organization_id ⇒ String? (readonly)
The ID of the organization owning the discount. Required unless you use an organization token.
23189 23190 23191 |
# File 'lib/pago/v2026_04/models.rb', line 23189 def organization_id @organization_id end |
#products ⇒ Array<String>? (readonly)
23185 23186 23187 |
# File 'lib/pago/v2026_04/models.rb', line 23185 def products @products end |
#starts_at ⇒ String? (readonly)
Optional timestamp after which the discount is redeemable.
23174 23175 23176 |
# File 'lib/pago/v2026_04/models.rb', line 23174 def starts_at @starts_at end |
#type ⇒ String (readonly)
23192 23193 23194 |
# File 'lib/pago/v2026_04/models.rb', line 23192 def type @type end |
Class Method Details
.from_json(data) ⇒ DiscountPercentageCreate?
23244 23245 23246 23247 23248 23249 23250 23251 23252 23253 23254 23255 23256 23257 23258 23259 23260 23261 23262 23263 23264 23265 23266 |
# File 'lib/pago/v2026_04/models.rb', line 23244 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), basis_points: (data.key?("basis_points") ? data["basis_points"] : ::Pago::UNSET) ), data ) end |