Class: ApiReference::MonetaryTieredPercentageDiscountAdjustment
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::MonetaryTieredPercentageDiscountAdjustment
- Defined in:
- lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb
Overview
MonetaryTieredPercentageDiscountAdjustment Model.
Instance Attribute Summary collapse
-
#adjustment_type ⇒ String
readonly
The adjustment id this adjustment replaces.
-
#amount ⇒ String
The value applied by an adjustment.
-
#applies_to_price_ids ⇒ Array[String]
The price IDs that this adjustment applies to.
-
#filters ⇒ Array[PriceFilter]
The filters that determine which prices to apply this adjustment to.
-
#id ⇒ String
TODO: Write general description for this method.
-
#is_invoice_level ⇒ TrueClass | FalseClass
True for adjustments that apply to an entire invoice, false for adjustments that apply to only one price.
-
#reason ⇒ String
The reason for the adjustment.
-
#replaces_adjustment_id ⇒ String
The adjustment id this adjustment replaces.
-
#tiers ⇒ Array[PercentageTier]
The ordered, contiguous bands of cumulative eligible spend, each discounted at its own percentage (progressive fill-a-tier), applied to the prices this adjustment covers in a given billing period.
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(id:, is_invoice_level:, filters:, applies_to_price_ids:, reason:, replaces_adjustment_id:, tiers:, amount:, additional_properties: nil) ⇒ MonetaryTieredPercentageDiscountAdjustment
constructor
A new instance of MonetaryTieredPercentageDiscountAdjustment.
-
#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(id:, is_invoice_level:, filters:, applies_to_price_ids:, reason:, replaces_adjustment_id:, tiers:, amount:, additional_properties: nil) ⇒ MonetaryTieredPercentageDiscountAdjustment
Returns a new instance of MonetaryTieredPercentageDiscountAdjustment.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 81 def initialize(id:, is_invoice_level:, filters:, applies_to_price_ids:, reason:, replaces_adjustment_id:, tiers:, amount:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id @is_invoice_level = is_invoice_level @filters = filters @applies_to_price_ids = applies_to_price_ids @reason = reason @replaces_adjustment_id = replaces_adjustment_id @adjustment_type = 'tiered_percentage_discount' @tiers = tiers @amount = amount @additional_properties = additional_properties end |
Instance Attribute Details
#adjustment_type ⇒ String (readonly)
The adjustment id this adjustment replaces. This adjustment will take the place of the replaced adjustment in plan version migrations.
41 42 43 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 41 def adjustment_type @adjustment_type end |
#amount ⇒ String
The value applied by an adjustment.
51 52 53 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 51 def amount @amount end |
#applies_to_price_ids ⇒ Array[String]
The price IDs that this adjustment applies to.
27 28 29 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 27 def applies_to_price_ids @applies_to_price_ids end |
#filters ⇒ Array[PriceFilter]
The filters that determine which prices to apply this adjustment to.
23 24 25 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 23 def filters @filters end |
#id ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 14 def id @id end |
#is_invoice_level ⇒ TrueClass | FalseClass
True for adjustments that apply to an entire invoice, false for adjustments that apply to only one price.
19 20 21 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 19 def is_invoice_level @is_invoice_level end |
#reason ⇒ String
The reason for the adjustment.
31 32 33 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 31 def reason @reason end |
#replaces_adjustment_id ⇒ String
The adjustment id this adjustment replaces. This adjustment will take the place of the replaced adjustment in plan version migrations.
36 37 38 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 36 def replaces_adjustment_id @replaces_adjustment_id end |
#tiers ⇒ Array[PercentageTier]
The ordered, contiguous bands of cumulative eligible spend, each discounted at its own percentage (progressive fill-a-tier), applied to the prices this adjustment covers in a given billing period.
47 48 49 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 47 def tiers @tiers end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 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 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 100 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil is_invoice_level = hash.key?('is_invoice_level') ? hash['is_invoice_level'] : nil # 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 = nil unless hash.key?('filters') applies_to_price_ids = hash.key?('applies_to_price_ids') ? hash['applies_to_price_ids'] : nil reason = hash.key?('reason') ? hash['reason'] : nil replaces_adjustment_id = hash.key?('replaces_adjustment_id') ? hash['replaces_adjustment_id'] : nil # Parameter is an array, so we need to iterate through it tiers = nil unless hash['tiers'].nil? tiers = [] hash['tiers'].each do |structure| tiers << (PercentageTier.from_hash(structure) if structure) end end tiers = nil unless hash.key?('tiers') amount = hash.key?('amount') ? hash['amount'] : nil # 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. MonetaryTieredPercentageDiscountAdjustment.new(id: id, is_invoice_level: is_invoice_level, filters: filters, applies_to_price_ids: applies_to_price_ids, reason: reason, replaces_adjustment_id: replaces_adjustment_id, tiers: tiers, amount: amount, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 54 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['is_invoice_level'] = 'is_invoice_level' @_hash['filters'] = 'filters' @_hash['applies_to_price_ids'] = 'applies_to_price_ids' @_hash['reason'] = 'reason' @_hash['replaces_adjustment_id'] = 'replaces_adjustment_id' @_hash['adjustment_type'] = 'adjustment_type' @_hash['tiers'] = 'tiers' @_hash['amount'] = 'amount' @_hash end |
.nullables ⇒ Object
An array for nullable fields
74 75 76 77 78 79 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 74 def self.nullables %w[ reason replaces_adjustment_id ] end |
.optionals ⇒ Object
An array for optional fields
69 70 71 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 69 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 155 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.is_invoice_level, ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value.filters, ->(val) { PriceFilter.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.applies_to_price_ids, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.reason, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.replaces_adjustment_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.adjustment_type, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.tiers, ->(val) { PercentageTier.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.amount, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['is_invoice_level'], ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value['filters'], ->(val) { PriceFilter.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['applies_to_price_ids'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['reason'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['replaces_adjustment_id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['adjustment_type'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['tiers'], ->(val) { PercentageTier.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['amount'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
221 222 223 224 225 226 227 228 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 221 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, is_invoice_level: #{@is_invoice_level.inspect},"\ " filters: #{@filters.inspect}, applies_to_price_ids: #{@applies_to_price_ids.inspect},"\ " reason: #{@reason.inspect}, replaces_adjustment_id: #{@replaces_adjustment_id.inspect},"\ " adjustment_type: #{@adjustment_type.inspect}, tiers: #{@tiers.inspect}, amount:"\ " #{@amount.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
212 213 214 215 216 217 218 |
# File 'lib/api_reference/models/monetary_tiered_percentage_discount_adjustment.rb', line 212 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, is_invoice_level: #{@is_invoice_level}, filters: #{@filters},"\ " applies_to_price_ids: #{@applies_to_price_ids}, reason: #{@reason},"\ " replaces_adjustment_id: #{@replaces_adjustment_id}, adjustment_type: #{@adjustment_type},"\ " tiers: #{@tiers}, amount: #{@amount}, additional_properties: #{@additional_properties}>" end |