Class: PostfinancecheckoutRubySdk::LineItem
- Inherits:
-
Object
- Object
- PostfinancecheckoutRubySdk::LineItem
- Defined in:
- lib/postfinancecheckout-ruby-sdk/models/line_item.rb
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#aggregated_tax_rate ⇒ Object
The total tax rate applied to the item, calculated from the rates of all tax lines.
-
#amount_excluding_tax ⇒ Object
The line item price with discounts applied, excluding taxes.
-
#amount_including_tax ⇒ Object
The line item price with discounts applied, including taxes.
-
#attributes ⇒ Object
A map of custom information for the item.
-
#discount_excluding_tax ⇒ Object
The discount allocated to the item, excluding taxes.
-
#discount_including_tax ⇒ Object
The discount allocated to the item, including taxes.
-
#name ⇒ Object
The name of the product, ideally in the customer’s language.
-
#quantity ⇒ Object
The number of items that were purchased.
-
#shipping_required ⇒ Object
Whether the item required shipping.
-
#sku ⇒ Object
The SKU (stock-keeping unit) of the product.
-
#tax_amount ⇒ Object
The sum of all taxes applied to the item.
-
#tax_amount_per_unit ⇒ Object
The calculated tax amount per unit.
-
#taxes ⇒ Object
A set of tax lines, each of which specifies a tax applied to the item.
-
#type ⇒ Object
Returns the value of attribute type.
-
#undiscounted_amount_excluding_tax ⇒ Object
The line item price with discounts not applied, excluding taxes.
-
#undiscounted_amount_including_tax ⇒ Object
The line item price with discounts not applied, including taxes.
-
#undiscounted_unit_price_excluding_tax ⇒ Object
The calculated price per unit with discounts not applied, excluding taxes.
-
#undiscounted_unit_price_including_tax ⇒ Object
The calculated price per unit with discounts not applied, including taxes.
-
#unique_id ⇒ Object
The unique identifier of the line item within the set of line items.
-
#unit_price_excluding_tax ⇒ Object
The calculated price per unit with discounts applied, excluding taxes.
-
#unit_price_including_tax ⇒ Object
The calculated price per unit with discounts applied, including taxes.
Class Method Summary collapse
-
._deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Returns the model itself.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ LineItem
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ LineItem
Initializes the object
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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 177 def initialize(attributes = {}) unless attributes.is_a?(Hash) fail ArgumentError, "The input argument (attributes) must be a hash in `PostfinancecheckoutRubySdk::LineItem` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| unless self.class.attribute_map.key?(k.to_sym) fail ArgumentError, "`#{k}` is not a valid attribute in `PostfinancecheckoutRubySdk::LineItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'tax_amount_per_unit') self.tax_amount_per_unit = attributes[:'tax_amount_per_unit'] end if attributes.key?(:'undiscounted_amount_excluding_tax') self.undiscounted_amount_excluding_tax = attributes[:'undiscounted_amount_excluding_tax'] end if attributes.key?(:'quantity') self.quantity = attributes[:'quantity'] end if attributes.key?(:'undiscounted_unit_price_including_tax') self.undiscounted_unit_price_including_tax = attributes[:'undiscounted_unit_price_including_tax'] end if attributes.key?(:'amount_excluding_tax') self.amount_excluding_tax = attributes[:'amount_excluding_tax'] end if attributes.key?(:'undiscounted_amount_including_tax') self.undiscounted_amount_including_tax = attributes[:'undiscounted_amount_including_tax'] end if attributes.key?(:'taxes') if (value = attributes[:'taxes']).is_a?(Array) self.taxes = value end end if attributes.key?(:'type') self.type = attributes[:'type'] end if attributes.key?(:'unit_price_including_tax') self.unit_price_including_tax = attributes[:'unit_price_including_tax'] end if attributes.key?(:'discount_excluding_tax') self.discount_excluding_tax = attributes[:'discount_excluding_tax'] end if attributes.key?(:'shipping_required') self.shipping_required = attributes[:'shipping_required'] end if attributes.key?(:'unit_price_excluding_tax') self.unit_price_excluding_tax = attributes[:'unit_price_excluding_tax'] end if attributes.key?(:'name') self.name = attributes[:'name'] end if attributes.key?(:'attributes') if (value = attributes[:'attributes']).is_a?(Hash) self.attributes = value end end if attributes.key?(:'undiscounted_unit_price_excluding_tax') self.undiscounted_unit_price_excluding_tax = attributes[:'undiscounted_unit_price_excluding_tax'] end if attributes.key?(:'amount_including_tax') self.amount_including_tax = attributes[:'amount_including_tax'] end if attributes.key?(:'discount_including_tax') self.discount_including_tax = attributes[:'discount_including_tax'] end if attributes.key?(:'sku') self.sku = attributes[:'sku'] end if attributes.key?(:'tax_amount') self.tax_amount = attributes[:'tax_amount'] end if attributes.key?(:'aggregated_tax_rate') self.aggregated_tax_rate = attributes[:'aggregated_tax_rate'] end if attributes.key?(:'unique_id') self.unique_id = attributes[:'unique_id'] end end |
Instance Attribute Details
#aggregated_tax_rate ⇒ Object
The total tax rate applied to the item, calculated from the rates of all tax lines.
83 84 85 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 83 def aggregated_tax_rate @aggregated_tax_rate end |
#amount_excluding_tax ⇒ Object
The line item price with discounts applied, excluding taxes.
39 40 41 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 39 def amount_excluding_tax @amount_excluding_tax end |
#amount_including_tax ⇒ Object
The line item price with discounts applied, including taxes.
71 72 73 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 71 def amount_including_tax @amount_including_tax end |
#attributes ⇒ Object
A map of custom information for the item.
65 66 67 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 65 def attributes @attributes end |
#discount_excluding_tax ⇒ Object
The discount allocated to the item, excluding taxes.
53 54 55 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 53 def discount_excluding_tax @discount_excluding_tax end |
#discount_including_tax ⇒ Object
The discount allocated to the item, including taxes.
74 75 76 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 74 def discount_including_tax @discount_including_tax end |
#name ⇒ Object
The name of the product, ideally in the customer’s language.
62 63 64 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 62 def name @name end |
#quantity ⇒ Object
The number of items that were purchased.
33 34 35 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 33 def quantity @quantity end |
#shipping_required ⇒ Object
Whether the item required shipping.
56 57 58 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 56 def shipping_required @shipping_required end |
#sku ⇒ Object
The SKU (stock-keeping unit) of the product.
77 78 79 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 77 def sku @sku end |
#tax_amount ⇒ Object
The sum of all taxes applied to the item.
80 81 82 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 80 def tax_amount @tax_amount end |
#tax_amount_per_unit ⇒ Object
The calculated tax amount per unit.
27 28 29 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 27 def tax_amount_per_unit @tax_amount_per_unit end |
#taxes ⇒ Object
A set of tax lines, each of which specifies a tax applied to the item.
45 46 47 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 45 def taxes @taxes end |
#type ⇒ Object
Returns the value of attribute type.
47 48 49 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 47 def type @type end |
#undiscounted_amount_excluding_tax ⇒ Object
The line item price with discounts not applied, excluding taxes.
30 31 32 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 30 def undiscounted_amount_excluding_tax @undiscounted_amount_excluding_tax end |
#undiscounted_amount_including_tax ⇒ Object
The line item price with discounts not applied, including taxes.
42 43 44 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 42 def undiscounted_amount_including_tax @undiscounted_amount_including_tax end |
#undiscounted_unit_price_excluding_tax ⇒ Object
The calculated price per unit with discounts not applied, excluding taxes.
68 69 70 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 68 def undiscounted_unit_price_excluding_tax @undiscounted_unit_price_excluding_tax end |
#undiscounted_unit_price_including_tax ⇒ Object
The calculated price per unit with discounts not applied, including taxes.
36 37 38 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 36 def undiscounted_unit_price_including_tax @undiscounted_unit_price_including_tax end |
#unique_id ⇒ Object
The unique identifier of the line item within the set of line items.
86 87 88 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 86 def unique_id @unique_id end |
#unit_price_excluding_tax ⇒ Object
The calculated price per unit with discounts applied, excluding taxes.
59 60 61 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 59 def unit_price_excluding_tax @unit_price_excluding_tax end |
#unit_price_including_tax ⇒ Object
The calculated price per unit with discounts applied, including taxes.
50 51 52 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 50 def unit_price_including_tax @unit_price_including_tax end |
Class Method Details
._deserialize(type, value) ⇒ Object
Deserializes the data based on type
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 435 def self._deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = PostfinancecheckoutRubySdk.const_get(type) klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
138 139 140 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 138 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
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 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 111 def self.attribute_map { :'tax_amount_per_unit' => :'taxAmountPerUnit', :'undiscounted_amount_excluding_tax' => :'undiscountedAmountExcludingTax', :'quantity' => :'quantity', :'undiscounted_unit_price_including_tax' => :'undiscountedUnitPriceIncludingTax', :'amount_excluding_tax' => :'amountExcludingTax', :'undiscounted_amount_including_tax' => :'undiscountedAmountIncludingTax', :'taxes' => :'taxes', :'type' => :'type', :'unit_price_including_tax' => :'unitPriceIncludingTax', :'discount_excluding_tax' => :'discountExcludingTax', :'shipping_required' => :'shippingRequired', :'unit_price_excluding_tax' => :'unitPriceExcludingTax', :'name' => :'name', :'attributes' => :'attributes', :'undiscounted_unit_price_excluding_tax' => :'undiscountedUnitPriceExcludingTax', :'amount_including_tax' => :'amountIncludingTax', :'discount_including_tax' => :'discountIncludingTax', :'sku' => :'sku', :'tax_amount' => :'taxAmount', :'aggregated_tax_rate' => :'aggregatedTaxRate', :'unique_id' => :'uniqueId' } end |
.build_from_hash(attributes) ⇒ Object
Returns the model itself
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 411 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
170 171 172 173 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 170 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 143 def self.openapi_types { :'tax_amount_per_unit' => :'Float', :'undiscounted_amount_excluding_tax' => :'Float', :'quantity' => :'Float', :'undiscounted_unit_price_including_tax' => :'Float', :'amount_excluding_tax' => :'Float', :'undiscounted_amount_including_tax' => :'Float', :'taxes' => :'Array<Tax>', :'type' => :'LineItemType', :'unit_price_including_tax' => :'Float', :'discount_excluding_tax' => :'Float', :'shipping_required' => :'Boolean', :'unit_price_excluding_tax' => :'Float', :'name' => :'String', :'attributes' => :'Hash<String, LineItemAttribute>', :'undiscounted_unit_price_excluding_tax' => :'Float', :'amount_including_tax' => :'Float', :'discount_including_tax' => :'Float', :'sku' => :'String', :'tax_amount' => :'Float', :'aggregated_tax_rate' => :'Float', :'unique_id' => :'String' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 372 def ==(o) return true if self.equal?(o) self.class == o.class && tax_amount_per_unit == o.tax_amount_per_unit && undiscounted_amount_excluding_tax == o.undiscounted_amount_excluding_tax && quantity == o.quantity && undiscounted_unit_price_including_tax == o.undiscounted_unit_price_including_tax && amount_excluding_tax == o.amount_excluding_tax && undiscounted_amount_including_tax == o.undiscounted_amount_including_tax && taxes == o.taxes && type == o.type && unit_price_including_tax == o.unit_price_including_tax && discount_excluding_tax == o.discount_excluding_tax && shipping_required == o.shipping_required && unit_price_excluding_tax == o.unit_price_excluding_tax && name == o.name && attributes == o.attributes && undiscounted_unit_price_excluding_tax == o.undiscounted_unit_price_excluding_tax && amount_including_tax == o.amount_including_tax && discount_including_tax == o.discount_including_tax && sku == o.sku && tax_amount == o.tax_amount && aggregated_tax_rate == o.aggregated_tax_rate && unique_id == o.unique_id end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 506 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#eql?(o) ⇒ Boolean
400 401 402 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 400 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
406 407 408 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 406 def hash [tax_amount_per_unit, undiscounted_amount_excluding_tax, quantity, undiscounted_unit_price_including_tax, amount_excluding_tax, undiscounted_amount_including_tax, taxes, type, unit_price_including_tax, discount_excluding_tax, shipping_required, unit_price_excluding_tax, name, attributes, undiscounted_unit_price_excluding_tax, amount_including_tax, discount_including_tax, sku, tax_amount, aggregated_tax_rate, unique_id].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 281 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if !@name.nil? && @name.to_s.length > 150 invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 150.') end if !@name.nil? && @name.to_s.length < 1 invalid_properties.push('invalid value for "name", the character length must be greater than or equal to 1.') end if !@sku.nil? && @sku.to_s.length > 200 invalid_properties.push('invalid value for "sku", the character length must be smaller than or equal to 200.') end if !@unique_id.nil? && @unique_id.to_s.length > 200 invalid_properties.push('invalid value for "unique_id", the character length must be smaller than or equal to 200.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
482 483 484 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 482 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 488 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
476 477 478 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 476 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
305 306 307 308 309 310 311 312 |
# File 'lib/postfinancecheckout-ruby-sdk/models/line_item.rb', line 305 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if !@name.nil? && @name.to_s.length > 150 return false if !@name.nil? && @name.to_s.length < 1 return false if !@sku.nil? && @sku.to_s.length > 200 return false if !@unique_id.nil? && @unique_id.to_s.length > 200 true end |