Class: WalmartApIs::SettlementTransaction

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/walmart_ap_is/models/settlement_transaction.rb

Overview

SettlementTransaction 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(purchase_order_id: SKIP, transaction_type: SKIP, amount: SKIP, posted_date: SKIP, additional_properties: nil) ⇒ SettlementTransaction

Returns a new instance of SettlementTransaction.



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

def initialize(purchase_order_id: SKIP, transaction_type: SKIP,
               amount: SKIP, posted_date: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @purchase_order_id = purchase_order_id unless purchase_order_id == SKIP
  @transaction_type = transaction_type unless transaction_type == SKIP
  @amount = amount unless amount == SKIP
  @posted_date = posted_date unless posted_date == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountMoney

TODO: Write general description for this method

Returns:



23
24
25
# File 'lib/walmart_ap_is/models/settlement_transaction.rb', line 23

def amount
  @amount
end

#posted_dateDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


27
28
29
# File 'lib/walmart_ap_is/models/settlement_transaction.rb', line 27

def posted_date
  @posted_date
end

#purchase_order_idString

TODO: Write general description for this method

Returns:

  • (String)


15
16
17
# File 'lib/walmart_ap_is/models/settlement_transaction.rb', line 15

def purchase_order_id
  @purchase_order_id
end

#transaction_typeString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/walmart_ap_is/models/settlement_transaction.rb', line 19

def transaction_type
  @transaction_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



67
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
93
94
95
# File 'lib/walmart_ap_is/models/settlement_transaction.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  purchase_order_id =
    hash.key?('purchaseOrderId') ? hash['purchaseOrderId'] : SKIP
  transaction_type =
    hash.key?('transactionType') ? hash['transactionType'] : SKIP
  amount = Money.from_hash(hash['amount']) if hash['amount']
  posted_date = if hash.key?('postedDate')
                  (DateTimeHelper.from_rfc3339(hash['postedDate']) if hash['postedDate'])
                else
                  SKIP
                end

  # 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.
  SettlementTransaction.new(purchase_order_id: purchase_order_id,
                            transaction_type: transaction_type,
                            amount: amount,
                            posted_date: posted_date,
                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/walmart_ap_is/models/settlement_transaction.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['purchase_order_id'] = 'purchaseOrderId'
  @_hash['transaction_type'] = 'transactionType'
  @_hash['amount'] = 'amount'
  @_hash['posted_date'] = 'postedDate'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/walmart_ap_is/models/settlement_transaction.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
46
47
# File 'lib/walmart_ap_is/models/settlement_transaction.rb', line 40

def self.optionals
  %w[
    purchase_order_id
    transaction_type
    amount
    posted_date
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



110
111
112
113
114
115
# File 'lib/walmart_ap_is/models/settlement_transaction.rb', line 110

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

#to_custom_posted_dateObject



97
98
99
# File 'lib/walmart_ap_is/models/settlement_transaction.rb', line 97

def to_custom_posted_date
  DateTimeHelper.to_rfc3339(posted_date)
end

#to_sObject

Provides a human-readable string representation of the object.



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

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