Class: Zaala::API::DetailRecord

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/zaala/api/types.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_message(h) ⇒ Object



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/zaala/api/types.rb', line 292

def self.from_message(h)
  DetailRecord.new({
    quantity: h[:quantity],
    amount: h[:amount],
    vat_percent: h[:vatPercent],
    vat_amount: h[:vatAmount],
    amount_without_vat: h[:amountWithoutVat],
    product_text: h[:productText],
    product_id: h[:productId],
    product_category: h[:productCategory],
    rebate_percentage: h[:rebatePercentage],
    single_article_amount: h[:singleArticleAmount],
    single_article_amount_without_vat: h[:singleArticleAmountWithoutVat],
    type: h[:type],
    quantity_unit: h[:quantityUnit],
  })
end

Instance Method Details

#to_messageObject



310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/zaala/api/types.rb', line 310

def to_message
  m = {
    quantity: quantity,
    amount: amount,
    vatPercent: vat_percent,
    vatAmount: vat_amount,
    amountWithoutVat: amount_without_vat,
    productText: product_text
  }
  m[:productId] = product_id unless product_id.nil?
  m[:productCategory] = product_category unless product_category.nil?
  m[:rebatePercentage] = rebate_percentage unless rebate_percentage.nil?
  m[:singleArticleAmount] = single_article_amount unless single_article_amount.nil?
  m[:singleArticleAmountWithoutVat] = single_article_amount_without_vat unless single_article_amount_without_vat.nil?
  m[:type] = type unless type.nil?
  m[:quantityUnit] = quantity_unit unless quantity_unit.nil?
  m
end