Class: SquareConnect::TransactionApi

Inherits:
Object
  • Object
show all
Defined in:
lib/square_connect/api/transaction_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TransactionApi

Returns a new instance of TransactionApi.



17
18
19
# File 'lib/square_connect/api/transaction_api.rb', line 17

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



15
16
17
# File 'lib/square_connect/api/transaction_api.rb', line 15

def api_client
  @api_client
end

Instance Method Details

#capture_transaction(authorization, location_id, transaction_id, opts = {}) ⇒ CaptureTransactionResponse

CaptureTransaction Captures a transaction that was created with the Chargenendpoint with a ‘delay_capture` value of `true`.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id
  • transaction_id
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



252
253
254
255
# File 'lib/square_connect/api/transaction_api.rb', line 252

def capture_transaction(authorization, location_id, transaction_id, opts = {})
  data, status_code, headers = capture_transaction_with_http_info(authorization, location_id, transaction_id, opts)
  return data
end

#capture_transaction_with_http_info(authorization, location_id, transaction_id, opts = {}) ⇒ Array<(CaptureTransactionResponse, Fixnum, Hash)>

CaptureTransaction Captures a transaction that was created with the Chargenendpoint with a ‘delay_capture` value of `true`.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id
  • transaction_id
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(CaptureTransactionResponse, Fixnum, Hash)>)

    CaptureTransactionResponse data, response status code and response headers



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
# File 'lib/square_connect/api/transaction_api.rb', line 264

