Class: LoyaltyApIs::Transaction
- Defined in:
- lib/loyalty_ap_is/models/transaction.rb
Overview
Transaction Model.
Instance Attribute Summary collapse
-
#balances ⇒ Array[TransactionBalance]
Total amount of VAT.
-
#company_id ⇒ Integer
Partner identifier.
-
#currency_code ⇒ String
Currency using ISO4217 alpha-3 currency code.
-
#currency_data ⇒ CurrencyData
currencyData is only filled, where there is possible non-same currency cross-border transaction.
-
#is_partner_redemption ⇒ TrueClass | FalseClass
Describes whether the transaction is partner redemption.
-
#loyalty ⇒ LoyaltyCardInfo
Transaction date in JSON recommended format: “yyyy-MM-ddTHH:mm:ssZ”.
-
#partner_code ⇒ String
Unique code identifying the partner.
-
#partner_logo ⇒ String
Name of the partner.
-
#partner_name ⇒ String
Name of the partner.
-
#points_to_cash ⇒ PointsToCash
Unique number of transaction's receipt.
-
#receipt_number ⇒ String
Unique number of transaction's receipt.
-
#redeemed_items ⇒ Array[RedeemedItem]
Currency using ISO4217 alpha-3 currency code.
-
#reference_id ⇒ String
Reference ID for each transaction.
-
#sale_items ⇒ Array[SaleItem]
Currency using ISO4217 alpha-3 currency code.
-
#site_data ⇒ SiteData
Transaction date in JSON recommended format: “yyyy-MM-ddTHH:mm:ssZ”.
-
#total_amount ⇒ Float
Total amount of the transaction.
-
#total_discount_amount ⇒ Float
Total discount amount of the transaction.
-
#total_discounted_full_amount ⇒ Float
totalAmount - totalDiscountedFullAmount.
-
#total_vat_amount ⇒ Float
Total amount of VAT.
-
#transaction_date_time ⇒ Integer
Transaction date as Unix epoch (UTC), as requested by MobGen.
-
#transaction_date_time_stamp ⇒ DateTime
Transaction date in JSON recommended format: “yyyy-MM-ddTHH:mm:ssZ”.
-
#transaction_id ⇒ String
Unique Id of the transaction row.
-
#transaction_vouchers ⇒ Array[TransactionVoucher]
Currency using ISO4217 alpha-3 currency code.
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(transaction_date_time:, site_data:, loyalty:, total_amount:, total_discount_amount:, total_discounted_full_amount:, sale_items:, redeemed_items:, transaction_vouchers:, transaction_date_time_stamp: SKIP, transaction_id: SKIP, partner_code: SKIP, partner_name: SKIP, partner_logo: SKIP, reference_id: SKIP, total_vat_amount: SKIP, balances: SKIP, currency_code: SKIP, receipt_number: SKIP, points_to_cash: SKIP, company_id: SKIP, is_partner_redemption: SKIP, currency_data: SKIP, additional_properties: nil) ⇒ Transaction
constructor
A new instance of Transaction.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_transaction_date_time_stamp ⇒ Object
-
#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(transaction_date_time:, site_data:, loyalty:, total_amount:, total_discount_amount:, total_discounted_full_amount:, sale_items:, redeemed_items:, transaction_vouchers:, transaction_date_time_stamp: SKIP, transaction_id: SKIP, partner_code: SKIP, partner_name: SKIP, partner_logo: SKIP, reference_id: SKIP, total_vat_amount: SKIP, balances: SKIP, currency_code: SKIP, receipt_number: SKIP, points_to_cash: SKIP, company_id: SKIP, is_partner_redemption: SKIP, currency_data: SKIP, additional_properties: nil) ⇒ Transaction
Returns a new instance of Transaction.
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 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 161 def initialize(transaction_date_time:, site_data:, loyalty:, total_amount:, total_discount_amount:, total_discounted_full_amount:, sale_items:, redeemed_items:, transaction_vouchers:, transaction_date_time_stamp: SKIP, transaction_id: SKIP, partner_code: SKIP, partner_name: SKIP, partner_logo: SKIP, reference_id: SKIP, total_vat_amount: SKIP, balances: SKIP, currency_code: SKIP, receipt_number: SKIP, points_to_cash: SKIP, company_id: SKIP, is_partner_redemption: SKIP, currency_data: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @transaction_date_time = transaction_date_time unless transaction_date_time_stamp == SKIP @transaction_date_time_stamp = transaction_date_time_stamp end @site_data = site_data @loyalty = loyalty @transaction_id = transaction_id unless transaction_id == SKIP @partner_code = partner_code unless partner_code == SKIP @partner_name = partner_name unless partner_name == SKIP @partner_logo = partner_logo unless partner_logo == SKIP @reference_id = reference_id unless reference_id == SKIP @total_amount = total_amount @total_discount_amount = total_discount_amount @total_discounted_full_amount = total_discounted_full_amount @total_vat_amount = total_vat_amount unless total_vat_amount == SKIP @balances = balances unless balances == SKIP @currency_code = currency_code unless currency_code == SKIP @sale_items = sale_items @redeemed_items = redeemed_items @transaction_vouchers = transaction_vouchers @receipt_number = receipt_number unless receipt_number == SKIP @points_to_cash = points_to_cash unless points_to_cash == SKIP @company_id = company_id unless company_id == SKIP @is_partner_redemption = is_partner_redemption unless is_partner_redemption == SKIP @currency_data = currency_data unless currency_data == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#balances ⇒ Array[TransactionBalance]
Total amount of VAT
68 69 70 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 68 def balances @balances end |
#company_id ⇒ Integer
Partner identifier
96 97 98 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 96 def company_id @company_id end |
#currency_code ⇒ String
Currency using ISO4217 alpha-3 currency code
72 73 74 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 72 def currency_code @currency_code end |
#currency_data ⇒ CurrencyData
currencyData is only filled, where there is possible non-same currency cross-border transaction
105 106 107 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 105 def currency_data @currency_data end |
#is_partner_redemption ⇒ TrueClass | FalseClass
Describes whether the transaction is partner redemption.
100 101 102 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 100 def is_partner_redemption @is_partner_redemption end |
#loyalty ⇒ LoyaltyCardInfo
Transaction date in JSON recommended format: “yyyy-MM-ddTHH:mm:ssZ”
27 28 29 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 27 def loyalty @loyalty end |
#partner_code ⇒ String
Unique code identifying the partner
35 36 37 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 35 def partner_code @partner_code end |
#partner_logo ⇒ String
Name of the partner
43 44 45 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 43 def partner_logo @partner_logo end |
#partner_name ⇒ String
Name of the partner
39 40 41 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 39 def partner_name @partner_name end |
#points_to_cash ⇒ PointsToCash
Unique number of transaction's receipt
92 93 94 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 92 def points_to_cash @points_to_cash end |
#receipt_number ⇒ String
Unique number of transaction's receipt
88 89 90 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 88 def receipt_number @receipt_number end |
#redeemed_items ⇒ Array[RedeemedItem]
Currency using ISO4217 alpha-3 currency code
80 81 82 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 80 def redeemed_items @redeemed_items end |
#reference_id ⇒ String
Reference ID for each transaction. It is unique for each partner and transaction.
48 49 50 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 48 def reference_id @reference_id end |
#sale_items ⇒ Array[SaleItem]
Currency using ISO4217 alpha-3 currency code
76 77 78 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 76 def sale_items @sale_items end |
#site_data ⇒ SiteData
Transaction date in JSON recommended format: “yyyy-MM-ddTHH:mm:ssZ”
23 24 25 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 23 def site_data @site_data end |
#total_amount ⇒ Float
Total amount of the transaction.
52 53 54 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 52 def total_amount @total_amount end |
#total_discount_amount ⇒ Float
Total discount amount of the transaction.
56 57 58 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 56 def total_discount_amount @total_discount_amount end |
#total_discounted_full_amount ⇒ Float
totalAmount - totalDiscountedFullAmount
60 61 62 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 60 def total_discounted_full_amount @total_discounted_full_amount end |
#total_vat_amount ⇒ Float
Total amount of VAT
64 65 66 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 64 def total_vat_amount @total_vat_amount end |
#transaction_date_time ⇒ Integer
Transaction date as Unix epoch (UTC), as requested by MobGen.
15 16 17 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 15 def transaction_date_time @transaction_date_time end |
#transaction_date_time_stamp ⇒ DateTime
Transaction date in JSON recommended format: “yyyy-MM-ddTHH:mm:ssZ”
19 20 21 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 19 def transaction_date_time_stamp @transaction_date_time_stamp end |
#transaction_id ⇒ String
Unique Id of the transaction row.
31 32 33 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 31 def transaction_id @transaction_id end |
#transaction_vouchers ⇒ Array[TransactionVoucher]
Currency using ISO4217 alpha-3 currency code
84 85 86 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 84 def transaction_vouchers @transaction_vouchers end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 204 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. transaction_date_time = hash.key?('transactionDateTime') ? hash['transactionDateTime'] : nil site_data = SiteData.from_hash(hash['siteData']) if hash['siteData'] loyalty = LoyaltyCardInfo.from_hash(hash['loyalty']) if hash['loyalty'] total_amount = hash.key?('totalAmount') ? hash['totalAmount'] : nil total_discount_amount = hash.key?('totalDiscountAmount') ? hash['totalDiscountAmount'] : nil total_discounted_full_amount = hash.key?('totalDiscountedFullAmount') ? hash['totalDiscountedFullAmount'] : nil # Parameter is an array, so we need to iterate through it sale_items = nil unless hash['saleItems'].nil? sale_items = [] hash['saleItems'].each do |structure| sale_items << (SaleItem.from_hash(structure) if structure) end end sale_items = nil unless hash.key?('saleItems') # Parameter is an array, so we need to iterate through it redeemed_items = nil unless hash['redeemedItems'].nil? redeemed_items = [] hash['redeemedItems'].each do |structure| redeemed_items << (RedeemedItem.from_hash(structure) if structure) end end redeemed_items = nil unless hash.key?('redeemedItems') # Parameter is an array, so we need to iterate through it transaction_vouchers = nil unless hash['transactionVouchers'].nil? transaction_vouchers = [] hash['transactionVouchers'].each do |structure| transaction_vouchers << (TransactionVoucher.from_hash(structure) if structure) end end transaction_vouchers = nil unless hash.key?('transactionVouchers') transaction_date_time_stamp = if hash.key?('transactionDateTimeStamp') (DateTimeHelper.from_rfc3339(hash['transactionDateTimeStamp']) if hash['transactionDateTimeStamp']) else SKIP end transaction_id = hash.key?('transactionId') ? hash['transactionId'] : SKIP partner_code = hash.key?('partnerCode') ? hash['partnerCode'] : SKIP partner_name = hash.key?('partnerName') ? hash['partnerName'] : SKIP partner_logo = hash.key?('partnerLogo') ? hash['partnerLogo'] : SKIP reference_id = hash.key?('referenceId') ? hash['referenceId'] : SKIP total_vat_amount = hash.key?('totalVatAmount') ? hash['totalVatAmount'] : SKIP # Parameter is an array, so we need to iterate through it balances = nil unless hash['balances'].nil? balances = [] hash['balances'].each do |structure| balances << (TransactionBalance.from_hash(structure) if structure) end end balances = SKIP unless hash.key?('balances') currency_code = hash.key?('currencyCode') ? hash['currencyCode'] : SKIP receipt_number = hash.key?('receiptNumber') ? hash['receiptNumber'] : SKIP points_to_cash = PointsToCash.from_hash(hash['pointsToCash']) if hash['pointsToCash'] company_id = hash.key?('companyId') ? hash['companyId'] : SKIP is_partner_redemption = hash.key?('isPartnerRedemption') ? hash['isPartnerRedemption'] : SKIP currency_data = CurrencyData.from_hash(hash['currencyData']) if hash['currencyData'] # 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. Transaction.new(transaction_date_time: transaction_date_time, site_data: site_data, loyalty: loyalty, total_amount: total_amount, total_discount_amount: total_discount_amount, total_discounted_full_amount: total_discounted_full_amount, sale_items: sale_items, redeemed_items: redeemed_items, transaction_vouchers: transaction_vouchers, transaction_date_time_stamp: transaction_date_time_stamp, transaction_id: transaction_id, partner_code: partner_code, partner_name: partner_name, partner_logo: partner_logo, reference_id: reference_id, total_vat_amount: total_vat_amount, balances: balances, currency_code: currency_code, receipt_number: receipt_number, points_to_cash: points_to_cash, company_id: company_id, is_partner_redemption: is_partner_redemption, currency_data: currency_data, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
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 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 108 def self.names @_hash = {} if @_hash.nil? @_hash['transaction_date_time'] = 'transactionDateTime' @_hash['transaction_date_time_stamp'] = 'transactionDateTimeStamp' @_hash['site_data'] = 'siteData' @_hash['loyalty'] = 'loyalty' @_hash['transaction_id'] = 'transactionId' @_hash['partner_code'] = 'partnerCode' @_hash['partner_name'] = 'partnerName' @_hash['partner_logo'] = 'partnerLogo' @_hash['reference_id'] = 'referenceId' @_hash['total_amount'] = 'totalAmount' @_hash['total_discount_amount'] = 'totalDiscountAmount' @_hash['total_discounted_full_amount'] = 'totalDiscountedFullAmount' @_hash['total_vat_amount'] = 'totalVatAmount' @_hash['balances'] = 'balances' @_hash['currency_code'] = 'currencyCode' @_hash['sale_items'] = 'saleItems' @_hash['redeemed_items'] = 'redeemedItems' @_hash['transaction_vouchers'] = 'transactionVouchers' @_hash['receipt_number'] = 'receiptNumber' @_hash['points_to_cash'] = 'pointsToCash' @_hash['company_id'] = 'companyId' @_hash['is_partner_redemption'] = 'isPartnerRedemption' @_hash['currency_data'] = 'currencyData' @_hash end |
.nullables ⇒ Object
An array for nullable fields
157 158 159 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 157 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 137 def self.optionals %w[ transaction_date_time_stamp transaction_id partner_code partner_name partner_logo reference_id total_vat_amount balances currency_code receipt_number points_to_cash company_id is_partner_redemption currency_data ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 333 def inspect class_name = self.class.name.split('::').last "<#{class_name} transaction_date_time: #{@transaction_date_time.inspect},"\ " transaction_date_time_stamp: #{@transaction_date_time_stamp.inspect}, site_data:"\ " #{@site_data.inspect}, loyalty: #{@loyalty.inspect}, transaction_id:"\ " #{@transaction_id.inspect}, partner_code: #{@partner_code.inspect}, partner_name:"\ " #{@partner_name.inspect}, partner_logo: #{@partner_logo.inspect}, reference_id:"\ " #{@reference_id.inspect}, total_amount: #{@total_amount.inspect}, total_discount_amount:"\ " #{@total_discount_amount.inspect}, total_discounted_full_amount:"\ " #{@total_discounted_full_amount.inspect}, total_vat_amount: #{@total_vat_amount.inspect},"\ " balances: #{@balances.inspect}, currency_code: #{@currency_code.inspect}, sale_items:"\ " #{@sale_items.inspect}, redeemed_items: #{@redeemed_items.inspect}, transaction_vouchers:"\ " #{@transaction_vouchers.inspect}, receipt_number: #{@receipt_number.inspect},"\ " points_to_cash: #{@points_to_cash.inspect}, company_id: #{@company_id.inspect},"\ " is_partner_redemption: #{@is_partner_redemption.inspect}, currency_data:"\ " #{@currency_data.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_transaction_date_time_stamp ⇒ Object
311 312 313 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 311 def to_custom_transaction_date_time_stamp DateTimeHelper.to_rfc3339(transaction_date_time_stamp) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/loyalty_ap_is/models/transaction.rb', line 316 def to_s class_name = self.class.name.split('::').last "<#{class_name} transaction_date_time: #{@transaction_date_time},"\ " transaction_date_time_stamp: #{@transaction_date_time_stamp}, site_data: #{@site_data},"\ " loyalty: #{@loyalty}, transaction_id: #{@transaction_id}, partner_code: #{@partner_code},"\ " partner_name: #{@partner_name}, partner_logo: #{@partner_logo}, reference_id:"\ " #{@reference_id}, total_amount: #{@total_amount}, total_discount_amount:"\ " #{@total_discount_amount}, total_discounted_full_amount: #{@total_discounted_full_amount},"\ " total_vat_amount: #{@total_vat_amount}, balances: #{@balances}, currency_code:"\ " #{@currency_code}, sale_items: #{@sale_items}, redeemed_items: #{@redeemed_items},"\ " transaction_vouchers: #{@transaction_vouchers}, receipt_number: #{@receipt_number},"\ " points_to_cash: #{@points_to_cash}, company_id: #{@company_id}, is_partner_redemption:"\ " #{@is_partner_redemption}, currency_data: #{@currency_data}, additional_properties:"\ " #{@additional_properties}>" end |