Class: LoyaltyApIs::RedeemedItem
- Defined in:
- lib/loyalty_ap_is/models/redeemed_item.rb
Overview
RedeemedItem 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.
-
#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.
-
#points ⇒ Integer
Number of points redeemed.
-
#product_data ⇒ RedeemedItemProduct
Original amount of sales line.
-
#quantity ⇒ Float
Quantity of product.
-
#vat_amount ⇒ Float
Value added tax.
-
#vat_rate ⇒ Float
VAT rate of sales line.
-
#voucher_items ⇒ Array[VoucherItem]
List of vouchers.
-
#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, vat_amount: SKIP, vat_rate: SKIP, points: SKIP, vouchers: SKIP, voucher_items: SKIP, additional_properties: nil) ⇒ RedeemedItem
constructor
A new instance of RedeemedItem.
-
#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, vat_amount: SKIP, vat_rate: SKIP, points: SKIP, vouchers: SKIP, voucher_items: SKIP, additional_properties: nil) ⇒ RedeemedItem
Returns a new instance of RedeemedItem.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 108 def initialize(amount:, detail_type:, discount_amount:, offer_infos:, original_amount:, product_data:, quantity:, description: SKIP, offer_lang: SKIP, vat_amount: SKIP, vat_rate: SKIP, points: SKIP, vouchers: SKIP, voucher_items: 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 @product_data = product_data @quantity = quantity @vat_amount = vat_amount unless vat_amount == SKIP @vat_rate = vat_rate unless vat_rate == SKIP @points = points unless points == SKIP @vouchers = vouchers unless vouchers == SKIP @voucher_items = voucher_items unless voucher_items == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ Float
Total amount
18 19 20 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 18 def amount @amount end |
#description ⇒ String
Description - currently not in use
14 15 16 |
# File 'lib/loyalty_ap_is/models/redeemed_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/redeemed_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/redeemed_item.rb', line 27 def discount_amount @discount_amount end |
#offer_infos ⇒ Array[OfferInfo]
Discount amount of sales line
31 32 33 |
# File 'lib/loyalty_ap_is/models/redeemed_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/redeemed_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/redeemed_item.rb', line 39 def original_amount @original_amount end |
#points ⇒ Integer
Number of points redeemed. Applicable for redeemedItems and not for saleItems
60 61 62 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 60 def points @points end |
#product_data ⇒ RedeemedItemProduct
Original amount of sales line
43 44 45 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 43 def product_data @product_data end |
#quantity ⇒ Float
Quantity of product
47 48 49 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 47 def quantity @quantity end |
#vat_amount ⇒ Float
Value added tax
51 52 53 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 51 def vat_amount @vat_amount end |
#vat_rate ⇒ Float
VAT rate of sales line
55 56 57 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 55 def vat_rate @vat_rate end |
#voucher_items ⇒ Array[VoucherItem]
List of vouchers
68 69 70 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 68 def voucher_items @voucher_items end |
#vouchers ⇒ Array[String]
List of vouchers
64 65 66 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 64 def vouchers @vouchers end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 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 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 134 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 = RedeemedItemProduct.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'] vat_amount = hash.key?('vatAmount') ? hash['vatAmount'] : SKIP vat_rate = hash.key?('vatRate') ? hash['vatRate'] : SKIP points = hash.key?('points') ? hash['points'] : SKIP vouchers = hash.key?('vouchers') ? hash['vouchers'] : 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') # 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. RedeemedItem.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, vat_amount: vat_amount, vat_rate: vat_rate, points: points, vouchers: vouchers, voucher_items: voucher_items, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 71 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['product_data'] = 'productData' @_hash['quantity'] = 'quantity' @_hash['vat_amount'] = 'vatAmount' @_hash['vat_rate'] = 'vatRate' @_hash['points'] = 'points' @_hash['vouchers'] = 'vouchers' @_hash['voucher_items'] = 'voucherItems' @_hash end |
.nullables ⇒ Object
An array for nullable fields
104 105 106 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 104 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 91 def self.optionals %w[ description offer_lang vat_amount vat_rate points vouchers voucher_items ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
210 211 212 213 214 215 216 217 218 219 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 210 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}, product_data: #{@product_data.inspect}, quantity:"\ " #{@quantity.inspect}, vat_amount: #{@vat_amount.inspect}, vat_rate: #{@vat_rate.inspect},"\ " points: #{@points.inspect}, vouchers: #{@vouchers.inspect}, voucher_items:"\ " #{@voucher_items.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
199 200 201 202 203 204 205 206 207 |
# File 'lib/loyalty_ap_is/models/redeemed_item.rb', line 199 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}, product_data:"\ " #{@product_data}, quantity: #{@quantity}, vat_amount: #{@vat_amount}, vat_rate:"\ " #{@vat_rate}, points: #{@points}, vouchers: #{@vouchers}, voucher_items:"\ " #{@voucher_items}, additional_properties: #{@additional_properties}>" end |