def capture_transaction_with_http_info(authorization, location_id, transaction_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: TransactionApi#capture_transaction ..."
  end
  
  # verify the required parameter 'authorization' is set
  fail "Missing the required parameter 'authorization' when calling capture_transaction" if authorization.nil?
  
  # verify the required parameter 'location_id' is set
  fail "Missing the required parameter 'location_id' when calling capture_transaction" if location_id.nil?
  
  # verify the required parameter 'transaction_id' is set
  fail "Missing the required parameter 'transaction_id' when calling capture_transaction" if transaction_id.nil?
  
  # resource path
  path = "/v2/locations/{location_id}/transactions/{transaction_id}/capture".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s).sub('{' + 'transaction_id' + '}', transaction_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  _header_accept = ['application/json']
  _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result

  # HTTP header 'Content-Type'
  _header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
  header_params[:'Authorization'] = authorization

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  
  auth_names = []
  data, status_code, headers = @api_client.call_api(:POST, path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CaptureTransactionResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionApi#capture_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#charge(authorization, location_id, body, opts = {}) ⇒ ChargeResponse

Charge Charges a card represented by a token.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id

    The ID of the location to associate the transaction with.

  • body

    An object containing the fields to POST for the request.nnSee the corresponding object definition for field details.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



110
111
112
113
# File 'lib/square_connect/api/transaction_api.rb', line 110

def charge(authorization, location_id, body, opts = {})
  data, status_code, headers = charge_with_http_info(authorization, location_id, body, opts)
  return data
end

#charge_with_http_info(authorization, location_id, body, opts = {}) ⇒ Array<(ChargeResponse, Fixnum, Hash)>

Charge Charges a card represented by a token.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id

    The ID of the location to associate the transaction with.

  • body

    An object containing the fields to POST for the request.nnSee the corresponding object definition for field details.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(ChargeResponse, Fixnum, Hash)>)

    ChargeResponse data, response status code and response headers



122
123
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
# File 'lib/square_connect/api/transaction_api.rb', line 122

def charge_with_http_info(authorization, location_id, body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: TransactionApi#charge ..."
  end
  
  # verify the required parameter 'authorization' is set
  fail "Missing the required parameter 'authorization' when calling charge" if authorization.nil?
  
  # verify the required parameter 'location_id' is set
  fail "Missing the required parameter 'location_id' when calling charge" if location_id.nil?
  
  # verify the required parameter 'body' is set
  fail "Missing the required parameter 'body' when calling charge" if body.nil?
  
  # resource path
  path = "/v2/locations/{location_id}/transactions".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  _header_accept = ['application/json']
  _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result

  # HTTP header 'Content-Type'
  _header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
  header_params[:'Authorization'] = authorization

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(body)
  
  auth_names = []
  data, status_code, headers = @api_client.call_api(:POST, path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'ChargeResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionApi#charge\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_transactions(authorization, location_id, opts = {}) ⇒ ListTransactionsResponse

ListTransactions Lists transactions for a particular location.nnWhen making a request to this endpoint, your request body must include either the ‘cursor` parameter, or it mustninclude both `begin_time` and `end_time` with an optional `sort_order`.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id

    The ID of the location to list transactions for.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :begin_time (String)

    The beginning of the requested reporting period, in RFC 3339 format.

  • :end_time (String)

    The end of the requested reporting period, in RFC 3339 format.

  • :sort_order (String)

    The order in which results are listed in the response (‘ASC` fornchronological, `DESC` for reverse-chronological).

  • :cursor (String)

    A pagination cursor to retrieve the next set of results for yournoriginal query to the endpoint.

Returns:



31
32
33
34
# File 'lib/square_connect/api/transaction_api.rb', line 31

def list_transactions(authorization, location_id, opts = {})
  data, status_code, headers = list_transactions_with_http_info(authorization, location_id, opts)
  return data
end

#list_transactions_with_http_info(authorization, location_id, opts = {}) ⇒ Array<(ListTransactionsResponse, Fixnum, Hash)>

ListTransactions Lists transactions for a particular location.nnWhen making a request to this endpoint, your request body must include either the ‘cursor` parameter, or it mustninclude both `begin_time` and `end_time` with an optional `sort_order`.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id

    The ID of the location to list transactions for.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :begin_time (String)

    The beginning of the requested reporting period, in RFC 3339 format.

  • :end_time (String)

    The end of the requested reporting period, in RFC 3339 format.

  • :sort_order (String)

    The order in which results are listed in the response (‘ASC` fornchronological, `DESC` for reverse-chronological).

  • :cursor (String)

    A pagination cursor to retrieve the next set of results for yournoriginal query to the endpoint.

Returns:

  • (Array<(ListTransactionsResponse, Fixnum, Hash)>)

    ListTransactionsResponse data, response status code and response headers



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
96
97
98
99
100
101
# File 'lib/square_connect/api/transaction_api.rb', line 46

def list_transactions_with_http_info(authorization, location_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: TransactionApi#list_transactions ..."
  end
  
  # verify the required parameter 'authorization' is set
  fail "Missing the required parameter 'authorization' when calling list_transactions" if authorization.nil?
  
  # verify the required parameter 'location_id' is set
  fail "Missing the required parameter 'location_id' when calling list_transactions" if location_id.nil?
  
  if opts[:'sort_order'] && !['DESC', 'ASC'].include?(opts[:'sort_order'])
    fail 'invalid value for "sort_order", must be one of DESC, ASC'
  end
  
  # resource path
  path = "/v2/locations/{location_id}/transactions".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s)

  # query parameters
  query_params = {}
  query_params[:'begin_time'] = opts[:'begin_time'] if opts[:'begin_time']
  query_params[:'end_time'] = opts[:'end_time'] if opts[:'end_time']
  query_params[:'sort_order'] = opts[:'sort_order'] if opts[:'sort_order']
  query_params[:'cursor'] = opts[:'cursor'] if opts[:'cursor']

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  _header_accept = ['application/json']
  _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result

  # HTTP header 'Content-Type'
  _header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
  header_params[:'Authorization'] = authorization

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'ListTransactionsResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionApi#list_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#retrieve_transaction(authorization, location_id, transaction_id, opts = {}) ⇒ RetrieveTransactionResponse

RetrieveTransaction Retrieves details for a single transaction.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id
  • transaction_id
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



181
182
183
184
# File 'lib/square_connect/api/transaction_api.rb', line 181

def retrieve_transaction(authorization, location_id, transaction_id, opts = {})
  data, status_code, headers = retrieve_transaction_with_http_info(authorization, location_id, transaction_id, opts)
  return data
end

#retrieve_transaction_with_http_info(authorization, location_id, transaction_id, opts = {}) ⇒ Array<(RetrieveTransactionResponse, Fixnum, Hash)>

RetrieveTransaction Retrieves details for a single transaction.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id
  • transaction_id
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/square_connect/api/transaction_api.rb', line 193

def retrieve_transaction_with_http_info(authorization, location_id, transaction_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: TransactionApi#retrieve_transaction ..."
  end
  
  # verify the required parameter 'authorization' is set
  fail "Missing the required parameter 'authorization' when calling retrieve_transaction" if authorization.nil?
  
  # verify the required parameter 'location_id' is set
  fail "Missing the required parameter 'location_id' when calling retrieve_transaction" if location_id.nil?
  
  # verify the required parameter 'transaction_id' is set
  fail "Missing the required parameter 'transaction_id' when calling retrieve_transaction" if transaction_id.nil?
  
  # resource path
  path = "/v2/locations/{location_id}/transactions/{transaction_id}".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s).sub('{' + 'transaction_id' + '}', transaction_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  _header_accept = ['application/json']
  _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result

  # HTTP header 'Content-Type'
  _header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
  header_params[:'Authorization'] = authorization

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'RetrieveTransactionResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionApi#retrieve_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#void_transaction(authorization, location_id, transaction_id, opts = {}) ⇒ VoidTransactionResponse

VoidTransaction Cancels a transaction that was created with the Chargenendpoint with a ‘delay_capture` value of `true`.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id
  • transaction_id
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



323
324
325
326
# File 'lib/square_connect/api/transaction_api.rb', line 323

def void_transaction(authorization, location_id, transaction_id, opts = {})
  data, status_code, headers = void_transaction_with_http_info(authorization, location_id, transaction_id, opts)
  return data
end

#void_transaction_with_http_info(authorization, location_id, transaction_id, opts = {}) ⇒ Array<(VoidTransactionResponse, Fixnum, Hash)>

VoidTransaction Cancels a transaction that was created with the Chargenendpoint with a ‘delay_capture` value of `true`.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id
  • transaction_id
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(VoidTransactionResponse, Fixnum, Hash)>)

    VoidTransactionResponse data, response status code and response headers



335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/square_connect/api/transaction_api.rb', line 335

def void_transaction_with_http_info(authorization, location_id, transaction_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: TransactionApi#void_transaction ..."
  end
  
  # verify the required parameter 'authorization' is set
  fail "Missing the required parameter 'authorization' when calling void_transaction" if authorization.nil?
  
  # verify the required parameter 'location_id' is set
  fail "Missing the required parameter 'location_id' when calling void_transaction" if location_id.nil?
  
  # verify the required parameter 'transaction_id' is set
  fail "Missing the required parameter 'transaction_id' when calling void_transaction" if transaction_id.nil?
  
  # resource path
  path = "/v2/locations/{location_id}/transactions/{transaction_id}/void".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s).sub('{' + 'transaction_id' + '}', transaction_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  _header_accept = ['application/json']
  _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result

  # HTTP header 'Content-Type'
  _header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
  header_params[:'Authorization'] = authorization

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  
  auth_names = []
  data, status_code, headers = @api_client.call_api(:POST, path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'VoidTransactionResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionApi#void_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end