Class: Batches::CloseResponse

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

Overview

CloseResponse 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_last_updated: 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, transaction_count: SKIP, amount: SKIP, currency: SKIP, gratuity_amount: SKIP, sales: SKIP, refunds: SKIP, funding_debit: SKIP, funding_credit: SKIP, brand_breakdown: SKIP, host_breakdown: SKIP, action: SKIP, additional_properties: nil) ⇒ CloseResponse

Returns a new instance of CloseResponse.



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/batches/models/close_response.rb', line 201

def initialize(id: SKIP, status: SKIP, time_created: SKIP,
               time_last_updated: 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, transaction_count: SKIP,
               amount: SKIP, currency: SKIP, gratuity_amount: SKIP,
               sales: SKIP, refunds: SKIP, funding_debit: SKIP,
               funding_credit: SKIP, brand_breakdown: SKIP,
               host_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_last_updated = time_last_updated unless time_last_updated == 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
  @transaction_count = transaction_count unless 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
  @host_breakdown = host_breakdown unless host_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)


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

def 
  @account_id
end

#account_nameString

A meaningful label that better identifies the account.

Returns:

  • (String)


64
65
66
# File 'lib/batches/models/close_response.rb', line 64

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:



134
135
136
# File 'lib/batches/models/close_response.rb', line 134

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)


82
83
84
# File 'lib/batches/models/close_response.rb', line 82

def amount
  @amount
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:



122
123
124
# File 'lib/batches/models/close_response.rb', line 122

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)


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

def close_action_id
  @close_action_id
end

#currencyString

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

Returns:

  • (String)


86
87
88
# File 'lib/batches/models/close_response.rb', line 86

def currency
  @currency
end

#device_referenceString

A reference for the device that created the batch

Returns:

  • (String)


72
73
74
# File 'lib/batches/models/close_response.rb', line 72

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:



116
117
118
# File 'lib/batches/models/close_response.rb', line 116

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:



110
111
112
# File 'lib/batches/models/close_response.rb', line 110

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)


92
93
94
# File 'lib/batches/models/close_response.rb', line 92

def gratuity_amount
  @gratuity_amount
end

#host_breakdownHostBreakdownItem

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:



128
129
130
# File 'lib/batches/models/close_response.rb', line 128

def host_breakdown
  @host_breakdown
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/close_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)


50
51
52
# File 'lib/batches/models/close_response.rb', line 50

def merchant_id
  @merchant_id
end

#merchant_nameString

A meaningful label that better identifies the merchant.

Returns:

  • (String)


54
55
56
# File 'lib/batches/models/close_response.rb', line 54

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)


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

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:



104
105
106
# File 'lib/batches/models/close_response.rb', line 104

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:



98
99
100
# File 'lib/batches/models/close_response.rb', line 98

def sales
  @sales
end

#site_referenceString

A reference for the location that created the batch.

Returns:

  • (String)


68
69
70
# File 'lib/batches/models/close_response.rb', line 68

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/close_response.rb', line 21

def status
  @status
end

#time_closedString

Time indicating when the batch was closed

Returns:

  • (String)


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

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/close_response.rb', line 25

def time_created
  @time_created
end

#time_last_updatedString

Global Payments time indicating when the batch was last updated in ISO-8601 format..

Returns:

  • (String)


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

def time_last_updated
  @time_last_updated
end

#transaction_countFloat

The number of transactions in the batch.

Returns:

  • (Float)


76
77
78
# File 'lib/batches/models/close_response.rb', line 76

def transaction_count
  @transaction_count
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/batches/models/close_response.rb', line 243

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_last_updated =
    hash.key?('time_last_updated') ? hash['time_last_updated'] : 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
  transaction_count =
    hash.key?('transaction_count') ? hash['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')
  host_breakdown = HostBreakdownItem.from_hash(hash['host_breakdown']) if
    hash['host_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.
  CloseResponse.new(id: id,
                    status: status,
                    time_created: time_created,
                    time_last_updated: time_last_updated,
                    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,
                    transaction_count: 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,
                    host_breakdown: host_breakdown,
                    action: action,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['status'] = 'status'
  @_hash['time_created'] = 'time_created'
  @_hash['time_last_updated'] = 'time_last_updated'
  @_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['transaction_count'] = '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['host_breakdown'] = 'host_breakdown'
  @_hash['action'] = 'action'
  @_hash
end

.nullablesObject

An array for nullable fields



197
198
199
# File 'lib/batches/models/close_response.rb', line 197

def self.nullables
  []
end

.optionalsObject

An array for optional fields



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/batches/models/close_response.rb', line 167

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/batches/models/close_response.rb', line 340

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, status: #{@status.inspect}, time_created:"\
  " #{@time_created.inspect}, time_last_updated: #{@time_last_updated.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}, transaction_count: #{@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}, host_breakdown: #{@host_breakdown.inspect},"\
  " action: #{@action.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/batches/models/close_response.rb', line 325

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, status: #{@status}, time_created: #{@time_created},"\
  " time_last_updated: #{@time_last_updated}, 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}, transaction_count: #{@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}, host_breakdown: #{@host_breakdown}, action:"\
  " #{@action}, additional_properties: #{@additional_properties}>"
end