Class: LoyaltyApIs::TransactionVoucher

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/loyalty_ap_is/models/transaction_voucher.rb

Overview

TransactionVoucher Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(detail_type:, code:, name:, amount:, quantity:, additional_properties: nil) ⇒ TransactionVoucher

Returns a new instance of TransactionVoucher.



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 54

def initialize(detail_type:, code:, name:, amount:, quantity:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @detail_type = detail_type
  @code = code
  @name = name
  @amount = amount
  @quantity = quantity
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountFloat

Sum amount of the voucher

Returns:

  • (Float)


27
28
29
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 27

def amount
  @amount
end

#codeString

Unique code of the voucher

Returns:

  • (String)


19
20
21
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 19

def code
  @code
end

#detail_typeTransactionDetailType

Indicates the Type of the transaction detail row (award, redemption, transfer, voucher, refund or central award).



15
16
17
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 15

def detail_type
  @detail_type
end

#nameString

Name of the voucher

Returns:

  • (String)


23
24
25
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 23

def name
  @name
end

#quantityFloat

Quantity of vouchers

Returns:

  • (Float)


31
32
33
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 31

def quantity
  @quantity
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 68

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  detail_type = hash.key?('detailType') ? hash['detailType'] : nil
  code = hash.key?('code') ? hash['code'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  amount = hash.key?('amount') ? hash['amount'] : nil
  quantity = hash.key?('quantity') ? hash['quantity'] : nil

  # 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.
  TransactionVoucher.new(detail_type: detail_type,
                         code: code,
                         name: name,
                         amount: amount,
                         quantity: quantity,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['detail_type'] = 'detailType'
  @_hash['code'] = 'code'
  @_hash['name'] = 'name'
  @_hash['amount'] = 'amount'
  @_hash['quantity'] = 'quantity'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 45

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



102
103
104
105
106
107
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 102

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} detail_type: #{@detail_type.inspect}, code: #{@code.inspect}, name:"\
  " #{@name.inspect}, amount: #{@amount.inspect}, quantity: #{@quantity.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



95
96
97
98
99
# File 'lib/loyalty_ap_is/models/transaction_voucher.rb', line 95

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} detail_type: #{@detail_type}, code: #{@code}, name: #{@name}, amount:"\
  " #{@amount}, quantity: #{@quantity}, additional_properties: #{@additional_properties}>"
end