Class: Batches::GetResponse

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

Overview

GetResponse 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(id: SKIP, status: SKIP, time_created: SKIP, time_closed: SKIP, open_action_id: SKIP, close_action_id: SKIP, merchant_id: SKIP, merchant_name: SKIP, account_id: SKIP, account_name: SKIP, site_reference: SKIP, device_reference: SKIP, batch_transaction_count: SKIP, amount: SKIP, currency: SKIP, gratuity_amount: SKIP, sales: SKIP, refunds: SKIP, funding_debit: SKIP, funding_credit: SKIP, brand_breakdown: SKIP, action: SKIP, additional_properties: nil) ⇒ GetResponse

Returns a new instance of GetResponse.



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/batches/models/get_response.rb', line 186

def initialize(id: SKIP, status: SKIP, time_created: SKIP,
               time_closed: SKIP, open_action_id: SKIP,
               close_action_id: SKIP, merchant_id: SKIP,
               merchant_name: SKIP, account_id: SKIP, account_name: SKIP,
               site_reference: SKIP, device_reference: SKIP,
               batch_transaction_count: SKIP, amount: SKIP, currency: SKIP,
               gratuity_amount: SKIP, sales: SKIP, refunds: SKIP,
               funding_debit: SKIP, funding_credit: SKIP,
               brand_breakdown: SKIP, action: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id unless id == SKIP
  @status = status unless status == SKIP
  @time_created = time_created unless time_created == SKIP
  @time_closed = time_closed unless time_closed == SKIP
  @open_action_id = open_action_id unless open_action_id == SKIP
  @close_action_id = close_action_id unless close_action_id == 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
  @batch_transaction_count = batch_transaction_count unless batch_transaction_count == SKIP
  @amount = amount unless amount == SKIP
  @currency = currency unless currency == SKIP
  @gratuity_amount = gratuity_amount unless gratuity_amount == SKIP
  @sales = sales unless sales == SKIP
  @refunds = refunds unless refunds == SKIP
  @funding_debit = funding_debit unless funding_debit == SKIP
  @funding_credit = funding_credit unless funding_credit == SKIP
  @brand_breakdown = brand_breakdown unless brand_breakdown == 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)


55
56
57
# File 'lib/batches/models/get_response.rb', line 55

def 
  @account_id
end

#account_nameString

A meaningful label that better identifies the account.

Returns:

  • (String)


59
60
61
# File 'lib/batches/models/get_response.rb', line 59

def 
  @account_name
end

#actionAction

The amount that is an aggregation of all the transactions' gratuity amounts in the batch. It is always represented in the lowest denomination of the related currency.

Returns:



123
124
125
# File 'lib/batches/models/get_response.rb', line 123

def action
  @action
end

#amountString

The batch amount that is an aggregation of all the transactions' amounts in the batch. It is always represented in the lowest denomination of the related currency.

Returns:

  • (String)


77
78
79
# File 'lib/batches/models/get_response.rb', line 77

def amount
  @amount
end

#batch_transaction_countFloat

The number of transactions in the batch.

Returns:

  • (Float)


71
72
73
# File 'lib/batches/models/get_response.rb', line 71

def batch_transaction_count
  @batch_transaction_count
end

#brand_breakdownArray[BrandBreakdownItem]

The amount that is an aggregation of all the transactions' gratuity amounts in the batch. It is always represented in the lowest denomination of the related currency.

Returns:



117
118
119
# File 'lib/batches/models/get_response.rb', line 117

def brand_breakdown
  @brand_breakdown
end

#close_action_idString

An identifier generated by Global Payments to uniquely identify the action that closed the batch.

Returns:

  • (String)


39
40
41
# File 'lib/batches/models/get_response.rb', line 39

def close_action_id
  @close_action_id
end

#currencyString

The currency of the amount in ISO-4217(alpha-3)

Returns:

  • (String)


81
82
83
# File 'lib/batches/models/get_response.rb', line 81

def currency
  @currency
end

#device_referenceString

A reference for the device that created the batch

Returns:

  • (String)


67
68
69
# File 'lib/batches/models/get_response.rb', line 67

def device_reference
  @device_reference
end

#funding_creditFundingCredit

