Class: TransferZero::RecipientsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ RecipientsApi

Returns a new instance of RecipientsApi.



19
20
21
# File 'lib/transferzero-sdk/api/recipients_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/recipients_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#delete_recipient(recipient_id, opts = {}) ⇒ RecipientResponse

Cancelling a recipient Cancels the payment to the recipient specified in the URL path. Please note recipients where the ‘may_cancel` attribute is true will be cancelled immediately. If the `may_cancel` attribute is false you can still try to cancel the recipient, however it will only gets cancelled if we will receive a confirmation from our partner that the payment has failed

Parameters:

  • recipient_id

    ID of recipient to cancel. Example: `/v1/recipients/9d4d7b73-a94c-4979-ab57-09074fd55d33`

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

    the optional parameters

Returns:



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

def delete_recipient(recipient_id, opts = {})
  data, _status_code, _headers = delete_recipient_with_http_info(recipient_id, opts)
  data
end

#delete_recipient_with_http_info(recipient_id, opts = {}) ⇒ Array<(RecipientResponse, Fixnum, Hash)>

Cancelling a recipient Cancels the payment to the recipient specified in the URL path. Please note recipients where the &#x60;may_cancel&#x60; attribute is true will be cancelled immediately. If the &#x60;may_cancel&#x60; attribute is false you can still try to cancel the recipient, however it will only gets cancelled if we will receive a confirmation from our partner that the payment has failed

Parameters:

  • recipient_id

    ID of recipient to cancel. Example: &#x60;/v1/recipients/9d4d7b73-a94c-4979-ab57-09074fd55d33&#x60;

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

    the optional parameters

Returns:

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

    RecipientResponse 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
# File 'lib/transferzero-sdk/api/recipients_api.rb', line 39

def delete_recipient_with_http_info(recipient_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RecipientsApi.delete_recipient ...'
  end
  # verify the required parameter 'recipient_id' is set
  if @api_client.config.client_side_validation && recipient_id.nil?
    fail ArgumentError, "Missing the required parameter 'recipient_id' when calling RecipientsApi.delete_recipient"
  end
  # resource path
  local_var_path = '/recipients/{Recipient ID}'.sub('{' + 'Recipient ID' + '}', recipient_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(:DELETE, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'RecipientResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RecipientsApi#delete_recipient\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_recipients(opts = {}) ⇒ RecipientListResponse

Getting a list of recipients with filtering Fetches details of all recipients.

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)

  • :created_at_from (String)

    Start date to filter recipients by created_at range Allows filtering results by the specified &#x60;created_at&#x60; timeframe. Example: &#x60;/v1/recipients?created_at_from&#x3D;2018-06-06&amp;created_at_to&#x3D;2018-06-08&#x60;

  • :created_at_to (String)

    End date to filter recipients by created_at range Allows filtering results by the specified &#x60;created_at&#x60; timeframe. Example: &#x60;/v1/recipients?created_at_from&#x3D;2018-06-06&amp;created_at_to&#x3D;2018-06-08&#x60;

  • :amount_from (String)

    Minimum amount to filter recipients by amount range. Allows filtering results by the specified &#x60;amount&#x60; range. When using this filter, the &#x60;currency&#x60; should also be specified. Example: &#x60;/v1/recipients?currency&#x3D;NGN&amp;amount_from&#x3D;83.76672339&amp;amount_to&#x3D;83.76672339&#x60;

  • :amount_to (String)

    Max amount to filter recipients by amount range. Allows filtering results by the specified &#x60;amount&#x60; range. When using this filter, the &#x60;currency&#x60; should also be specified. Example: &#x60;/v1/recipients?currency&#x3D;NGN&amp;amount_from&#x3D;83.76672339&amp;amount_to&#x3D;83.76672339&#x60;

  • :state (Array<String>)

    Allows filtering results by &#x60;state&#x60; of recipient. See [API Documentation - Recipient state](docs.transferzero.com/docs/transaction-flow/#state) for possible states. Example: &#x60;/v1/recipients?state[]&#x3D;error&amp;state&#x3D;initial&#x60;

  • :currency (Array<String>)

    Allows filtering results by &#x60;input_currency&#x60;. Additionally required when filtering by an amount range Example: &#x60;/v1/recipients?currency[]&#x3D;KES&amp;currency&#x3D;NGN&#x60;

Returns:



100
101
102
103
# File 'lib/transferzero-sdk/api/recipients_api.rb', line 100

def get_recipients(opts = {})
  data, _status_code, _headers = get_recipients_with_http_info(opts)
  data
end

#get_recipients_all(opts = {}) ⇒ Object



77
78
79
80
81
82
83
84
85
86
# File 'lib/transferzero-sdk/api/recipients_api.rb', line 77

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

#get_recipients_with_http_info(opts = {}) ⇒ Array<(RecipientListResponse, Fixnum, Hash)>

Getting a list of recipients with filtering Fetches details of all recipients.

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)

  • :created_at_from (String)

    Start date to filter recipients by created_at range Allows filtering results by the specified &#x60;created_at&#x60; timeframe. Example: &#x60;/v1/recipients?created_at_from&#x3D;2018-06-06&amp;created_at_to&#x3D;2018-06-08&#x60;

  • :created_at_to (String)

    End date to filter recipients by created_at range Allows filtering results by the specified &#x60;created_at&#x60; timeframe. Example: &#x60;/v1/recipients?created_at_from&#x3D;2018-06-06&amp;created_at_to&#x3D;2018-06-08&#x60;

  • :amount_from (String)

    Minimum amount to filter recipients by amount range. Allows filtering results by the specified &#x60;amount&#x60; range. When using this filter, the &#x60;currency&#x60; should also be specified. Example: &#x60;/v1/recipients?currency&#x3D;NGN&amp;amount_from&#x3D;83.76672339&amp;amount_to&#x3D;83.76672339&#x60;

  • :amount_to (String)

    Max amount to filter recipients by amount range. Allows filtering results by the specified &#x60;amount&#x60; range. When using this filter, the &#x60;currency&#x60; should also be specified. Example: &#x60;/v1/recipients?currency&#x3D;NGN&amp;amount_from&#x3D;83.76672339&amp;amount_to&#x3D;83.76672339&#x60;

  • :state (Array<String>)

    Allows filtering results by &#x60;state&#x60; of recipient. See [API Documentation - Recipient state](docs.transferzero.com/docs/transaction-flow/#state) for possible states. Example: &#x60;/v1/recipients?state[]&#x3D;error&amp;state&#x3D;initial&#x60;

  • :currency (Array<String>)

    Allows filtering results by &#x60;input_currency&#x60;. Additionally required when filtering by an amount range Example: &#x60;/v1/recipients?currency[]&#x3D;KES&amp;currency&#x3D;NGN&#x60;

Returns:

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

    RecipientListResponse data, response status code and response headers



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
149
150
151
152
153
154
155
156
157
# File 'lib/transferzero-sdk/api/recipients_api.rb', line 117

def get_recipients_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RecipientsApi.get_recipients ...'
  end
  # resource path
  local_var_path = '/recipients'

  # query parameters
  query_params = {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'per'] = opts[:'per'] if !opts[:'per'].nil?
  query_params[:'created_at_from'] = opts[:'created_at_from'] if !opts[:'created_at_from'].nil?
  query_params[:'created_at_to'] = opts[:'created_at_to'] if !opts[:'created_at_to'].nil?
  query_params[:'amount_from'] = opts[:'amount_from'] if !opts[:'amount_from'].nil?
  query_params[:'amount_to'] = opts[:'amount_to'] if !opts[:'amount_to'].nil?
  query_params[:'state'] = @api_client.build_collection_param(opts[:'state'], :multi) if !opts[:'state'].nil?
  query_params[:'currency'] = @api_client.build_collection_param(opts[:'currency'], :multi) if !opts[:'currency'].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 => 'RecipientListResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RecipientsApi#get_recipients\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#patch_recipient(recipient_id, recipient_request, opts = {}) ⇒ RecipientResponse

Updating a recipient Updates the recipient specified in the URL path. Please note that only recipients where the ‘editable` field is true can be modified. Once the recipient is modified any subsequent payout tries will be sent to the updated details.

