Class: BleumiPay::PaymentsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/bleumi_pay_sdk_ruby/api/payments_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default, request_validator = RequestValidator.default) ⇒ PaymentsApi

Returns a new instance of PaymentsApi.



20
21
22
23
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 20

def initialize(api_client = ApiClient.default, request_validator = RequestValidator.default)
  @api_client = api_client
  @request_validator = request_validator
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 17

def api_client
  @api_client
end

#request_validatorObject

Returns the value of attribute request_validator.



18
19
20
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 18

def request_validator
  @request_validator
end

Instance Method Details

#get_payment(id, opts = {}) ⇒ Payment

Retrieve the wallet addresses & token balances for a given payment

Parameters:

  • id (String)

    Unique identifier of the payment (specified during createPayment) to retrieve

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

    the optional parameters

Returns:



28
29
30
31
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 28

def get_payment(id, opts = {})
  data, _status_code, _headers = get_payment_with_http_info(id, opts)
  data
end

#get_payment_operation(id, txid, opts = {}) ⇒ PaymentOperation

Retrieve a payment operation for a specific payment.

Parameters:

  • id (String)

    Unique identifier of the payment (specified during [Create a Payment](#createPayment))

  • txid (String)

    ID of a specific operation of the payment

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

    the optional parameters

Returns:



89
90
91
92
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 89

def get_payment_operation(id, txid, opts = {})
  data, _status_code, _headers = get_payment_operation_with_http_info(id, txid, opts)
  data
end

#get_payment_operation_with_http_info(id, txid, opts = {}) ⇒ Array<(PaymentOperation, Integer, Hash)>

Retrieve a payment operation for a specific payment.

Parameters:

  • id (String)

    Unique identifier of the payment (specified during [Create a Payment](#createPayment))

  • txid (String)

    ID of a specific operation of the payment

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

    the optional parameters

Returns:

  • (Array<(PaymentOperation, Integer, Hash)>)

    PaymentOperation data, response status code and response headers



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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 99

def get_payment_operation_with_http_info(id, txid, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.get_payment_operation ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.get_payment_operation"
  end
  # verify the required parameter 'txid' is set
  if @api_client.config.client_side_validation && txid.nil?
    fail ArgumentError, "Missing the required parameter 'txid' when calling PaymentsApi.get_payment_operation"
  end
  # resource path
  local_var_path = '/v1/payment/{id}/operation/{txid}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)).sub('{' + 'txid' + '}', CGI.escape(txid.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

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

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'PaymentOperation' 

  # auth_names
  auth_names = opts[:auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#get_payment_operation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_payment_with_http_info(id, opts = {}) ⇒ Array<(Payment, Integer, Hash)>

Retrieve the wallet addresses &amp; token balances for a given payment

Parameters:

  • id (String)

    Unique identifier of the payment (specified during createPayment) to retrieve

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

    the optional parameters

Returns:

  • (Array<(Payment, Integer, Hash)>)

    Payment data, response status code and response headers



37
38
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
78
79
80
81
82
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 37

def get_payment_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.get_payment ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.get_payment"
  end
  # resource path
  local_var_path = '/v1/payment/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

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

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'Payment' 

  # auth_names
  auth_names = opts[:auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#get_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_payment_operations(id, opts = {}) ⇒ PaginatedPaymentOperations

Retrieve all payment operations for a specific payment.

Parameters:

  • id (String)

    Unique identifier of the payment (specified during [Create a Payment](#createPayment))

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

    the optional parameters

Options Hash (opts):

  • :next_token (String)

    Cursor to start results from

Returns:



155
156
157
158
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 155

def list_payment_operations(id, opts = {})
  data, _status_code, _headers = list_payment_operations_with_http_info(id, opts)
  data
end

#list_payment_operations_with_http_info(id, opts = {}) ⇒ Array<(PaginatedPaymentOperations, Integer, Hash)>

Retrieve all payment operations for a specific payment.

Parameters:

  • id (String)

    Unique identifier of the payment (specified during [Create a Payment](#createPayment))

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

    the optional parameters

Options Hash (opts):

  • :next_token (String)

    Cursor to start results from

Returns:

  • (Array<(PaginatedPaymentOperations, Integer, Hash)>)

    PaginatedPaymentOperations data, response status code and response headers



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
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 165

def list_payment_operations_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.list_payment_operations ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.list_payment_operations"
  end
  # resource path
  local_var_path = '/v1/payment/{id}/operation'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'nextToken'] = opts[:'next_token'] if !opts[:'next_token'].nil?

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

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'PaginatedPaymentOperations' 

  # auth_names
  auth_names = opts[:auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#list_payment_operations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_payments(opts = {}) ⇒ PaginatedPayments

Retrieve all payments created.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :next_token (String)

    Cursor to start results from

  • :sort_by (String)

    Sort payments by

  • :sort_order (String)

    Sort Order

  • :start_at (String)

    Get payments from this timestamp (unix)

  • :end_at (String)

    Get payments till this timestamp (unix)

Returns:



221
222
223
224
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 221

def list_payments(opts = {})
  data, _status_code, _headers = list_payments_with_http_info(opts)
  data
end

#list_payments_with_http_info(opts = {}) ⇒ Array<(PaginatedPayments, Integer, Hash)>

Retrieve all payments created.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :next_token (String)

    Cursor to start results from

  • :sort_by (String)

    Sort payments by

  • :sort_order (String)

    Sort Order

  • :start_at (String)

    Get payments from this timestamp (unix)

  • :end_at (String)

    Get payments till this timestamp (unix)

Returns:

  • (Array<(PaginatedPayments, Integer, Hash)>)

    PaginatedPayments data, response status code and response headers



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
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 234

def list_payments_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.list_payments ...'
  end
  allowable_values = ["createdAt", "updatedAt"]
  if @api_client.config.client_side_validation && opts[:'sort_by'] && !allowable_values.include?(opts[:'sort_by'])
    fail ArgumentError, "invalid value for \"sort_by\", must be one of #{allowable_values}"
  end
  allowable_values = ["ascending", "descending"]
  if @api_client.config.client_side_validation && opts[:'sort_order'] && !allowable_values.include?(opts[:'sort_order'])
    fail ArgumentError, "invalid value for \"sort_order\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/payment'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'nextToken'] = opts[:'next_token'] if !opts[:'next_token'].nil?
  query_params[:'sortBy'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?
  query_params[:'sortOrder'] = opts[:'sort_order'] if !opts[:'sort_order'].nil?
  query_params[:'startAt'] = opts[:'start_at'] if !opts[:'start_at'].nil?
  query_params[:'endAt'] = opts[:'end_at'] if !opts[:'end_at'].nil?

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

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'PaginatedPayments' 

  # auth_names
  auth_names = opts[:auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#list_payments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#refund_payment(id, payment_refund_request, opts = {}) ⇒ PaymentOperationResponse

Refund the balance of a token for a given payment to the buyerAddress

Parameters:

  • id (String)

    Unique identifier of the payment (specified during createPayment)

  • payment_refund_request (PaymentRefundRequest)

    Request body - used to specify the token to refund.

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

    the optional parameters

Options Hash (opts):

  • :chain (Chain)

    Network in which payment is to be refunded.

Returns:



296
297
298
299
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 296

def refund_payment(id, payment_refund_request, opts = {})
  data, _status_code, _headers = refund_payment_with_http_info(id, payment_refund_request, opts)
  data
end

#refund_payment_with_http_info(id, payment_refund_request, opts = {}) ⇒ Array<(PaymentOperationResponse, Integer, Hash)>

Refund the balance of a token for a given payment to the buyerAddress

Parameters:

  • id (String)

    Unique identifier of the payment (specified during createPayment)

  • payment_refund_request (PaymentRefundRequest)

    Request body - used to specify the token to refund.

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

    the optional parameters

Options Hash (opts):

  • :chain (Chain)

    Network in which payment is to be refunded.

Returns:

  • (Array<(PaymentOperationResponse, Integer, Hash)>)

    PaymentOperationResponse data, response status code and response headers



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
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
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 307

def refund_payment_with_http_info(id, payment_refund_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.refund_payment ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.refund_payment"
  end
  # verify the required parameter 'payment_refund_request' is set
  if @api_client.config.client_side_validation && payment_refund_request.nil?
    fail ArgumentError, "Missing the required parameter 'payment_refund_request' when calling PaymentsApi.refund_payment"
  end
  # verify the values in the request body are valid
  chain = opts[:'chain'] if !opts[:'chain'].nil?
  msg = @request_validator.validate_refund_payment_request(payment_refund_request, chain)
  if (@request_validator.is_not_empty(msg))
    fail ArgumentError, "`#{msg}` when calling PaymentsApi.refund_payment"
  end
  # resource path
  local_var_path = '/v1/payment/{id}/refund'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'chain'] = opts[:'chain'] if !opts[:'chain'].nil?

  # header parameters
  header_params = opts[: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 = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(payment_refund_request) 

  # return_type
  return_type = opts[:return_type] || 'PaymentOperationResponse' 

  # auth_names
  auth_names = opts[:auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#refund_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#settle_payment(id, payment_settle_request, opts = {}) ⇒ PaymentOperationResponse

Settle a specific amount of a token for a given payment to the transferAddress and remaining balance (if any) will be refunded to the buyerAddress

Parameters:

  • id (String)

    Unique identifier of the payment (specified during createPayment)

  • payment_settle_request (PaymentSettleRequest)

    Request body - used to specify the amount to settle.

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

    the optional parameters

Options Hash (opts):

  • :chain (Chain)

    Network in which payment is to be settled.

Returns:



373
374
375
376
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 373

def settle_payment(id, payment_settle_request, opts = {})
  data, _status_code, _headers = settle_payment_with_http_info(id, payment_settle_request, opts)
  data
end

#settle_payment_with_http_info(id, payment_settle_request, opts = {}) ⇒ Array<(PaymentOperationResponse, Integer, Hash)>

Settle a specific amount of a token for a given payment to the transferAddress and remaining balance (if any) will be refunded to the buyerAddress

Parameters:

  • id (String)

    Unique identifier of the payment (specified during createPayment)

  • payment_settle_request (PaymentSettleRequest)

    Request body - used to specify the amount to settle.

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

    the optional parameters

Options Hash (opts):

  • :chain (Chain)

    Network in which payment is to be settled.

Returns:

  • (Array<(PaymentOperationResponse, Integer, Hash)>)

    PaymentOperationResponse data, response status code and response headers



384
385
386
387
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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/bleumi_pay_sdk_ruby/api/payments_api.rb', line 384

def settle_payment_with_http_info(id, payment_settle_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.settle_payment ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.settle_payment"
  end
  # verify the required parameter 'payment_settle_request' is set
  if @api_client.config.client_side_validation && payment_settle_request.nil?
    fail ArgumentError, "Missing the required parameter 'payment_settle_request' when calling PaymentsApi.settle_payment"
  end
  # verify the values in the request body are valid
  chain = opts[:'chain'] if !opts[:'chain'].nil?
  msg = @request_validator.validate_settle_payment_request(payment_settle_request, chain)
  if (@request_validator.is_not_empty(msg))
    fail ArgumentError, "`#{msg}` when calling PaymentsApi.settle_payment"
  end      
  # resource path
  local_var_path = '/v1/payment/{id}/settle'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'chain'] = opts[:'chain'] if !opts[:'chain'].nil?

  # header parameters
  header_params = opts[: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 = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(payment_settle_request) 

  # return_type
  return_type = opts[:return_type] || 'PaymentOperationResponse' 

  # auth_names
  auth_names = opts[:auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#settle_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end