The amount that is an aggregation of all the transactions' gratuity amounts in the batch. It is always represented in the lowest denomination of the related currency.

Returns:



111
112
113
# File 'lib/batches/models/get_response.rb', line 111

def funding_credit
  @funding_credit
end

#funding_debitFundingDebit

The amount that is an aggregation of all the transactions' gratuity amounts in the batch. It is always represented in the lowest denomination of the related currency.

Returns:



105
106
107
# File 'lib/batches/models/get_response.rb', line 105

def funding_debit
  @funding_debit
end

#gratuity_amountString

The amount that is an aggregation of all the transactions' gratuity amounts in the batch. It is always represented in the lowest denomination of the related currency.

Returns:

  • (String)


87
88
89
# File 'lib/batches/models/get_response.rb', line 87

def gratuity_amount
  @gratuity_amount
end

#idString

A unique identifier for the object created by Global Payments. The first 3 characters identifies the resource an id relates to.

Returns:

  • (String)


15
16
17
# File 'lib/batches/models/get_response.rb', line 15

def id
  @id
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)


45
46
47
# File 'lib/batches/models/get_response.rb', line 45

def merchant_id
  @merchant_id
end

#merchant_nameString

A meaningful label that better identifies the merchant.

Returns:

  • (String)


49
50
51
# File 'lib/batches/models/get_response.rb', line 49

def merchant_name
  @merchant_name
end

#open_action_idString

An identifier generated by Global Payments to uniquely identify the action that opened the batch.

Returns:

  • (String)


34
35
36
# File 'lib/batches/models/get_response.rb', line 34

def open_action_id
  @open_action_id
end

#refundsRefunds

The amount that is an aggregation of all the transactions' gratuity amounts in the batch. It is always represented in the lowest denomination of the related currency.

Returns:



99
100
101
# File 'lib/batches/models/get_response.rb', line 99

def refunds
  @refunds
end

#salesSales

The amount that is an aggregation of all the transactions' gratuity amounts in the batch. It is always represented in the lowest denomination of the related currency.

Returns:



93
94
95
# File 'lib/batches/models/get_response.rb', line 93

def sales
  @sales
end

#site_referenceString

A reference for the location that created the batch.

Returns:

  • (String)


63
64
65
# File 'lib/batches/models/get_response.rb', line 63

def site_reference
  @site_reference
end

#statusStatusBatchesStatus

Indicates where a batch is in its life cycle. *OPEN - Batch is open and can accept more transactions. *CLOSED - Batch is closed and cannot accept more transactions.

Returns:



21
22
23
# File 'lib/batches/models/get_response.rb', line 21

def status
  @status
end

#time_closedString

Time indicating when the batch was closed

Returns:

  • (String)


29
30
31
# File 'lib/batches/models/get_response.rb', line 29

def time_closed
  @time_closed
end

#time_createdString

Time indicating when the batch was created in ISO-8601 format..

Returns:

  • (String)


25
26
27
# File 'lib/batches/models/get_response.rb', line 25

