Class: TransferZero::TransactionsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/transferzero-sdk/api/transactions_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TransactionsApi

Returns a new instance of TransactionsApi.



19
20
21
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 19

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#calculate_transactions(transaction_request, opts = {}) ⇒ TransactionResponse

Calculates transaction amounts for a transaction payload Calculates the input, output and fee amounts for the recipients in a transaction payload

Parameters:

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

    the optional parameters

Returns:



29
30
31
32
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 29

def calculate_transactions(transaction_request, opts = {})
  data, _status_code, _headers = calculate_transactions_with_http_info(transaction_request, opts)
  data
end

#calculate_transactions_with_http_info(transaction_request, opts = {}) ⇒ Array<(TransactionResponse, Fixnum, Hash)>

Calculates transaction amounts for a transaction payload Calculates the input, output and fee amounts for the recipients in a transaction payload

Parameters:

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

    the optional parameters

Returns:

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

    TransactionResponse data, response status code and response headers



39
40
41
42
43
44
45
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
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 39

def calculate_transactions_with_http_info(transaction_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TransactionsApi.calculate_transactions ...'
  end
  # verify the required parameter 'transaction_request' is set
  if @api_client.config.client_side_validation && transaction_request.nil?
    fail ArgumentError, "Missing the required parameter 'transaction_request' when calling TransactionsApi.calculate_transactions"
  end
  # resource path
  local_var_path = '/transactions/calculate'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(transaction_request)
  auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'TransactionResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionsApi#calculate_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_transaction(transaction_id, opts = {}) ⇒ TransactionResponse

Fetch a single transaction Finds and returns a Transaction created by the requesting API key, using the provided Transaction ID.

Parameters:

  • transaction_id

    ID of the transaction. Example: &#x60;/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670&#x60;

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

    the optional parameters

Returns:



85
86
87
88
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 85

def get_transaction(transaction_id, opts = {})
  data, _status_code, _headers = get_transaction_with_http_info(transaction_id, opts)
  data
end

#get_transaction_with_http_info(transaction_id, opts = {}) ⇒ Array<(TransactionResponse, Fixnum, Hash)>

Fetch a single transaction Finds and returns a Transaction created by the requesting API key, using the provided Transaction ID.

Parameters:

  • transaction_id

    ID of the transaction. Example: &#x60;/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670&#x60;

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

    the optional parameters

Returns:

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

    TransactionResponse data, response status code and response headers



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 95

def get_transaction_with_http_info(transaction_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TransactionsApi.get_transaction ...'
  end
  # verify the required parameter 'transaction_id' is set
  if @api_client.config.client_side_validation && transaction_id.nil?
    fail ArgumentError, "Missing the required parameter 'transaction_id' when calling TransactionsApi.get_transaction"
  end
  # resource path
  local_var_path = '/transactions/{Transaction ID}'.sub('{' + 'Transaction ID' + '}', transaction_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'TransactionResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionsApi#get_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_transactions(opts = {}) ⇒ TransactionListResponse

Get a list of transactions Retrieves a paginated list of the Transactions created by your API key.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    The page number to request (defaults to 1)

  • :per (Integer)

    The number of results to load per page (defaults to 10)

  • :external_id (String)

    Allows filtering results by &#x60;external_id&#x60;. Example: &#x60;/v1/senders?external_id&#x3D;26ec8517-2f0d-48c0-b74f-0bccb9ab3a87&#x60;

Returns:



151
152
153
154
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 151

def get_transactions(opts = {})
  data, _status_code, _headers = get_transactions_with_http_info(opts)
  data
end

#get_transactions_all(opts = {}) ⇒ Object



133
134
135
136
137
138
139
140
141
142
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 133

def get_transactions_all(opts = {})
  result = []
  response = get_transactions(opts)
  result += response["object"]
  while next_page = response["meta"]["pagination"]["next_page"]
    response = get_transactions(opts.merge(page: next_page))
    result += response["object"]
  end
  result
end

#get_transactions_with_http_info(opts = {}) ⇒ Array<(TransactionListResponse, Fixnum, Hash)>

Get a list of transactions Retrieves a paginated list of the Transactions created by your API key.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    The page number to request (defaults to 1)

  • :per (Integer)

    The number of results to load per page (defaults to 10)

  • :external_id (String)

    Allows filtering results by &#x60;external_id&#x60;. Example: &#x60;/v1/senders?external_id&#x3D;26ec8517-2f0d-48c0-b74f-0bccb9ab3a87&#x60;

Returns:

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

    TransactionListResponse data, response status code and response headers



163
164
165
166
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
195
196
197
198
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 163

def get_transactions_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TransactionsApi.get_transactions ...'
  end
  # resource path
  local_var_path = '/transactions'

  # query parameters
  query_params = {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'per'] = opts[:'per'] if !opts[:'per'].nil?
  query_params[:'external_id'] = opts[:'external_id'] if !opts[:'external_id'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'TransactionListResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionsApi#get_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#payin_transaction(transaction_id, payin_method_request, opts = {}) ⇒ TransactionResponse

Creates a fake payin for transaction This method is available only in sandbox environment and is supposed to be used only for testing integration. It allows you to emulate a payin without paying actual money.

Parameters:

  • transaction_id

    ID of the transaction to payin. Example: &#x60;/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670/payin&#x60;

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

    the optional parameters

Returns:



207
208
209
210
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 207

def payin_transaction(transaction_id, payin_method_request, opts = {})
  data, _status_code, _headers = payin_transaction_with_http_info(transaction_id, payin_method_request, opts)
  data
end

#payin_transaction_with_http_info(transaction_id, payin_method_request, opts = {}) ⇒ Array<(TransactionResponse, Fixnum, Hash)>

Creates a fake payin for transaction This method is available only in sandbox environment and is supposed to be used only for testing integration. It allows you to emulate a payin without paying actual money.

Parameters:

  • transaction_id

    ID of the transaction to payin. Example: &#x60;/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670/payin&#x60;

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

    the optional parameters

Returns:

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

    TransactionResponse data, response status code and response headers



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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 218

def payin_transaction_with_http_info(transaction_id, payin_method_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TransactionsApi.payin_transaction ...'
  end
  # verify the required parameter 'transaction_id' is set
  if @api_client.config.client_side_validation && transaction_id.nil?
    fail ArgumentError, "Missing the required parameter 'transaction_id' when calling TransactionsApi.payin_transaction"
  end
  # verify the required parameter 'payin_method_request' is set
  if @api_client.config.client_side_validation && payin_method_request.nil?
    fail ArgumentError, "Missing the required parameter 'payin_method_request' when calling TransactionsApi.payin_transaction"
  end
  # resource path
  local_var_path = '/transactions/{Transaction ID}/payin'.sub('{' + 'Transaction ID' + '}', transaction_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(payin_method_request)
  auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'TransactionResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionsApi#payin_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#payout_transaction(transaction_id, opts = {}) ⇒ TransactionResponse

Creates a fake payout for transaction This method is available only in sandbox environment and is supposed to be used only for testing. It allows you to emulate the payout of a transaction after payin.

Parameters:

  • transaction_id

    ID of the transaction to payout. Example: &#x60;/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670/payout&#x60;

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

    the optional parameters

Returns:



268
269
270
271
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 268

def payout_transaction(transaction_id, opts = {})
  data, _status_code, _headers = payout_transaction_with_http_info(transaction_id, opts)
  data
end

#payout_transaction_with_http_info(transaction_id, opts = {}) ⇒ Array<(TransactionResponse, Fixnum, Hash)>

Creates a fake payout for transaction This method is available only in sandbox environment and is supposed to be used only for testing. It allows you to emulate the payout of a transaction after payin.

Parameters:

  • transaction_id

    ID of the transaction to payout. Example: &#x60;/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670/payout&#x60;

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

    the optional parameters

Returns:

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

    TransactionResponse data, response status code and response headers



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/transferzero-sdk/api/transactions_api.rb', line 278

def payout_transaction_with_http_info(transaction_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TransactionsApi.payout_transaction ...'
  end
  # verify the required parameter 'transaction_id' is set
  if @api_client.config.client_side_validation && transaction_id.nil?
    fail ArgumentError, "Missing the required parameter 'transaction_id' when calling TransactionsApi.payout_transaction"
  end
  # resource path
  local_var_path = '/transactions/{Transaction ID}/payout'.sub('{' + 'Transaction ID' + '}', transaction_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'TransactionResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionsApi#payout_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#post_transactions(transaction_request, opts = {}) ⇒ TransactionResponse

Creates a new transaction Transactions are the main objects in the TransferZero API, so it’s important to understand how to create and manage them. Transactions facilitate money movement from one Sender in a specific currency to one or multiple Recipients in another currency. The main flow of a successful transaction flow is the following - - Transaction is created linking the Sender to the Recipient(s) with the requested amounts. - Once the sender is KYC’d and approved the transaction can be funded. - Once the transaction is funded, we will initiate the payout to the recipient(s). - After the recipient (or all recipients) has received the money, the transaction is finished.

Parameters:

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

    the optional parameters

Returns:



322
323
324
325
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 322

def post_transactions(transaction_request, opts = {})
  data, _status_code, _headers = post_transactions_with_http_info(transaction_request, opts)
  data
end

#post_transactions_with_http_info(transaction_request, opts = {}) ⇒ Array<(TransactionResponse, Fixnum, Hash)>

Creates a new transaction Transactions are the main objects in the TransferZero API, so it&#39;s important to understand how to create and manage them. Transactions facilitate money movement from one Sender in a specific currency to one or multiple Recipients in another currency. The main flow of a successful transaction flow is the following - - Transaction is created linking the Sender to the Recipient(s) with the requested amounts. - Once the sender is KYC&#39;d and approved the transaction can be funded. - Once the transaction is funded, we will initiate the payout to the recipient(s). - After the recipient (or all recipients) has received the money, the transaction is finished.

Parameters:

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

    the optional parameters

Returns:

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

    TransactionResponse data, response status code and response headers



332
333
334
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
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 332

def post_transactions_with_http_info(transaction_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TransactionsApi.post_transactions ...'
  end
  # verify the required parameter 'transaction_request' is set
  if @api_client.config.client_side_validation && transaction_request.nil?
    fail ArgumentError, "Missing the required parameter 'transaction_request' when calling TransactionsApi.post_transactions"
  end
  # resource path
  local_var_path = '/transactions'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(transaction_request)
  auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'TransactionResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionsApi#post_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#validate_transactions(transaction_request, opts = {}) ⇒ TransactionResponse

Validates a transaction payload Validates fields in a transaction payload and displays invalid or missing fields

Parameters:

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

    the optional parameters

Returns:



378
379
380
381
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 378

def validate_transactions(transaction_request, opts = {})
  data, _status_code, _headers = validate_transactions_with_http_info(transaction_request, opts)
  data
end

#validate_transactions_with_http_info(transaction_request, opts = {}) ⇒ Array<(TransactionResponse, Fixnum, Hash)>

Validates a transaction payload Validates fields in a transaction payload and displays invalid or missing fields

Parameters:

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

    the optional parameters

Returns:

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

    TransactionResponse data, response status code and response headers



388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/transferzero-sdk/api/transactions_api.rb', line 388

def validate_transactions_with_http_info(transaction_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TransactionsApi.validate_transactions ...'
  end
  # verify the required parameter 'transaction_request' is set
  if @api_client.config.client_side_validation && transaction_request.nil?
    fail ArgumentError, "Missing the required parameter 'transaction_request' when calling TransactionsApi.validate_transactions"
  end
  # resource path
  local_var_path = '/transactions/validate'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(transaction_request)
  auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'TransactionResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionsApi#validate_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end