Class: ApiReference::NewTieredPercentageDiscount
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::NewTieredPercentageDiscount
- Defined in:
- lib/api_reference/models/new_tiered_percentage_discount.rb
Overview
NewTieredPercentageDiscount Model.
Instance Attribute Summary collapse
-
#adjustment_type ⇒ String
readonly
When false, this adjustment will be applied to a single price.
-
#applies_to_all ⇒ TrueClass | FalseClass
If set, the adjustment will apply to every price on the subscription.
-
#applies_to_item_ids ⇒ Array[String]
The set of item IDs to which this adjustment applies.
-
#applies_to_price_ids ⇒ Array[String]
The set of price IDs to which this adjustment applies.
-
#currency ⇒ String
If set, only prices in the specified currency will have the adjustment applied.
-
#filters ⇒ Array[PriceFilter]
A list of filters that determine which prices this adjustment will apply to.
-
#is_invoice_level ⇒ TrueClass | FalseClass
When false, this adjustment will be applied to a single price.
-
#price_type ⇒ PriceType
If set, only prices of the specified type will have the adjustment applied.
-
#tiers ⇒ Array[NewTieredPercentageDiscountTier]
When false, this adjustment will be applied to a single price.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(tiers:, applies_to_price_ids: SKIP, applies_to_item_ids: SKIP, applies_to_all: SKIP, filters: SKIP, currency: SKIP, price_type: SKIP, is_invoice_level: true, additional_properties: nil) ⇒ NewTieredPercentageDiscount
constructor
A new instance of NewTieredPercentageDiscount.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(tiers:, applies_to_price_ids: SKIP, applies_to_item_ids: SKIP, applies_to_all: SKIP, filters: SKIP, currency: SKIP, price_type: SKIP, is_invoice_level: true, additional_properties: nil) ⇒ NewTieredPercentageDiscount
Returns a new instance of NewTieredPercentageDiscount.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 94 def initialize(tiers:, applies_to_price_ids: SKIP, applies_to_item_ids: SKIP, applies_to_all: SKIP, filters: SKIP, currency: SKIP, price_type: SKIP, is_invoice_level: true, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @applies_to_price_ids = applies_to_price_ids unless applies_to_price_ids == SKIP @applies_to_item_ids = applies_to_item_ids unless applies_to_item_ids == SKIP @applies_to_all = applies_to_all unless applies_to_all == SKIP @filters = filters unless filters == SKIP @currency = currency unless currency == SKIP @price_type = price_type unless price_type == SKIP @is_invoice_level = is_invoice_level unless is_invoice_level == SKIP @adjustment_type = 'tiered_percentage_discount' @tiers = tiers @additional_properties = additional_properties end |
Instance Attribute Details
#adjustment_type ⇒ String (readonly)
When false, this adjustment will be applied to a single price. Otherwise, it will be applied at the invoice level, possibly to multiple prices.
47 48 49 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 47 def adjustment_type @adjustment_type end |
#applies_to_all ⇒ TrueClass | FalseClass
If set, the adjustment will apply to every price on the subscription.
22 23 24 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 22 def applies_to_all @applies_to_all end |
#applies_to_item_ids ⇒ Array[String]
The set of item IDs to which this adjustment applies.
18 19 20 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 18 def applies_to_item_ids @applies_to_item_ids end |
#applies_to_price_ids ⇒ Array[String]
The set of price IDs to which this adjustment applies.
14 15 16 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 14 def applies_to_price_ids @applies_to_price_ids end |
#currency ⇒ String
If set, only prices in the specified currency will have the adjustment applied.
32 33 34 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 32 def currency @currency end |
#filters ⇒ Array[PriceFilter]
A list of filters that determine which prices this adjustment will apply to.
27 28 29 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 27 def filters @filters end |
#is_invoice_level ⇒ TrueClass | FalseClass
When false, this adjustment will be applied to a single price. Otherwise, it will be applied at the invoice level, possibly to multiple prices.
42 43 44 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 42 def is_invoice_level @is_invoice_level end |
#price_type ⇒ PriceType
If set, only prices of the specified type will have the adjustment applied.
37 38 39 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 37 def price_type @price_type end |
#tiers ⇒ Array[NewTieredPercentageDiscountTier]
When false, this adjustment will be applied to a single price. Otherwise, it will be applied at the invoice level, possibly to multiple prices.
52 53 54 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 52 def tiers @tiers end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 114 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it tiers = nil unless hash['tiers'].nil? tiers = [] hash['tiers'].each do |structure| tiers << (NewTieredPercentageDiscountTier.from_hash(structure) if structure) end end tiers = nil unless hash.key?('tiers') applies_to_price_ids = hash.key?('applies_to_price_ids') ? hash['applies_to_price_ids'] : SKIP applies_to_item_ids = hash.key?('applies_to_item_ids') ? hash['applies_to_item_ids'] : SKIP applies_to_all = hash.key?('applies_to_all') ? hash['applies_to_all'] : SKIP # Parameter is an array, so we need to iterate through it filters = nil unless hash['filters'].nil? filters = [] hash['filters'].each do |structure| filters << (PriceFilter.from_hash(structure) if structure) end end filters = SKIP unless hash.key?('filters') currency = hash.key?('currency') ? hash['currency'] : SKIP price_type = hash.key?('price_type') ? hash['price_type'] : SKIP is_invoice_level = hash['is_invoice_level'] ||= true # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. NewTieredPercentageDiscount.new(tiers: tiers, applies_to_price_ids: applies_to_price_ids, applies_to_item_ids: applies_to_item_ids, applies_to_all: applies_to_all, filters: filters, currency: currency, price_type: price_type, is_invoice_level: is_invoice_level, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 55 def self.names @_hash = {} if @_hash.nil? @_hash['applies_to_price_ids'] = 'applies_to_price_ids' @_hash['applies_to_item_ids'] = 'applies_to_item_ids' @_hash['applies_to_all'] = 'applies_to_all' @_hash['filters'] = 'filters' @_hash['currency'] = 'currency' @_hash['price_type'] = 'price_type' @_hash['is_invoice_level'] = 'is_invoice_level' @_hash['adjustment_type'] = 'adjustment_type' @_hash['tiers'] = 'tiers' @_hash end |
.nullables ⇒ Object
An array for nullable fields
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 83 def self.nullables %w[ applies_to_price_ids applies_to_item_ids applies_to_all filters currency price_type ] end |
.optionals ⇒ Object
An array for optional fields
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 70 def self.optionals %w[ applies_to_price_ids applies_to_item_ids applies_to_all filters currency price_type is_invoice_level ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 169 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.adjustment_type, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.tiers, ->(val) { NewTieredPercentageDiscountTier.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['adjustment_type'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['tiers'], ->(val) { NewTieredPercentageDiscountTier.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
204 205 206 207 208 209 210 211 212 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 204 def inspect class_name = self.class.name.split('::').last "<#{class_name} applies_to_price_ids: #{@applies_to_price_ids.inspect},"\ " applies_to_item_ids: #{@applies_to_item_ids.inspect}, applies_to_all:"\ " #{@applies_to_all.inspect}, filters: #{@filters.inspect}, currency: #{@currency.inspect},"\ " price_type: #{@price_type.inspect}, is_invoice_level: #{@is_invoice_level.inspect},"\ " adjustment_type: #{@adjustment_type.inspect}, tiers: #{@tiers.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
194 195 196 197 198 199 200 201 |
# File 'lib/api_reference/models/new_tiered_percentage_discount.rb', line 194 def to_s class_name = self.class.name.split('::').last "<#{class_name} applies_to_price_ids: #{@applies_to_price_ids}, applies_to_item_ids:"\ " #{@applies_to_item_ids}, applies_to_all: #{@applies_to_all}, filters: #{@filters},"\ " currency: #{@currency}, price_type: #{@price_type}, is_invoice_level:"\ " #{@is_invoice_level}, adjustment_type: #{@adjustment_type}, tiers: #{@tiers},"\ " additional_properties: #{@additional_properties}>" end |