def time_created
  @time_created
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/batches/models/get_response.rb', line 225

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  time_created = hash.key?('time_created') ? hash['time_created'] : SKIP
  time_closed = hash.key?('time_closed') ? hash['time_closed'] : SKIP
  open_action_id =
    hash.key?('open_action_id') ? hash['open_action_id'] : SKIP
  close_action_id =
    hash.key?('close_action_id') ? hash['close_action_id'] : 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
  batch_transaction_count =
    hash.key?('batch_transaction_count') ? hash['batch_transaction_count'] : SKIP
  amount = hash.key?('amount') ? hash['amount'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  gratuity_amount =
    hash.key?('gratuity_amount') ? hash['gratuity_amount'] : SKIP
  sales = Sales.from_hash(hash['sales']) if hash['sales']
  refunds = Refunds.from_hash(hash['refunds']) if hash['refunds']
  funding_debit = FundingDebit.from_hash(hash['funding_debit']) if hash['funding_debit']
  funding_credit = FundingCredit.from_hash(hash['funding_credit']) if hash['funding_credit']
  # Parameter is an array, so we need to iterate through it
  brand_breakdown = nil
  unless hash['brand_breakdown'].nil?
    brand_breakdown = []
    hash['brand_breakdown'].each do |structure|
      brand_breakdown << (BrandBreakdownItem.from_hash(structure) if structure)
    end
  end

  brand_breakdown = SKIP unless hash.key?('brand_breakdown')
  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.
  GetResponse.new(id: id,
                  status: status,
                  time_created: time_created,
                  time_closed: time_closed,
                  open_action_id: open_action_id,
                  close_action_id: close_action_id,
                  merchant_id: merchant_id,
                  merchant_name: merchant_name,
                  account_id: ,
                  account_name: ,
                  site_reference: site_reference,
                  device_reference: device_reference,
                  batch_transaction_count: batch_transaction_count,
                  amount: amount,
                  currency: currency,
                  gratuity_amount: gratuity_amount,
                  sales: sales,
                  refunds: refunds,
                  funding_debit: funding_debit,
                  funding_credit: funding_credit,
                  brand_breakdown: brand_breakdown,
                  action: action,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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
# File 'lib/batches/models/get_response.rb', line 126

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['status'] = 'status'
  @_hash['time_created'] = 'time_created'
  @_hash['time_closed'] = 'time_closed'
  @_hash['open_action_id'] = 'open_action_id'
  @_hash['close_action_id'] = 'close_action_id'
  @_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['batch_transaction_count'] = 'batch_transaction_count'
  @_hash['amount'] = 'amount'
  @_hash['currency'] = 'currency'
  @_hash['gratuity_amount'] = 'gratuity_amount'
  @_hash['sales'] = 'sales'
  @_hash['refunds'] = 'refunds'
  @_hash['funding_debit'] = 'funding_debit'
  @_hash['funding_credit'] = 'funding_credit'
  @_hash['brand_breakdown'] = 'brand_breakdown'
  @_hash['action'] = 'action'
  @_hash
end

.nullablesObject

An array for nullable fields



182
183
184
# File 'lib/batches/models/get_response.rb', line 182

def self.nullables
  []
end

.optionalsObject

An array for optional fields



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/batches/models/get_response.rb', line 154

def self.optionals
  %w[
    id
    status
    time_created
    time_closed
    open_action_id
    close_action_id
    merchant_id
    merchant_name
    account_id
    account_name
    site_reference
    device_reference
    batch_transaction_count
    amount
    currency
    gratuity_amount
    sales
    refunds
    funding_debit
    funding_credit
    brand_breakdown
    action
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/batches/models/get_response.rb', line 316

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, status: #{@status.inspect}, time_created:"\
  " #{@time_created.inspect}, time_closed: #{@time_closed.inspect}, open_action_id:"\
  " #{@open_action_id.inspect}, close_action_id: #{@close_action_id.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},"\
  " batch_transaction_count: #{@batch_transaction_count.inspect}, amount: #{@amount.inspect},"\
  " currency: #{@currency.inspect}, gratuity_amount: #{@gratuity_amount.inspect}, sales:"\
  " #{@sales.inspect}, refunds: #{@refunds.inspect}, funding_debit: #{@funding_debit.inspect},"\
  " funding_credit: #{@funding_credit.inspect}, brand_breakdown: #{@brand_breakdown.inspect},"\
  " action: #{@action.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/batches/models/get_response.rb', line 301

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, status: #{@status}, time_created: #{@time_created},"\
  " time_closed: #{@time_closed}, open_action_id: #{@open_action_id}, close_action_id:"\
  " #{@close_action_id}, merchant_id: #{@merchant_id}, merchant_name: #{@merchant_name},"\
  " account_id: #{@account_id}, account_name: #{@account_name}, site_reference:"\
  " #{@site_reference}, device_reference: #{@device_reference}, batch_transaction_count:"\
  " #{@batch_transaction_count}, amount: #{@amount}, currency: #{@currency}, gratuity_amount:"\
  " #{@gratuity_amount}, sales: #{@sales}, refunds: #{@refunds}, funding_debit:"\
  " #{@funding_debit}, funding_credit: #{@funding_credit}, brand_breakdown:"\
  " #{@brand_breakdown}, action: #{@action}, additional_properties:"\
  " #{@additional_properties}>"
end