Class: TransferZero::WebhooksApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ WebhooksApi

Returns a new instance of WebhooksApi.



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

def api_client
  @api_client
end

Instance Method Details

#delete_webhook(webhook_id, opts = {}) ⇒ WebhookDefinitionResponse

Unsubscribing from a webhook Unsubscribes from a webhook specified

Parameters:

  • webhook_id

    The ID of webhook to cancel. Example: `/v1/webhooks/9d4d7b73-a94c-4979-ab57-09074fd55d33`

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

    the optional parameters

Returns:



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

def delete_webhook(webhook_id, opts = {})
  data, _status_code, _headers = delete_webhook_with_http_info(webhook_id, opts)
  data
end

#delete_webhook_with_http_info(webhook_id, opts = {}) ⇒ Array<(WebhookDefinitionResponse, Fixnum, Hash)>

Unsubscribing from a webhook Unsubscribes from a webhook specified

Parameters:

  • webhook_id

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

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

    the optional parameters

Returns:

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

    WebhookDefinitionResponse 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/webhooks_api.rb', line 39

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

#get_webhook(webhook_id, opts = {}) ⇒ WebhookDefinitionResponse

Find a webhook’s details Look up a webhook’s details with its ID

Parameters:

  • webhook_id

    The ID of the Webhook to look up Example: &#x60;/v1/webhooks/9d4d7b73-a94c-4979-ab57-09074fd55d33&#x60;

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

    the optional parameters

Returns:



83
84
85
86
# File 'lib/transferzero-sdk/api/webhooks_api.rb', line 83

def get_webhook(webhook_id, opts = {})
  data, _status_code, _headers = get_webhook_with_http_info(webhook_id, opts)
  data
end

#get_webhook_events(opts = {}) ⇒ WebhookDefinitionEventListResponse

Find possible webhook events Fetching possible webhook events

Parameters:

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

    the optional parameters

Returns:



136
137
138
139
# File 'lib/transferzero-sdk/api/webhooks_api.rb', line 136

def get_webhook_events(opts = {})
  data, _status_code, _headers = get_webhook_events_with_http_info(opts)
  data
end

#get_webhook_events_with_http_info(opts = {}) ⇒ Array<(WebhookDefinitionEventListResponse, Fixnum, Hash)>

Find possible webhook events Fetching possible webhook events

Parameters:

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

    the optional parameters

Returns:



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
173
174
175
176
177
# File 'lib/transferzero-sdk/api/webhooks_api.rb', line 145

def get_webhook_events_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.get_webhook_events ...'
  end
  # resource path
  local_var_path = '/webhooks/events'

  # 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 => 'WebhookDefinitionEventListResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#get_webhook_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_webhook_with_http_info(webhook_id, opts = {}) ⇒ Array<(WebhookDefinitionResponse, Fixnum, Hash)>

Find a webhook&#39;s details Look up a webhook&#39;s details with its ID

Parameters:

  • webhook_id

    The ID of the Webhook to look up Example: &#x60;/v1/webhooks/9d4d7b73-a94c-4979-ab57-09074fd55d33&#x60;

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

    the optional parameters

Returns:

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

    WebhookDefinitionResponse data, response status code and response headers



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

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

#get_webhooks(opts = {}) ⇒ WebhookDefinitionListResponse

Listing webhooks Get a list of created webhooks

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)

Returns:



196
197
198
199
# File 'lib/transferzero-sdk/api/webhooks_api.rb', line 196

def get_webhooks(opts = {})
  data, _status_code, _headers = get_webhooks_with_http_info(opts)
  data
end

#get_webhooks_all(opts = {}) ⇒ Object



179
180
181
182
183
184
185
186
187
188
# File 'lib/transferzero-sdk/api/webhooks_api.rb', line 179

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

#get_webhooks_with_http_info(opts = {}) ⇒ Array<(WebhookDefinitionListResponse, Fixnum, Hash)>

Listing webhooks Get a list of created webhooks

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)

Returns:



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

def get_webhooks_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.get_webhooks ...'
  end
  # resource path
  local_var_path = '/webhooks'

  # query parameters
  query_params = {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'per'] = opts[:'per'] if !opts[:'per'].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 => 'WebhookDefinitionListResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#get_webhooks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#post_webhooks(webhook_definition_request, opts = {}) ⇒ WebhookDefinitionResponse

Creating a webhook Creates a new webhook, subscribing the provided endpoint to the specified event(s)

Parameters:

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

    the optional parameters

Returns:



249
250
251
252
# File 'lib/transferzero-sdk/api/webhooks_api.rb', line 249

def post_webhooks(webhook_definition_request, opts = {})
  data, _status_code, _headers = post_webhooks_with_http_info(webhook_definition_request, opts)
  data
end

#post_webhooks_with_http_info(webhook_definition_request, opts = {}) ⇒ Array<(WebhookDefinitionResponse, Fixnum, Hash)>

Creating a webhook Creates a new webhook, subscribing the provided endpoint to the specified event(s)

Parameters:

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

    the optional parameters

Returns:

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

    WebhookDefinitionResponse data, response status code and response headers



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

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

  # 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(webhook_definition_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 => 'WebhookDefinitionResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#post_webhooks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end