Parameters:

  • recipient_id

    ID of recipient to update. Example: &#x60;/v1/recipients/9d4d7b73-a94c-4979-ab57-09074fd55d33&#x60;

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

    the optional parameters

Returns:



166
167
168
169
# File 'lib/transferzero-sdk/api/recipients_api.rb', line 166

def patch_recipient(recipient_id, recipient_request, opts = {})
  data, _status_code, _headers = patch_recipient_with_http_info(recipient_id, recipient_request, opts)
  data
end

#patch_recipient_with_http_info(recipient_id, recipient_request, opts = {}) ⇒ Array<(RecipientResponse, Fixnum, Hash)>

Updating a recipient Updates the recipient specified in the URL path. Please note that only recipients where the &#x60;editable&#x60; field is true can be modified. Once the recipient is modified any subsequent payout tries will be sent to the updated details.

Parameters:

  • recipient_id

    ID of recipient to update. Example: &#x60;/v1/recipients/9d4d7b73-a94c-4979-ab57-09074fd55d33&#x60;

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

    the optional parameters

Returns:

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

    RecipientResponse data, response status code and response headers



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
212
213
214
215
216
217
218
219
# File 'lib/transferzero-sdk/api/recipients_api.rb', line 177

def patch_recipient_with_http_info(recipient_id, recipient_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RecipientsApi.patch_recipient ...'
  end
  # verify the required parameter 'recipient_id' is set
  if @api_client.config.client_side_validation && recipient_id.nil?
    fail ArgumentError, "Missing the required parameter 'recipient_id' when calling RecipientsApi.patch_recipient"
  end
  # verify the required parameter 'recipient_request' is set
  if @api_client.config.client_side_validation && recipient_request.nil?
    fail ArgumentError, "Missing the required parameter 'recipient_request' when calling RecipientsApi.patch_recipient"
  end
  # resource path
  local_var_path = '/recipients/{Recipient ID}'.sub('{' + 'Recipient ID' + '}', recipient_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(recipient_request)
  auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'RecipientResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RecipientsApi#patch_recipient\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#proof_of_payments(recipient_id, opts = {}) ⇒ ProofOfPaymentListResponse

Returns list of proof of payments Returns a list of uploaded proof of payment files for a transaction recipient

Parameters:

  • recipient_id

    ID of the recipient for whom the proof of payments will be returned. Example: &#x60;/v1/recipients/9d4d7b73-a94c-4979-ab57-09074fd55d33/proof_of_payments&#x60;

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

    the optional parameters

Returns:



227
228
229
230
# File 'lib/transferzero-sdk/api/recipients_api.rb', line 227

def proof_of_payments(recipient_id, opts = {})
  data, _status_code, _headers = proof_of_payments_with_http_info(recipient_id, opts)
  data
end

#proof_of_payments_with_http_info(recipient_id, opts = {}) ⇒ Array<(ProofOfPaymentListResponse, Fixnum, Hash)>

Returns list of proof of payments Returns a list of uploaded proof of payment files for a transaction recipient

Parameters:

  • recipient_id

    ID of the recipient for whom the proof of payments will be returned. Example: &#x60;/v1/recipients/9d4d7b73-a94c-4979-ab57-09074fd55d33/proof_of_payments&#x60;

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

    the optional parameters

Returns:

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

    ProofOfPaymentListResponse data, response status code and response headers



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
# File 'lib/transferzero-sdk/api/recipients_api.rb', line 237

def proof_of_payments_with_http_info(recipient_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RecipientsApi.proof_of_payments ...'
  end
  # verify the required parameter 'recipient_id' is set
  if @api_client.config.client_side_validation && recipient_id.nil?
    fail ArgumentError, "Missing the required parameter 'recipient_id' when calling RecipientsApi.proof_of_payments"
  end
  # resource path
  local_var_path = '/recipients/{Recipient ID}/proof_of_payments'.sub('{' + 'Recipient ID' + '}', recipient_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 => 'ProofOfPaymentListResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RecipientsApi#proof_of_payments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end