Class: Batches::TransactionBatchResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/batches/models/transaction_batch_response.rb

Overview

TransactionBatchResponse 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(total_record_count: SKIP, batch_transaction_count: SKIP, merchant_id: SKIP, merchant_name: SKIP, account_id: SKIP, account_name: SKIP, site_reference: SKIP, device_reference: SKIP, filter: SKIP, transactions: SKIP, action: SKIP, additional_properties: nil) ⇒ TransactionBatchResponse

Returns a new instance of TransactionBatchResponse.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/batches/models/transaction_batch_response.rb', line 101

def initialize(total_record_count: SKIP, batch_transaction_count: SKIP,
               merchant_id: SKIP, merchant_name: SKIP, account_id: SKIP,
               account_name: SKIP, site_reference: SKIP,
               device_reference: SKIP, filter: SKIP, transactions: SKIP,
               action: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @total_record_count = total_record_count unless total_record_count == SKIP
  @batch_transaction_count = batch_transaction_count unless batch_transaction_count == SKIP
  @merchant_id = merchant_id unless merchant_id == SKIP
  @merchant_name = merchant_name unless merchant_name == SKIP
  @account_id =  unless  == SKIP
  @account_name =  unless  == SKIP
  @site_reference = site_reference unless site_reference == SKIP
  @device_reference = device_reference unless device_reference == SKIP
  @filter = filter unless filter == SKIP
  @transactions = transactions unless transactions == SKIP
  @action = action unless action == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_idString

A unique identifier that is used to identify and reference an instance of this resource. This id is used when actioning or referencing a specific account. Begins with the three letters, TRA.

Returns:

  • (String)


36
37
38
# File 'lib/batches/models/transaction_batch_response.rb', line 36

def 
  @account_id
end

#account_nameString

A meaningful label that better identifies the account.

Returns:

  • (String)


40
41
42
# File 'lib/batches/models/transaction_batch_response.rb', line 40

def 
  @account_name
end

#actionAction

A reference for the device that created the batch

Returns:



60
61
62
# File 'lib/batches/models/transaction_batch_response.rb', line 60

def action
  @action
end

#batch_transaction_countFloat

The number of transactions in the batch.

Returns:

  • (Float)


20
21
22
# File 'lib/batches/models/transaction_batch_response.rb', line 20

def batch_transaction_count
  @batch_transaction_count
end

#device_referenceString

A reference for the device that created the batch

Returns:

  • (String)


48
49
50
# File 'lib/batches/models/transaction_batch_response.rb', line 48

def device_reference
  @device_reference
end

#filterFilter

A reference for the device that created the batch

Returns:



52
53
54
# File 'lib/batches/models/transaction_batch_response.rb', line 52

def filter
  @filter
end

#merchant_idString

A unique identifier that is used to identify and reference an instance of this resource. This id is used when actioning or referencing a specific merchant. Begins with the three letters, MER.

Returns:

  • (String)


26
27
28
# File 'lib/batches/models/transaction_batch_response.rb', line 26

def merchant_id
  @merchant_id
end

#merchant_nameString

A meaningful label that better identifies the merchant.

Returns:

  • (String)


30
31
32
# File 'lib/batches/models/transaction_batch_response.rb', line 30

def merchant_name
  @merchant_name
end

#site_referenceString

A reference for the location that created the batch.

Returns:

  • (String)


44
45
46
# File 'lib/batches/models/transaction_batch_response.rb', line 44

def site_reference
  @site_reference
end

#total_record_countFloat

The total number of records across all pages for the search filter. When searching for a collection of resoures, this is returned on the first page only and when the date range is a month or less.

Returns:

  • (Float)


16
17
18
# File 'lib/batches/models/transaction_batch_response.rb', line 16

def total_record_count
  @total_record_count
end

#transactionsArray[Transaction]

A reference for the device that created the batch

Returns:



56
57
58
# File 'lib/batches/models/transaction_batch_response.rb', line 56

def transactions
  @transactions
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



124
125
126
127
128
129
130
131
132
133
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
# File 'lib/batches/models/transaction_batch_response.rb', line 124

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  total_record_count =
    hash.key?('total_record_count') ? hash['total_record_count'] : SKIP
  batch_transaction_count =
    hash.key?('batch_transaction_count') ? hash['batch_transaction_count'] : SKIP
  merchant_id = hash.key?('merchant_id') ? hash['merchant_id'] : SKIP
  merchant_name = hash.key?('merchant_name') ? hash['merchant_name'] : SKIP
   = hash.key?('account_id') ? hash['account_id'] : SKIP
   = hash.key?('account_name') ? hash['account_name'] : SKIP
  site_reference =
    hash.key?('site_reference') ? hash['site_reference'] : SKIP
  device_reference =
    hash.key?('device_reference') ? hash['device_reference'] : SKIP
  filter = Filter.from_hash(hash['filter']) if hash['filter']
  # Parameter is an array, so we need to iterate through it
  transactions = nil
  unless hash['transactions'].nil?
    transactions = []
    hash['transactions'].each do |structure|
      transactions << (Transaction.from_hash(structure) if structure)
    end
  end

  transactions = SKIP unless hash.key?('transactions')
  action = Action.from_hash(hash['action']) if hash['action']

  # 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.
  TransactionBatchResponse.new(total_record_count: total_record_count,
                               batch_transaction_count: batch_transaction_count,
                               merchant_id: merchant_id,
                               merchant_name: merchant_name,
                               account_id: ,
                               account_name: ,
                               site_reference: site_reference,
                               device_reference: device_reference,
                               filter: filter,
                               transactions: transactions,
                               action: action,
                               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/batches/models/transaction_batch_response.rb', line 63

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_record_count'] = 'total_record_count'
  @_hash['batch_transaction_count'] = 'batch_transaction_count'
  @_hash['merchant_id'] = 'merchant_id'
  @_hash['merchant_name'] = 'merchant_name'
  @_hash['account_id'] = 'account_id'
  @_hash['account_name'] = 'account_name'
  @_hash['site_reference'] = 'site_reference'
  @_hash['device_reference'] = 'device_reference'
  @_hash['filter'] = 'filter'
  @_hash['transactions'] = 'transactions'
  @_hash['action'] = 'action'
  @_hash
end

.nullablesObject

An array for nullable fields



97
98
99
# File 'lib/batches/models/transaction_batch_response.rb', line 97

def self.nullables
  []
end

.optionalsObject

An array for optional fields



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/batches/models/transaction_batch_response.rb', line 80

def self.optionals
  %w[
    total_record_count
    batch_transaction_count
    merchant_id
    merchant_name
    account_id
    account_name
    site_reference
    device_reference
    filter
    transactions
    action
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



187
188
189
190
191
192
193
194
195
196
# File 'lib/batches/models/transaction_batch_response.rb', line 187

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} total_record_count: #{@total_record_count.inspect},"\
  " batch_transaction_count: #{@batch_transaction_count.inspect}, merchant_id:"\
  " #{@merchant_id.inspect}, merchant_name: #{@merchant_name.inspect}, account_id:"\
  " #{@account_id.inspect}, account_name: #{@account_name.inspect}, site_reference:"\
  " #{@site_reference.inspect}, device_reference: #{@device_reference.inspect}, filter:"\
  " #{@filter.inspect}, transactions: #{@transactions.inspect}, action: #{@action.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



176
177
178
179
180
181
182
183
184
# File 'lib/batches/models/transaction_batch_response.rb', line 176

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} total_record_count: #{@total_record_count}, batch_transaction_count:"\
  " #{@batch_transaction_count}, merchant_id: #{@merchant_id}, merchant_name:"\
  " #{@merchant_name}, account_id: #{@account_id}, account_name: #{@account_name},"\
  " site_reference: #{@site_reference}, device_reference: #{@device_reference}, filter:"\
  " #{@filter}, transactions: #{@transactions}, action: #{@action}, additional_properties:"\
  " #{@additional_properties}>"
end