Class: LoyaltyApIs::SaleItem
- Defined in:
- lib/loyalty_ap_is/models/sale_item.rb
Overview
SaleItem Model.
Instance Attribute Summary collapse
-
#amount ⇒ Float
Total amount.
-
#description ⇒ String
Description - currently not in use.
-
#detail_type ⇒ TransactionDetailType
Indicates the Type of the transaction detail row (award, redemption, transfer, voucher, refund or central award).
-
#discount_amount ⇒ Float
Discount amount of sales line.
-
#ev ⇒ EvChargingDetails
Unit of measure.
-
#offer_infos ⇒ Array[OfferInfo]
Discount amount of sales line.
-
#offer_lang ⇒ OfferLanguage
Discount amount of sales line.
-
#original_amount ⇒ Float
Original amount of sales line.
-
#original_net_amount ⇒ Float
Original amount excluding VAT.
-
#points ⇒ Integer
Points earned in a transaction.
-
#product_data ⇒ SaleItemProduct
Original amount excluding VAT.
-
#quantity ⇒ Float
Quantity of product.
-
#unit_measure ⇒ UnitMeasure
Unit of measure.
-
#unit_price ⇒ Float
Unit price of sale item.
-
#vat_amount ⇒ Float
Value added tax.
-
#vat_rate ⇒ Float
VAT rate of sales line.
-
#voucher_items ⇒ Array[VoucherItem]
VAT rate of sales line.
-
#vouchers ⇒ Array[String]
List of vouchers.
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.
Instance Method Summary collapse
-
#initialize(amount:, detail_type:, discount_amount:, offer_infos:, original_amount:, product_data:, quantity:, description: SKIP, offer_lang: SKIP, original_net_amount: SKIP, vat_amount: SKIP, vat_rate: SKIP, voucher_items: SKIP, vouchers: SKIP, unit_price: SKIP, unit_measure: SKIP, ev: SKIP, points: SKIP, additional_properties: nil) ⇒ SaleItem
constructor
A new instance of SaleItem.
-
#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(amount:, detail_type:, discount_amount:, offer_infos:, original_amount:, product_data:, quantity:, description: SKIP, offer_lang: SKIP, original_net_amount: SKIP, vat_amount: SKIP, vat_rate: SKIP, voucher_items: SKIP, vouchers: SKIP, unit_price: SKIP, unit_measure: SKIP, ev: SKIP, points: SKIP, additional_properties: nil) ⇒ SaleItem
Returns a new instance of SaleItem.
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 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 131 def initialize(amount:, detail_type:, discount_amount:, offer_infos:, original_amount:, product_data:, quantity:, description: SKIP, offer_lang: SKIP, original_net_amount: SKIP, vat_amount: SKIP, vat_rate: SKIP, voucher_items: SKIP, vouchers: SKIP, unit_price: SKIP, unit_measure: SKIP, ev: SKIP, points: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @description = description unless description == SKIP @amount = amount @detail_type = detail_type @discount_amount = discount_amount @offer_infos = offer_infos @offer_lang = offer_lang unless offer_lang == SKIP @original_amount = original_amount @original_net_amount = original_net_amount unless original_net_amount == SKIP @product_data = product_data @quantity = quantity @vat_amount = vat_amount unless vat_amount == SKIP @vat_rate = vat_rate unless vat_rate == SKIP @voucher_items = voucher_items unless voucher_items == SKIP @vouchers = vouchers unless vouchers == SKIP @unit_price = unit_price unless unit_price == SKIP @unit_measure = unit_measure unless unit_measure == SKIP @ev = ev unless ev == SKIP @points = points unless points == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ Float
Total amount
18 19 20 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 18 def amount @amount end |
#description ⇒ String
Description - currently not in use
14 15 16 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 14 def description @description end |
#detail_type ⇒ TransactionDetailType
Indicates the Type of the transaction detail row (award, redemption, transfer, voucher, refund or central award).
23 24 25 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 23 def detail_type @detail_type end |
#discount_amount ⇒ Float
Discount amount of sales line
27 28 29 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 27 def discount_amount @discount_amount end |
#ev ⇒ EvChargingDetails
Unit of measure
79 80 81 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 79 def ev @ev end |
#offer_infos ⇒ Array[OfferInfo]
Discount amount of sales line
31 32 33 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 31 def offer_infos @offer_infos end |
#offer_lang ⇒ OfferLanguage
Discount amount of sales line
35 36 37 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 35 def offer_lang @offer_lang end |
#original_amount ⇒ Float
Original amount of sales line
39 40 41 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 39 def original_amount @original_amount end |
#original_net_amount ⇒ Float
Original amount excluding VAT
43 44 45 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 43 def original_net_amount @original_net_amount end |
#points ⇒ Integer
Points earned in a transaction
83 84 85 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 83 def points @points end |
#product_data ⇒ SaleItemProduct
Original amount excluding VAT
47 48 49 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 47 def product_data @product_data end |
#quantity ⇒ Float
Quantity of product
51 52 53 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 51 def quantity @quantity end |
#unit_measure ⇒ UnitMeasure
Unit of measure
75 76 77 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 75 def unit_measure @unit_measure end |
#unit_price ⇒ Float
Unit price of sale item
71 72 73 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 71 def unit_price @unit_price end |
#vat_amount ⇒ Float
Value added tax
55 56 57 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 55 def vat_amount @vat_amount end |
#vat_rate ⇒ Float
VAT rate of sales line
59 60 61 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 59 def vat_rate @vat_rate end |
#voucher_items ⇒ Array[VoucherItem]
VAT rate of sales line
63 64 65 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 63 def voucher_items @voucher_items end |
#vouchers ⇒ Array[String]
List of vouchers
67 68 69 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 67 def vouchers @vouchers end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 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 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 163 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = hash.key?('amount') ? hash['amount'] : nil detail_type = hash.key?('detailType') ? hash['detailType'] : nil discount_amount = hash.key?('discountAmount') ? hash['discountAmount'] : nil # Parameter is an array, so we need to iterate through it offer_infos = nil unless hash['offerInfos'].nil? offer_infos = [] hash['offerInfos'].each do |structure| offer_infos << (OfferInfo.from_hash(structure) if structure) end end offer_infos = nil unless hash.key?('offerInfos') original_amount = hash.key?('originalAmount') ? hash['originalAmount'] : nil product_data = SaleItemProduct.from_hash(hash['productData']) if hash['productData'] quantity = hash.key?('quantity') ? hash['quantity'] : nil description = hash.key?('description') ? hash['description'] : SKIP offer_lang = OfferLanguage.from_hash(hash['offerLang']) if hash['offerLang'] original_net_amount = hash.key?('originalNetAmount') ? hash['originalNetAmount'] : SKIP vat_amount = hash.key?('vatAmount') ? hash['vatAmount'] : SKIP vat_rate = hash.key?('vatRate') ? hash['vatRate'] : SKIP # Parameter is an array, so we need to iterate through it voucher_items = nil unless hash['voucherItems'].nil? voucher_items = [] hash['voucherItems'].each do |structure| voucher_items << (VoucherItem.from_hash(structure) if structure) end end voucher_items = SKIP unless hash.key?('voucherItems') vouchers = hash.key?('vouchers') ? hash['vouchers'] : SKIP unit_price = hash.key?('unitPrice') ? hash['unitPrice'] : SKIP unit_measure = hash.key?('unitMeasure') ? hash['unitMeasure'] : SKIP ev = EvChargingDetails.from_hash(hash['EV']) if hash['EV'] points = hash.key?('points') ? hash['points'] : SKIP # 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. SaleItem.new(amount: amount, detail_type: detail_type, discount_amount: discount_amount, offer_infos: offer_infos, original_amount: original_amount, product_data: product_data, quantity: quantity, description: description, offer_lang: offer_lang, original_net_amount: original_net_amount, vat_amount: vat_amount, vat_rate: vat_rate, voucher_items: voucher_items, vouchers: vouchers, unit_price: unit_price, unit_measure: unit_measure, ev: ev, points: points, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 86 def self.names @_hash = {} if @_hash.nil? @_hash['description'] = 'description' @_hash['amount'] = 'amount' @_hash['detail_type'] = 'detailType' @_hash['discount_amount'] = 'discountAmount' @_hash['offer_infos'] = 'offerInfos' @_hash['offer_lang'] = 'offerLang' @_hash['original_amount'] = 'originalAmount' @_hash['original_net_amount'] = 'originalNetAmount' @_hash['product_data'] = 'productData' @_hash['quantity'] = 'quantity' @_hash['vat_amount'] = 'vatAmount' @_hash['vat_rate'] = 'vatRate' @_hash['voucher_items'] = 'voucherItems' @_hash['vouchers'] = 'vouchers' @_hash['unit_price'] = 'unitPrice' @_hash['unit_measure'] = 'unitMeasure' @_hash['ev'] = 'EV' @_hash['points'] = 'points' @_hash end |
.nullables ⇒ Object
An array for nullable fields
127 128 129 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 127 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 110 def self.optionals %w[ description offer_lang original_net_amount vat_amount vat_rate voucher_items vouchers unit_price unit_measure ev points ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 249 def inspect class_name = self.class.name.split('::').last "<#{class_name} description: #{@description.inspect}, amount: #{@amount.inspect},"\ " detail_type: #{@detail_type.inspect}, discount_amount: #{@discount_amount.inspect},"\ " offer_infos: #{@offer_infos.inspect}, offer_lang: #{@offer_lang.inspect}, original_amount:"\ " #{@original_amount.inspect}, original_net_amount: #{@original_net_amount.inspect},"\ " product_data: #{@product_data.inspect}, quantity: #{@quantity.inspect}, vat_amount:"\ " #{@vat_amount.inspect}, vat_rate: #{@vat_rate.inspect}, voucher_items:"\ " #{@voucher_items.inspect}, vouchers: #{@vouchers.inspect}, unit_price:"\ " #{@unit_price.inspect}, unit_measure: #{@unit_measure.inspect}, ev: #{@ev.inspect},"\ " points: #{@points.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
237 238 239 240 241 242 243 244 245 246 |
# File 'lib/loyalty_ap_is/models/sale_item.rb', line 237 def to_s class_name = self.class.name.split('::').last "<#{class_name} description: #{@description}, amount: #{@amount}, detail_type:"\ " #{@detail_type}, discount_amount: #{@discount_amount}, offer_infos: #{@offer_infos},"\ " offer_lang: #{@offer_lang}, original_amount: #{@original_amount}, original_net_amount:"\ " #{@original_net_amount}, product_data: #{@product_data}, quantity: #{@quantity},"\ " vat_amount: #{@vat_amount}, vat_rate: #{@vat_rate}, voucher_items: #{@voucher_items},"\ " vouchers: #{@vouchers}, unit_price: #{@unit_price}, unit_measure: #{@unit_measure}, ev:"\ " #{@ev}, points: #{@points}, additional_properties: #{@additional_properties}>" end |