ultracart_api 4.1.162 → 4.1.164

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/docs/WebhookApi.md CHANGED
@@ -1,840 +1,840 @@
1
- # UltracartClient::WebhookApi
2
-
3
- All URIs are relative to *https://secure.ultracart.com/rest/v2*
4
-
5
- | Method | HTTP request | Description |
6
- | ------ | ------------ | ----------- |
7
- | [**delete_webhook**](WebhookApi.md#delete_webhook) | **DELETE** /webhook/webhooks/{webhookOid} | Delete a webhook |
8
- | [**delete_webhook_by_url**](WebhookApi.md#delete_webhook_by_url) | **DELETE** /webhook/webhooks | Delete a webhook by URL |
9
- | [**get_webhook_event_categories**](WebhookApi.md#get_webhook_event_categories) | **GET** /webhook/webhook_event_categories | Retrieve webhook event categories |
10
- | [**get_webhook_log**](WebhookApi.md#get_webhook_log) | **GET** /webhook/webhooks/{webhookOid}/logs/{requestId} | Retrieve an individual log |
11
- | [**get_webhook_log_summaries**](WebhookApi.md#get_webhook_log_summaries) | **GET** /webhook/webhooks/{webhookOid}/logs | Retrieve the log summaries |
12
- | [**get_webhooks**](WebhookApi.md#get_webhooks) | **GET** /webhook/webhooks | Retrieve webhooks |
13
- | [**insert_webhook**](WebhookApi.md#insert_webhook) | **POST** /webhook/webhooks | Add a webhook |
14
- | [**resend_event**](WebhookApi.md#resend_event) | **POST** /webhook/webhooks/{webhookOid}/reflow/{eventName} | Resend events to the webhook endpoint. |
15
- | [**update_webhook**](WebhookApi.md#update_webhook) | **PUT** /webhook/webhooks/{webhookOid} | Update a webhook |
16
-
17
-
18
- ## delete_webhook
19
-
20
- > delete_webhook(webhook_oid)
21
-
22
- Delete a webhook
23
-
24
- Delete a webhook on the UltraCart account.
25
-
26
-
27
- ### Examples
28
-
29
- ```ruby
30
- require 'ultracart_api'
31
- require_relative '../constants'
32
-
33
- # deletes a webhook
34
- #
35
- # You will need the webhook_oid to call this method. Call getWebhooks() if you don't know your oid.
36
- # Returns status code 204 (No Content) on success
37
-
38
- webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
39
- webhook_oid = 123456789 # call getWebhooks if you don't know this.
40
- webhook_api.delete_webhook(webhook_oid)
41
- ```
42
-
43
-
44
- #### Using the delete_webhook_with_http_info variant
45
-
46
- This returns an Array which contains the response data (`nil` in this case), status code and headers.
47
-
48
- > <Array(nil, Integer, Hash)> delete_webhook_with_http_info(webhook_oid)
49
-
50
- ```ruby
51
- begin
52
- # Delete a webhook
53
- data, status_code, headers = api_instance.delete_webhook_with_http_info(webhook_oid)
54
- p status_code # => 2xx
55
- p headers # => { ... }
56
- p data # => nil
57
- rescue UltracartClient::ApiError => e
58
- puts "Error when calling WebhookApi->delete_webhook_with_http_info: #{e}"
59
- end
60
- ```
61
-
62
- ### Parameters
63
-
64
- | Name | Type | Description | Notes |
65
- | ---- | ---- | ----------- | ----- |
66
- | **webhook_oid** | **Integer** | The webhook oid to delete. | |
67
-
68
- ### Return type
69
-
70
- nil (empty response body)
71
-
72
- ### Authorization
73
-
74
- [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
75
-
76
- ### HTTP request headers
77
-
78
- - **Content-Type**: Not defined
79
- - **Accept**: application/json
80
-
81
-
82
- ## delete_webhook_by_url
83
-
84
- > <WebhookResponse> delete_webhook_by_url(webhook)
85
-
86
- Delete a webhook by URL
87
-
88
- Delete a webhook based upon the URL on the webhook_url matching an existing webhook.
89
-
90
-
91
- ### Examples
92
-
93
- ```ruby
94
- require 'ultracart_api'
95
- require_relative '../constants'
96
-
97
- # This method can be confusing due to its payload. The method does indeed delete a webhook by url, but you need to
98
- # pass a webhook object in as the payload. However, only the url is used. UltraCart does this to avoid any confusion
99
- # with the rest url versus the webhook url.
100
- #
101
- # To use:
102
- # Get your webhook url.
103
- # Create a Webhook object.
104
- # Set the Webhook url property.
105
- # Pass the webhook to deleteWebhookByUrl()
106
- #
107
- # Returns status code 204 (No Content) on success
108
-
109
- webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
110
-
111
- webhook_url = "https://www.mywebiste.com/page/to/call/when/this/webhook/fires.php"
112
- webhook = UltracartClient::Webhook.new
113
- webhook.webhook_url = webhook_url
114
-
115
- webhook_api.delete_webhook_by_url(webhook)
116
- ```
117
-
118
-
119
- #### Using the delete_webhook_by_url_with_http_info variant
120
-
121
- This returns an Array which contains the response data, status code and headers.
122
-
123
- > <Array(<WebhookResponse>, Integer, Hash)> delete_webhook_by_url_with_http_info(webhook)
124
-
125
- ```ruby
126
- begin
127
- # Delete a webhook by URL
128
- data, status_code, headers = api_instance.delete_webhook_by_url_with_http_info(webhook)
129
- p status_code # => 2xx
130
- p headers # => { ... }
131
- p data # => <WebhookResponse>
132
- rescue UltracartClient::ApiError => e
133
- puts "Error when calling WebhookApi->delete_webhook_by_url_with_http_info: #{e}"
134
- end
135
- ```
136
-
137
- ### Parameters
138
-
139
- | Name | Type | Description | Notes |
140
- | ---- | ---- | ----------- | ----- |
141
- | **webhook** | [**Webhook**](Webhook.md) | Webhook to delete | |
142
-
143
- ### Return type
144
-
145
- [**WebhookResponse**](WebhookResponse.md)
146
-
147
- ### Authorization
148
-
149
- [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
150
-
151
- ### HTTP request headers
152
-
153
- - **Content-Type**: application/json; charset=UTF-8
154
- - **Accept**: application/json
155
-
156
-
157
- ## get_webhook_event_categories
158
-
159
- > <WebhookEventCategoriesResponse> get_webhook_event_categories
160
-
161
- Retrieve webhook event categories
162
-
163
- Retrieves the available webhook event categories and events with backend-owned metadata (OIDs, names, descriptions, available expansions, flags) independent of whether any webhooks are saved. Used by the New Webhook editor so a merchant with zero webhooks can still see the catalog.
164
-
165
-
166
- ### Examples
167
-
168
-
169
- (No example for this operation).
170
-
171
-
172
- #### Using the get_webhook_event_categories_with_http_info variant
173
-
174
- This returns an Array which contains the response data, status code and headers.
175
-
176
- > <Array(<WebhookEventCategoriesResponse>, Integer, Hash)> get_webhook_event_categories_with_http_info
177
-
178
- ```ruby
179
- begin
180
- # Retrieve webhook event categories
181
- data, status_code, headers = api_instance.get_webhook_event_categories_with_http_info
182
- p status_code # => 2xx
183
- p headers # => { ... }
184
- p data # => <WebhookEventCategoriesResponse>
185
- rescue UltracartClient::ApiError => e
186
- puts "Error when calling WebhookApi->get_webhook_event_categories_with_http_info: #{e}"
187
- end
188
- ```
189
-
190
- ### Parameters
191
-
192
- This endpoint does not need any parameter.
193
-
194
- ### Return type
195
-
196
- [**WebhookEventCategoriesResponse**](WebhookEventCategoriesResponse.md)
197
-
198
- ### Authorization
199
-
200
- [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
201
-
202
- ### HTTP request headers
203
-
204
- - **Content-Type**: Not defined
205
- - **Accept**: application/json
206
-
207
-
208
- ## get_webhook_log
209
-
210
- > <WebhookLogResponse> get_webhook_log(webhook_oid, request_id)
211
-
212
- Retrieve an individual log
213
-
214
- Retrieves an individual log for a webhook given the webhook oid the request id.
215
-
216
-
217
- ### Examples
218
-
219
- ```ruby
220
- require 'ultracart_api'
221
- require_relative '../constants'
222
-
223
- # getWebhookLog() provides a detail log of a webhook event. It is used in tandem with getWebhookLogSummaries to audit
224
- # webhook events. This method call will require the webhook_oid and the request_id. The webhook_oid can be discerned
225
- # from the results of getWebhooks() and the request_id can be found from getWebhookLogSummaries(). see those examples
226
- # if needed.
227
-
228
- webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
229
-
230
- webhook_oid = 123456789 # call getWebhooks if you don't know this.
231
- request_id = '987654321' # call getWebhookLogSummaries if you don't know this.
232
-
233
- api_response = webhook_api.get_webhook_log(webhook_oid, request_id)
234
- webhook_log = api_response.webhook_log
235
-
236
- if api_response.error
237
- puts api_response.error.developer_message
238
- puts api_response.error.user_message
239
- exit
240
- end
241
-
242
- puts webhook_log
243
- ```
244
-
245
-
246
- #### Using the get_webhook_log_with_http_info variant
247
-
248
- This returns an Array which contains the response data, status code and headers.
249
-
250
- > <Array(<WebhookLogResponse>, Integer, Hash)> get_webhook_log_with_http_info(webhook_oid, request_id)
251
-
252
- ```ruby
253
- begin
254
- # Retrieve an individual log
255
- data, status_code, headers = api_instance.get_webhook_log_with_http_info(webhook_oid, request_id)
256
- p status_code # => 2xx
257
- p headers # => { ... }
258
- p data # => <WebhookLogResponse>
259
- rescue UltracartClient::ApiError => e
260
- puts "Error when calling WebhookApi->get_webhook_log_with_http_info: #{e}"
261
- end
262
- ```
263
-
264
- ### Parameters
265
-
266
- | Name | Type | Description | Notes |
267
- | ---- | ---- | ----------- | ----- |
268
- | **webhook_oid** | **Integer** | The webhook oid that owns the log. | |
269
- | **request_id** | **String** | The request id associated with the log to view. | |
270
-
271
- ### Return type
272
-
273
- [**WebhookLogResponse**](WebhookLogResponse.md)
274
-
275
- ### Authorization
276
-
277
- [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
278
-
279
- ### HTTP request headers
280
-
281
- - **Content-Type**: Not defined
282
- - **Accept**: application/json
283
-
284
-
285
- ## get_webhook_log_summaries
286
-
287
- > <WebhookLogSummariesResponse> get_webhook_log_summaries(webhook_oid, opts)
288
-
289
- Retrieve the log summaries
290
-
291
- Retrieves the log summary information for a given webhook. This is useful for displaying all the various logs that can be viewed.
292
-
293
-
294
- ### Examples
295
-
296
- ```ruby
297
- require 'ultracart_api'
298
- require_relative '../constants'
299
-
300
- # This example illustrates how to retrieve webhook log summaries.
301
-
302
- webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
303
-
304
- def get_summary_chunk(webhook_api, offset, limit)
305
- webhook_oid = 123456789 # if you don't know this, use getWebhooks to find your webhook, then get its oid.
306
- _since = (Date.today - 10).strftime('%Y-%m-%d') + "T00:00:00+00:00" # get the last 10 days
307
- # Pay attention to whether limit or offset comes first in the method signature. UltraCart is not consistent with their ordering.
308
- api_response = webhook_api.get_webhook_log_summaries(webhook_oid, limit, offset, _since)
309
-
310
- return api_response.webhook_log_summaries if api_response.webhook_log_summaries
311
- []
312
- end
313
-
314
- summaries = []
315
-
316
- iteration = 1
317
- offset = 0
318
- limit = 200
319
- more_records_to_fetch = true
320
-
321
- begin
322
- while more_records_to_fetch
323
- puts "executing iteration #{iteration}"
324
-
325
- chunk_of_summaries = get_summary_chunk(webhook_api, offset, limit)
326
- summaries.concat(chunk_of_summaries)
327
- offset = offset + limit
328
- more_records_to_fetch = chunk_of_summaries.length == limit
329
- iteration += 1
330
- end
331
- rescue UltracartClient::ApiError => e
332
- puts "ApiError occurred on iteration #{iteration}"
333
- puts e.inspect
334
- exit 1
335
- end
336
-
337
- # this will be verbose...
338
- puts summaries.inspect
339
- ```
340
-
341
-
342
- #### Using the get_webhook_log_summaries_with_http_info variant
343
-
344
- This returns an Array which contains the response data, status code and headers.
345
-
346
- > <Array(<WebhookLogSummariesResponse>, Integer, Hash)> get_webhook_log_summaries_with_http_info(webhook_oid, opts)
347
-
348
- ```ruby
349
- begin
350
- # Retrieve the log summaries
351
- data, status_code, headers = api_instance.get_webhook_log_summaries_with_http_info(webhook_oid, opts)
352
- p status_code # => 2xx
353
- p headers # => { ... }
354
- p data # => <WebhookLogSummariesResponse>
355
- rescue UltracartClient::ApiError => e
356
- puts "Error when calling WebhookApi->get_webhook_log_summaries_with_http_info: #{e}"
357
- end
358
- ```
359
-
360
- ### Parameters
361
-
362
- | Name | Type | Description | Notes |
363
- | ---- | ---- | ----------- | ----- |
364
- | **webhook_oid** | **Integer** | The webhook oid to retrieve log summaries for. | |
365
- | **request_id** | **String** | Filter by request id | [optional] |
366
- | **begin_date** | **String** | Filter to deliveries on or after this date/time | [optional] |
367
- | **end_date** | **String** | Filter to deliveries on or before this date/time | [optional] |
368
- | **status** | **String** | Filter by HTTP status code | [optional] |
369
- | **success** | **Boolean** | Filter by success (true) or failure (false) | [optional] |
370
- | **event** | **String** | Filter by an event name contained in the delivery | [optional] |
371
- | **order_id** | **String** | Filter by an order id contained in the delivery | [optional] |
372
- | **request** | **String** | Filter by text contained in the request payload | [optional] |
373
- | **duration** | **Integer** | Filter to deliveries that took at least this many milliseconds | [optional] |
374
- | **_limit** | **Integer** | The maximum number of records to return on this one API call. | [optional][default to 100] |
375
- | **_offset** | **Integer** | Pagination of the record set. Offset is a zero based index. | [optional][default to 0] |
376
- | **_since** | **String** | Fetch log summaries that have been delivered since this date/time. | [optional] |
377
-
378
- ### Return type
379
-
380
- [**WebhookLogSummariesResponse**](WebhookLogSummariesResponse.md)
381
-
382
- ### Authorization
383
-
384
- [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
385
-
386
- ### HTTP request headers
387
-
388
- - **Content-Type**: Not defined
389
- - **Accept**: application/json
390
-
391
-
392
- ## get_webhooks
393
-
394
- > <WebhooksResponse> get_webhooks(opts)
395
-
396
- Retrieve webhooks
397
-
398
- Retrieves the webhooks associated with this application.
399
-
400
-
401
- ### Examples
402
-
403
- ```ruby
404
- require 'ultracart_api'
405
- require_relative '../constants'
406
-
407
- # This example illustrates how to retrieve all webhooks.
408
-
409
- webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
410
-
411
- def get_webhook_chunk(webhook_api, offset, limit)
412
- _sort = nil # default sorting is webhook_url, disabled, and those are also the two choices for sorting.
413
- _placeholders = nil # useful for UI displays, but not needed here.
414
- # Pay attention to whether limit or offset comes first in the method signature. UltraCart is not consistent with their ordering.
415
- opts = {
416
- '_sort' => _sort,
417
- '_placeholders' => _placeholders
418
- }
419
- api_response = webhook_api.get_webhooks(limit, offset, opts)
420
-
421
- return api_response.webhooks if api_response.webhooks
422
- []
423
- end
424
-
425
- webhooks = []
426
-
427
- iteration = 1
428
- offset = 0
429
- limit = 200
430
- more_records_to_fetch = true
431
-
432
- begin
433
- while more_records_to_fetch
434
- puts "executing iteration #{iteration}"
435
-
436
- chunk_of_webhooks = get_webhook_chunk(webhook_api, offset, limit)
437
- webhooks.concat(chunk_of_webhooks)
438
- offset = offset + limit
439
- more_records_to_fetch = chunk_of_webhooks.length == limit
440
- iteration += 1
441
- end
442
- rescue UltracartClient::ApiError => e
443
- puts "ApiError occurred on iteration #{iteration}"
444
- puts e.inspect
445
- exit 1
446
- end
447
-
448
- # this will be verbose...
449
- puts webhooks.inspect
450
- ```
451
-
452
-
453
- #### Using the get_webhooks_with_http_info variant
454
-
455
- This returns an Array which contains the response data, status code and headers.
456
-
457
- > <Array(<WebhooksResponse>, Integer, Hash)> get_webhooks_with_http_info(opts)
458
-
459
- ```ruby
460
- begin
461
- # Retrieve webhooks
462
- data, status_code, headers = api_instance.get_webhooks_with_http_info(opts)
463
- p status_code # => 2xx
464
- p headers # => { ... }
465
- p data # => <WebhooksResponse>
466
- rescue UltracartClient::ApiError => e
467
- puts "Error when calling WebhookApi->get_webhooks_with_http_info: #{e}"
468
- end
469
- ```
470
-
471
- ### Parameters
472
-
473
- | Name | Type | Description | Notes |
474
- | ---- | ---- | ----------- | ----- |
475
- | **_limit** | **Integer** | The maximum number of records to return on this one API call. | [optional][default to 100] |
476
- | **_offset** | **Integer** | Pagination of the record set. Offset is a zero based index. | [optional][default to 0] |
477
- | **_sort** | **String** | The sort order of the webhooks. See documentation for examples | [optional] |
478
- | **_placeholders** | **Boolean** | Whether or not placeholder values should be returned in the result. Useful for UIs that consume this REST API. | [optional] |
479
-
480
- ### Return type
481
-
482
- [**WebhooksResponse**](WebhooksResponse.md)
483
-
484
- ### Authorization
485
-
486
- [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
487
-
488
- ### HTTP request headers
489
-
490
- - **Content-Type**: Not defined
491
- - **Accept**: application/json
492
-
493
-
494
- ## insert_webhook
495
-
496
- > <WebhookResponse> insert_webhook(webhook, opts)
497
-
498
- Add a webhook
499
-
500
- Adds a new webhook on the account. If you add a new webhook with the authentication_type set to basic, but do not specify the basic_username and basic_password, UltraCart will automatically generate random ones and return them. This allows your application to have simpler logic on the setup of a secure webhook.
501
-
502
-
503
- ### Examples
504
-
505
- ```ruby
506
- require 'ultracart_api'
507
- require_relative '../constants'
508
-
509
- # Adds a new webhook on the account. If you add a new webhook with the authentication_type set to basic, but
510
- # do not specify the basic_username and basic_password, UltraCart will automatically generate random ones and
511
- # return them. This allows your application to have simpler logic on the setup of a secure webhook.
512
- #
513
- # Event Category Event Name Description
514
- # auto_order auto_order_cancel Fired when an auto order is canceled
515
- # auto_order auto_order_create Fired when an auto order is created
516
- # auto_order auto_order_decline Fired when an auto order is declined
517
- # auto_order auto_order_disable Fired when an auto order is disabled
518
- # auto_order auto_order_preshipment Fired when an auto order generates a new pre-shipment notice
519
- # auto_order auto_order_rebill Fired when an auto order is rebilled
520
- # auto_order auto_order_update Fired when an auto order is updated
521
- # chargeback chargeback_create Fired when a chargeback is created
522
- # chargeback chargeback_delete Fired when a chargeback is deleted
523
- # chargeback chargeback_update Fired when a chargeback is updated
524
- # checkout checkout_cart_abandon Fired when a cart is abandoned
525
- # checkout checkout_cart_send_return_email Fired when a return email should be sent to a customer
526
- # customer customer_create Fired when a customer profile is created.
527
- # customer customer_delete Fired when a customer profile is deleted.
528
- # customer customer_update Fired when a customer profile is updated.
529
- # fulfillment fulfillment_hold Fired when an order is held for review
530
- # fulfillment fulfillment_transmit Fired to transmit an order to the fulfillment house
531
- # item item_create Fired when a new item is created.
532
- # item item_delete Fired when an item is deleted.
533
- # item item_update Fired when an item is updated.
534
- # order order_abandon_recovery Fired when a previously abandoned cart turns into an order
535
- # order order_create Fired when an order is placed
536
- # order order_delete Fired when an order is deleted
537
- # order order_payment_failed Fired when a payment fails
538
- # order order_payment_process Fired when a payment is processed
539
- # order order_refund Fired when an order is refunded
540
- # order order_reject Fired when an order is rejected
541
- # order order_s3_invoice Fired when an invoice PDF is stored in S3 bucket
542
- # order order_s3_packing_slip Fired when a packing slip PDF is stored in an S3 bucket
543
- # order order_ship Fired when an order is shipped
544
- # order order_ship_delivered Fired when an order has a shipment delivered
545
- # order order_ship_expected Fired when an order has an expected delivery date
546
- # order order_ship_out_for_delivery Fired when an order has a shipment out for delivery
547
- # order order_stage_change Fired when an order stage changes
548
- # order order_update Fired when an order is edited
549
- # storefront screen_recording Fired when a screen recording is created
550
- # user user_create Fired when a user is created
551
- # user user_delete Fired when a user is deleted
552
- # user user_login Fired when a user logs in
553
- # user user_update Fired when a user is updated
554
- # workflow_task workflow_task_create Fired when a workflow task is created
555
- # workflow_task workflow_task_delete Fired when a workflow task is deleted
556
- # workflow_task workflow_task_update Fired when a workflow task is updated
557
- #
558
- # Note: Each event uses the same expansions as the event category. To see a list of possible expansion values,
559
- # visit www.ultracart.com/api/. Order Expansions (https://www.ultracart.com/api/#resource_order.html) are listed
560
- # below because most webhooks are for order events.
561
- # Order Expansion:
562
- # affiliate auto_order billing checkout
563
- # affiliate.ledger channel_partner coupon customer_profile
564
- # digital_order edi fraud_score gift
565
- # gift_certificate internal item linked_shipment
566
- # marketing payment payment.transaction point_of_sale
567
- # quote salesforce shipping shipping.tracking_number_details
568
- # summary taxes utms
569
- #
570
- # Note: The WebhookEventSubscription.event_ruler field is processed with the AWS Event Ruler library to filter down
571
- # events to just what you want. If you wish to employ a ruler filter, see https://github.com/aws/event-ruler
572
- # for syntax examples. You'll need to apply the aws syntax against the UltraCart object models. Contact UltraCart
573
- # support if you need assistance creating the proper ruler expression.
574
-
575
- webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
576
-
577
- webhook = UltracartClient::Webhook.new
578
- webhook.webhook_url = "https://www.mywebiste.com/page/to/call/when/this/webhook/fires.php" # Must be HTTPS if customer related information is being delivered.
579
- webhook.authentication_type = "basic" # "basic","none","api user","aws iam"
580
- webhook.basic_username = "george"
581
- webhook.basic_password = "LlamaLlamaRedPajama"
582
- webhook.maximum_events = 10
583
- webhook.maximum_size = 5242880 # 5 MB is pretty chunky.
584
- webhook.api_version = "2017-03-01" # this is our only API version so far.
585
- webhook.compress_events = true # compress events with gzip, then base64 encode them as a string.
586
-
587
- event_sub1 = UltracartClient::WebhookEventSubscription.new
588
- event_sub1.event_name = "order_create"
589
- event_sub1.event_description = "when an order is placed"
590
- event_sub1.expansion = "shipping,billing,item,coupon,summary" # whatever you need.
591
- event_sub1.event_ruler = nil # no filtering. we want all objects.
592
- event_sub1.comments = "Merchant specific comment, for example: Bobby needs this webhook for the Accounting department."
593
-
594
- event_sub2 = UltracartClient::WebhookEventSubscription.new
595
- event_sub2.event_name = "order_update"
596
- event_sub2.event_description = "when an order is modified"
597
- event_sub2.expansion = "shipping,billing,item,coupon,summary" # whatever you need.
598
- event_sub2.event_ruler = nil # no filtering. we want all objects.
599
- event_sub2.comments = "Merchant specific comment, for example: Bobby needs this webhook for the Accounting department."
600
-
601
- event_sub3 = UltracartClient::WebhookEventSubscription.new
602
- event_sub3.event_name = "order_delete"
603
- event_sub3.event_description = "when an order is modified"
604
- event_sub3.expansion = "" # don't need any expansion on delete. only need to know the order_id
605
- event_sub3.event_ruler = nil # no filtering. we want all objects.
606
- event_sub3.comments = "Merchant specific comment, for example: Bobby needs this webhook for the Accounting department."
607
-
608
- event_category1 = UltracartClient::WebhookEventCategory.new
609
- event_category1.event_category = "order"
610
- event_category1.events = [event_sub1, event_sub2, event_sub3]
611
-
612
- # api_response.webhook will return the newly created webhook.
613
- api_response = webhook_api.insert_webhook(webhook, false)
614
-
615
- if api_response.error
616
- puts api_response.error.developer_message
617
- puts api_response.error.user_message
618
- exit
619
- end
620
-
621
- created_webhook = api_response.webhook
622
- # TODO - store the webhook oid in case you ever need to make changes.
623
-
624
- # This should equal what you submitted, plus contain much new information
625
- puts created_webhook.inspect
626
- ```
627
-
628
-
629
- #### Using the insert_webhook_with_http_info variant
630
-
631
- This returns an Array which contains the response data, status code and headers.
632
-
633
- > <Array(<WebhookResponse>, Integer, Hash)> insert_webhook_with_http_info(webhook, opts)
634
-
635
- ```ruby
636
- begin
637
- # Add a webhook
638
- data, status_code, headers = api_instance.insert_webhook_with_http_info(webhook, opts)
639
- p status_code # => 2xx
640
- p headers # => { ... }
641
- p data # => <WebhookResponse>
642
- rescue UltracartClient::ApiError => e
643
- puts "Error when calling WebhookApi->insert_webhook_with_http_info: #{e}"
644
- end
645
- ```
646
-
647
- ### Parameters
648
-
649
- | Name | Type | Description | Notes |
650
- | ---- | ---- | ----------- | ----- |
651
- | **webhook** | [**Webhook**](Webhook.md) | Webhook to create | |
652
- | **_placeholders** | **Boolean** | Whether or not placeholder values should be returned in the result. Useful for UIs that consume this REST API. | [optional] |
653
-
654
- ### Return type
655
-
656
- [**WebhookResponse**](WebhookResponse.md)
657
-
658
- ### Authorization
659
-
660
- [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
661
-
662
- ### HTTP request headers
663
-
664
- - **Content-Type**: application/json; charset=UTF-8
665
- - **Accept**: application/json
666
-
667
-
668
- ## resend_event
669
-
670
- > <WebhookReflowResponse> resend_event(webhook_oid, event_name)
671
-
672
- Resend events to the webhook endpoint.
673
-
674
- This method will resend events to the webhook endpoint. This method can be used for example to send all the existing items on an account to a webhook.
675
-
676
-
677
- ### Examples
678
-
679
- ```ruby
680
- require 'ultracart_api'
681
- require_relative '../constants'
682
-
683
- # resentEvent is used to reflow an event. It will resend ALL events in history. So it is essentially a way to
684
- # get all objects from an event. Currently, there are only two events available for reflow: "item_update", and "order_create".
685
- # These two events provide the means to have a webhook receive all items or orders. This method is usually called
686
- # at the beginning of a webhook's life to prepopulate a merchant's database with all items or orders.
687
- #
688
- # You will need the webhook_oid to call this method. Call getWebhooks() if you don't know your oid.
689
-
690
- webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
691
-
692
- webhook_oid = 123456789 # call getWebhooks if you don't know this.
693
- event_name = "item_update" # or "order_create", but for this sample, we want all items.
694
-
695
- api_response = webhook_api.resend_event(webhook_oid, event_name)
696
- reflow = api_response.reflow
697
- success = reflow.queued
698
-
699
- if api_response.error
700
- puts api_response.error.developer_message
701
- puts api_response.error.user_message
702
- exit
703
- end
704
-
705
- puts api_response.inspect
706
- ```
707
-
708
-
709
- #### Using the resend_event_with_http_info variant
710
-
711
- This returns an Array which contains the response data, status code and headers.
712
-
713
- > <Array(<WebhookReflowResponse>, Integer, Hash)> resend_event_with_http_info(webhook_oid, event_name)
714
-
715
- ```ruby
716
- begin
717
- # Resend events to the webhook endpoint.
718
- data, status_code, headers = api_instance.resend_event_with_http_info(webhook_oid, event_name)
719
- p status_code # => 2xx
720
- p headers # => { ... }
721
- p data # => <WebhookReflowResponse>
722
- rescue UltracartClient::ApiError => e
723
- puts "Error when calling WebhookApi->resend_event_with_http_info: #{e}"
724
- end
725
- ```
726
-
727
- ### Parameters
728
-
729
- | Name | Type | Description | Notes |
730
- | ---- | ---- | ----------- | ----- |
731
- | **webhook_oid** | **Integer** | The webhook oid that is receiving the reflowed events. | |
732
- | **event_name** | **String** | The event to reflow. | |
733
-
734
- ### Return type
735
-
736
- [**WebhookReflowResponse**](WebhookReflowResponse.md)
737
-
738
- ### Authorization
739
-
740
- [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
741
-
742
- ### HTTP request headers
743
-
744
- - **Content-Type**: Not defined
745
- - **Accept**: application/json
746
-
747
-
748
- ## update_webhook
749
-
750
- > <WebhookResponse> update_webhook(webhook_oid, webhook, opts)
751
-
752
- Update a webhook
753
-
754
- Update a webhook on the account
755
-
756
-
757
- ### Examples
758
-
759
- ```ruby
760
- require 'ultracart_api'
761
- require_relative '../constants'
762
-
763
- # Updates a webhook on the account. See insertWebhook.php for a complete example with field usage.
764
- # For this example, we are just updating the basic password.
765
-
766
- webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
767
-
768
- # you should have stored this when you created the webhook. If you don't know it, call getWebhooks and iterate through
769
- # them to find you target webhook (add useful comments to each webhook really helps in this endeavor) and get the
770
- # webhook oid from that. You'll want to call getWebhooks any way to get the object for updating. It is HIGHLY
771
- # recommended to get the object from UltraCart for updating rather than constructing it yourself to avoid accidentally
772
- # deleting a part of the object during the update.
773
- webhook_oid = 123456789
774
-
775
- webhook_to_update = nil
776
- opts = {
777
- '_sort' => nil,
778
- '_placeholders' => nil
779
- }
780
- webhooks = webhook_api.get_webhooks(100, 0, opts).webhooks
781
- webhooks.each do |webhook|
782
- if webhook.webhook_oid == webhook_oid
783
- webhook_to_update = webhook
784
- break
785
- end
786
- end
787
-
788
- webhook_to_update.basic_password = "new password here"
789
- api_response = webhook_api.update_webhook(webhook_oid, webhook_to_update)
790
- updated_webhook = api_response.webhook
791
-
792
- if api_response.error
793
- puts api_response.error.developer_message
794
- puts api_response.error.user_message
795
- exit
796
- end
797
-
798
- puts updated_webhook.inspect
799
- ```
800
-
801
-
802
- #### Using the update_webhook_with_http_info variant
803
-
804
- This returns an Array which contains the response data, status code and headers.
805
-
806
- > <Array(<WebhookResponse>, Integer, Hash)> update_webhook_with_http_info(webhook_oid, webhook, opts)
807
-
808
- ```ruby
809
- begin
810
- # Update a webhook
811
- data, status_code, headers = api_instance.update_webhook_with_http_info(webhook_oid, webhook, opts)
812
- p status_code # => 2xx
813
- p headers # => { ... }
814
- p data # => <WebhookResponse>
815
- rescue UltracartClient::ApiError => e
816
- puts "Error when calling WebhookApi->update_webhook_with_http_info: #{e}"
817
- end
818
- ```
819
-
820
- ### Parameters
821
-
822
- | Name | Type | Description | Notes |
823
- | ---- | ---- | ----------- | ----- |
824
- | **webhook_oid** | **Integer** | The webhook oid to update. | |
825
- | **webhook** | [**Webhook**](Webhook.md) | Webhook to update | |
826
- | **_placeholders** | **Boolean** | Whether or not placeholder values should be returned in the result. Useful for UIs that consume this REST API. | [optional] |
827
-
828
- ### Return type
829
-
830
- [**WebhookResponse**](WebhookResponse.md)
831
-
832
- ### Authorization
833
-
834
- [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
835
-
836
- ### HTTP request headers
837
-
838
- - **Content-Type**: application/json; charset=UTF-8
839
- - **Accept**: application/json
840
-
1
+ # UltracartClient::WebhookApi
2
+
3
+ All URIs are relative to *https://secure.ultracart.com/rest/v2*
4
+
5
+ | Method | HTTP request | Description |
6
+ | ------ | ------------ | ----------- |
7
+ | [**delete_webhook**](WebhookApi.md#delete_webhook) | **DELETE** /webhook/webhooks/{webhookOid} | Delete a webhook |
8
+ | [**delete_webhook_by_url**](WebhookApi.md#delete_webhook_by_url) | **DELETE** /webhook/webhooks | Delete a webhook by URL |
9
+ | [**get_webhook_event_categories**](WebhookApi.md#get_webhook_event_categories) | **GET** /webhook/webhook_event_categories | Retrieve webhook event categories |
10
+ | [**get_webhook_log**](WebhookApi.md#get_webhook_log) | **GET** /webhook/webhooks/{webhookOid}/logs/{requestId} | Retrieve an individual log |
11
+ | [**get_webhook_log_summaries**](WebhookApi.md#get_webhook_log_summaries) | **GET** /webhook/webhooks/{webhookOid}/logs | Retrieve the log summaries |
12
+ | [**get_webhooks**](WebhookApi.md#get_webhooks) | **GET** /webhook/webhooks | Retrieve webhooks |
13
+ | [**insert_webhook**](WebhookApi.md#insert_webhook) | **POST** /webhook/webhooks | Add a webhook |
14
+ | [**resend_event**](WebhookApi.md#resend_event) | **POST** /webhook/webhooks/{webhookOid}/reflow/{eventName} | Resend events to the webhook endpoint. |
15
+ | [**update_webhook**](WebhookApi.md#update_webhook) | **PUT** /webhook/webhooks/{webhookOid} | Update a webhook |
16
+
17
+
18
+ ## delete_webhook
19
+
20
+ > delete_webhook(webhook_oid)
21
+
22
+ Delete a webhook
23
+
24
+ Delete a webhook on the UltraCart account.
25
+
26
+
27
+ ### Examples
28
+
29
+ ```ruby
30
+ require 'ultracart_api'
31
+ require_relative '../constants'
32
+
33
+ # deletes a webhook
34
+ #
35
+ # You will need the webhook_oid to call this method. Call getWebhooks() if you don't know your oid.
36
+ # Returns status code 204 (No Content) on success
37
+
38
+ webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
39
+ webhook_oid = 123456789 # call getWebhooks if you don't know this.
40
+ webhook_api.delete_webhook(webhook_oid)
41
+ ```
42
+
43
+
44
+ #### Using the delete_webhook_with_http_info variant
45
+
46
+ This returns an Array which contains the response data (`nil` in this case), status code and headers.
47
+
48
+ > <Array(nil, Integer, Hash)> delete_webhook_with_http_info(webhook_oid)
49
+
50
+ ```ruby
51
+ begin
52
+ # Delete a webhook
53
+ data, status_code, headers = api_instance.delete_webhook_with_http_info(webhook_oid)
54
+ p status_code # => 2xx
55
+ p headers # => { ... }
56
+ p data # => nil
57
+ rescue UltracartClient::ApiError => e
58
+ puts "Error when calling WebhookApi->delete_webhook_with_http_info: #{e}"
59
+ end
60
+ ```
61
+
62
+ ### Parameters
63
+
64
+ | Name | Type | Description | Notes |
65
+ | ---- | ---- | ----------- | ----- |
66
+ | **webhook_oid** | **Integer** | The webhook oid to delete. | |
67
+
68
+ ### Return type
69
+
70
+ nil (empty response body)
71
+
72
+ ### Authorization
73
+
74
+ [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
75
+
76
+ ### HTTP request headers
77
+
78
+ - **Content-Type**: Not defined
79
+ - **Accept**: application/json
80
+
81
+
82
+ ## delete_webhook_by_url
83
+
84
+ > <WebhookResponse> delete_webhook_by_url(webhook)
85
+
86
+ Delete a webhook by URL
87
+
88
+ Delete a webhook based upon the URL on the webhook_url matching an existing webhook.
89
+
90
+
91
+ ### Examples
92
+
93
+ ```ruby
94
+ require 'ultracart_api'
95
+ require_relative '../constants'
96
+
97
+ # This method can be confusing due to its payload. The method does indeed delete a webhook by url, but you need to
98
+ # pass a webhook object in as the payload. However, only the url is used. UltraCart does this to avoid any confusion
99
+ # with the rest url versus the webhook url.
100
+ #
101
+ # To use:
102
+ # Get your webhook url.
103
+ # Create a Webhook object.
104
+ # Set the Webhook url property.
105
+ # Pass the webhook to deleteWebhookByUrl()
106
+ #
107
+ # Returns status code 204 (No Content) on success
108
+
109
+ webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
110
+
111
+ webhook_url = "https://www.mywebiste.com/page/to/call/when/this/webhook/fires.php"
112
+ webhook = UltracartClient::Webhook.new
113
+ webhook.webhook_url = webhook_url
114
+
115
+ webhook_api.delete_webhook_by_url(webhook)
116
+ ```
117
+
118
+
119
+ #### Using the delete_webhook_by_url_with_http_info variant
120
+
121
+ This returns an Array which contains the response data, status code and headers.
122
+
123
+ > <Array(<WebhookResponse>, Integer, Hash)> delete_webhook_by_url_with_http_info(webhook)
124
+
125
+ ```ruby
126
+ begin
127
+ # Delete a webhook by URL
128
+ data, status_code, headers = api_instance.delete_webhook_by_url_with_http_info(webhook)
129
+ p status_code # => 2xx
130
+ p headers # => { ... }
131
+ p data # => <WebhookResponse>
132
+ rescue UltracartClient::ApiError => e
133
+ puts "Error when calling WebhookApi->delete_webhook_by_url_with_http_info: #{e}"
134
+ end
135
+ ```
136
+
137
+ ### Parameters
138
+
139
+ | Name | Type | Description | Notes |
140
+ | ---- | ---- | ----------- | ----- |
141
+ | **webhook** | [**Webhook**](Webhook.md) | Webhook to delete | |
142
+
143
+ ### Return type
144
+
145
+ [**WebhookResponse**](WebhookResponse.md)
146
+
147
+ ### Authorization
148
+
149
+ [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
150
+
151
+ ### HTTP request headers
152
+
153
+ - **Content-Type**: application/json; charset=UTF-8
154
+ - **Accept**: application/json
155
+
156
+
157
+ ## get_webhook_event_categories
158
+
159
+ > <WebhookEventCategoriesResponse> get_webhook_event_categories
160
+
161
+ Retrieve webhook event categories
162
+
163
+ Retrieves the available webhook event categories and events with backend-owned metadata (OIDs, names, descriptions, available expansions, flags) independent of whether any webhooks are saved. Used by the New Webhook editor so a merchant with zero webhooks can still see the catalog.
164
+
165
+
166
+ ### Examples
167
+
168
+
169
+ (No example for this operation).
170
+
171
+
172
+ #### Using the get_webhook_event_categories_with_http_info variant
173
+
174
+ This returns an Array which contains the response data, status code and headers.
175
+
176
+ > <Array(<WebhookEventCategoriesResponse>, Integer, Hash)> get_webhook_event_categories_with_http_info
177
+
178
+ ```ruby
179
+ begin
180
+ # Retrieve webhook event categories
181
+ data, status_code, headers = api_instance.get_webhook_event_categories_with_http_info
182
+ p status_code # => 2xx
183
+ p headers # => { ... }
184
+ p data # => <WebhookEventCategoriesResponse>
185
+ rescue UltracartClient::ApiError => e
186
+ puts "Error when calling WebhookApi->get_webhook_event_categories_with_http_info: #{e}"
187
+ end
188
+ ```
189
+
190
+ ### Parameters
191
+
192
+ This endpoint does not need any parameter.
193
+
194
+ ### Return type
195
+
196
+ [**WebhookEventCategoriesResponse**](WebhookEventCategoriesResponse.md)
197
+
198
+ ### Authorization
199
+
200
+ [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
201
+
202
+ ### HTTP request headers
203
+
204
+ - **Content-Type**: Not defined
205
+ - **Accept**: application/json
206
+
207
+
208
+ ## get_webhook_log
209
+
210
+ > <WebhookLogResponse> get_webhook_log(webhook_oid, request_id)
211
+
212
+ Retrieve an individual log
213
+
214
+ Retrieves an individual log for a webhook given the webhook oid the request id.
215
+
216
+
217
+ ### Examples
218
+
219
+ ```ruby
220
+ require 'ultracart_api'
221
+ require_relative '../constants'
222
+
223
+ # getWebhookLog() provides a detail log of a webhook event. It is used in tandem with getWebhookLogSummaries to audit
224
+ # webhook events. This method call will require the webhook_oid and the request_id. The webhook_oid can be discerned
225
+ # from the results of getWebhooks() and the request_id can be found from getWebhookLogSummaries(). see those examples
226
+ # if needed.
227
+
228
+ webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
229
+
230
+ webhook_oid = 123456789 # call getWebhooks if you don't know this.
231
+ request_id = '987654321' # call getWebhookLogSummaries if you don't know this.
232
+
233
+ api_response = webhook_api.get_webhook_log(webhook_oid, request_id)
234
+ webhook_log = api_response.webhook_log
235
+
236
+ if api_response.error
237
+ puts api_response.error.developer_message
238
+ puts api_response.error.user_message
239
+ exit
240
+ end
241
+
242
+ puts webhook_log
243
+ ```
244
+
245
+
246
+ #### Using the get_webhook_log_with_http_info variant
247
+
248
+ This returns an Array which contains the response data, status code and headers.
249
+
250
+ > <Array(<WebhookLogResponse>, Integer, Hash)> get_webhook_log_with_http_info(webhook_oid, request_id)
251
+
252
+ ```ruby
253
+ begin
254
+ # Retrieve an individual log
255
+ data, status_code, headers = api_instance.get_webhook_log_with_http_info(webhook_oid, request_id)
256
+ p status_code # => 2xx
257
+ p headers # => { ... }
258
+ p data # => <WebhookLogResponse>
259
+ rescue UltracartClient::ApiError => e
260
+ puts "Error when calling WebhookApi->get_webhook_log_with_http_info: #{e}"
261
+ end
262
+ ```
263
+
264
+ ### Parameters
265
+
266
+ | Name | Type | Description | Notes |
267
+ | ---- | ---- | ----------- | ----- |
268
+ | **webhook_oid** | **Integer** | The webhook oid that owns the log. | |
269
+ | **request_id** | **String** | The request id associated with the log to view. | |
270
+
271
+ ### Return type
272
+
273
+ [**WebhookLogResponse**](WebhookLogResponse.md)
274
+
275
+ ### Authorization
276
+
277
+ [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
278
+
279
+ ### HTTP request headers
280
+
281
+ - **Content-Type**: Not defined
282
+ - **Accept**: application/json
283
+
284
+
285
+ ## get_webhook_log_summaries
286
+
287
+ > <WebhookLogSummariesResponse> get_webhook_log_summaries(webhook_oid, opts)
288
+
289
+ Retrieve the log summaries
290
+
291
+ Retrieves the log summary information for a given webhook. This is useful for displaying all the various logs that can be viewed.
292
+
293
+
294
+ ### Examples
295
+
296
+ ```ruby
297
+ require 'ultracart_api'
298
+ require_relative '../constants'
299
+
300
+ # This example illustrates how to retrieve webhook log summaries.
301
+
302
+ webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
303
+
304
+ def get_summary_chunk(webhook_api, offset, limit)
305
+ webhook_oid = 123456789 # if you don't know this, use getWebhooks to find your webhook, then get its oid.
306
+ _since = (Date.today - 10).strftime('%Y-%m-%d') + "T00:00:00+00:00" # get the last 10 days
307
+ # Pay attention to whether limit or offset comes first in the method signature. UltraCart is not consistent with their ordering.
308
+ api_response = webhook_api.get_webhook_log_summaries(webhook_oid, limit, offset, _since)
309
+
310
+ return api_response.webhook_log_summaries if api_response.webhook_log_summaries
311
+ []
312
+ end
313
+
314
+ summaries = []
315
+
316
+ iteration = 1
317
+ offset = 0
318
+ limit = 200
319
+ more_records_to_fetch = true
320
+
321
+ begin
322
+ while more_records_to_fetch
323
+ puts "executing iteration #{iteration}"
324
+
325
+ chunk_of_summaries = get_summary_chunk(webhook_api, offset, limit)
326
+ summaries.concat(chunk_of_summaries)
327
+ offset = offset + limit
328
+ more_records_to_fetch = chunk_of_summaries.length == limit
329
+ iteration += 1
330
+ end
331
+ rescue UltracartClient::ApiError => e
332
+ puts "ApiError occurred on iteration #{iteration}"
333
+ puts e.inspect
334
+ exit 1
335
+ end
336
+
337
+ # this will be verbose...
338
+ puts summaries.inspect
339
+ ```
340
+
341
+
342
+ #### Using the get_webhook_log_summaries_with_http_info variant
343
+
344
+ This returns an Array which contains the response data, status code and headers.
345
+
346
+ > <Array(<WebhookLogSummariesResponse>, Integer, Hash)> get_webhook_log_summaries_with_http_info(webhook_oid, opts)
347
+
348
+ ```ruby
349
+ begin
350
+ # Retrieve the log summaries
351
+ data, status_code, headers = api_instance.get_webhook_log_summaries_with_http_info(webhook_oid, opts)
352
+ p status_code # => 2xx
353
+ p headers # => { ... }
354
+ p data # => <WebhookLogSummariesResponse>
355
+ rescue UltracartClient::ApiError => e
356
+ puts "Error when calling WebhookApi->get_webhook_log_summaries_with_http_info: #{e}"
357
+ end
358
+ ```
359
+
360
+ ### Parameters
361
+
362
+ | Name | Type | Description | Notes |
363
+ | ---- | ---- | ----------- | ----- |
364
+ | **webhook_oid** | **Integer** | The webhook oid to retrieve log summaries for. | |
365
+ | **request_id** | **String** | Filter by request id | [optional] |
366
+ | **begin_date** | **String** | Filter to deliveries on or after this date/time | [optional] |
367
+ | **end_date** | **String** | Filter to deliveries on or before this date/time | [optional] |
368
+ | **status** | **String** | Filter by HTTP status code | [optional] |
369
+ | **success** | **Boolean** | Filter by success (true) or failure (false) | [optional] |
370
+ | **event** | **String** | Filter by an event name contained in the delivery | [optional] |
371
+ | **order_id** | **String** | Filter by an order id contained in the delivery | [optional] |
372
+ | **request** | **String** | Filter by text contained in the request payload | [optional] |
373
+ | **duration** | **Integer** | Filter to deliveries that took at least this many milliseconds | [optional] |
374
+ | **_limit** | **Integer** | The maximum number of records to return on this one API call. | [optional][default to 100] |
375
+ | **_offset** | **Integer** | Pagination of the record set. Offset is a zero based index. | [optional][default to 0] |
376
+ | **_since** | **String** | Fetch log summaries that have been delivered since this date/time. | [optional] |
377
+
378
+ ### Return type
379
+
380
+ [**WebhookLogSummariesResponse**](WebhookLogSummariesResponse.md)
381
+
382
+ ### Authorization
383
+
384
+ [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
385
+
386
+ ### HTTP request headers
387
+
388
+ - **Content-Type**: Not defined
389
+ - **Accept**: application/json
390
+
391
+
392
+ ## get_webhooks
393
+
394
+ > <WebhooksResponse> get_webhooks(opts)
395
+
396
+ Retrieve webhooks
397
+
398
+ Retrieves the webhooks associated with this application.
399
+
400
+
401
+ ### Examples
402
+
403
+ ```ruby
404
+ require 'ultracart_api'
405
+ require_relative '../constants'
406
+
407
+ # This example illustrates how to retrieve all webhooks.
408
+
409
+ webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
410
+
411
+ def get_webhook_chunk(webhook_api, offset, limit)
412
+ _sort = nil # default sorting is webhook_url, disabled, and those are also the two choices for sorting.
413
+ _placeholders = nil # useful for UI displays, but not needed here.
414
+ # Pay attention to whether limit or offset comes first in the method signature. UltraCart is not consistent with their ordering.
415
+ opts = {
416
+ '_sort' => _sort,
417
+ '_placeholders' => _placeholders
418
+ }
419
+ api_response = webhook_api.get_webhooks(limit, offset, opts)
420
+
421
+ return api_response.webhooks if api_response.webhooks
422
+ []
423
+ end
424
+
425
+ webhooks = []
426
+
427
+ iteration = 1
428
+ offset = 0
429
+ limit = 200
430
+ more_records_to_fetch = true
431
+
432
+ begin
433
+ while more_records_to_fetch
434
+ puts "executing iteration #{iteration}"
435
+
436
+ chunk_of_webhooks = get_webhook_chunk(webhook_api, offset, limit)
437
+ webhooks.concat(chunk_of_webhooks)
438
+ offset = offset + limit
439
+ more_records_to_fetch = chunk_of_webhooks.length == limit
440
+ iteration += 1
441
+ end
442
+ rescue UltracartClient::ApiError => e
443
+ puts "ApiError occurred on iteration #{iteration}"
444
+ puts e.inspect
445
+ exit 1
446
+ end
447
+
448
+ # this will be verbose...
449
+ puts webhooks.inspect
450
+ ```
451
+
452
+
453
+ #### Using the get_webhooks_with_http_info variant
454
+
455
+ This returns an Array which contains the response data, status code and headers.
456
+
457
+ > <Array(<WebhooksResponse>, Integer, Hash)> get_webhooks_with_http_info(opts)
458
+
459
+ ```ruby
460
+ begin
461
+ # Retrieve webhooks
462
+ data, status_code, headers = api_instance.get_webhooks_with_http_info(opts)
463
+ p status_code # => 2xx
464
+ p headers # => { ... }
465
+ p data # => <WebhooksResponse>
466
+ rescue UltracartClient::ApiError => e
467
+ puts "Error when calling WebhookApi->get_webhooks_with_http_info: #{e}"
468
+ end
469
+ ```
470
+
471
+ ### Parameters
472
+
473
+ | Name | Type | Description | Notes |
474
+ | ---- | ---- | ----------- | ----- |
475
+ | **_limit** | **Integer** | The maximum number of records to return on this one API call. | [optional][default to 100] |
476
+ | **_offset** | **Integer** | Pagination of the record set. Offset is a zero based index. | [optional][default to 0] |
477
+ | **_sort** | **String** | The sort order of the webhooks. See documentation for examples | [optional] |
478
+ | **_placeholders** | **Boolean** | Whether or not placeholder values should be returned in the result. Useful for UIs that consume this REST API. | [optional] |
479
+
480
+ ### Return type
481
+
482
+ [**WebhooksResponse**](WebhooksResponse.md)
483
+
484
+ ### Authorization
485
+
486
+ [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
487
+
488
+ ### HTTP request headers
489
+
490
+ - **Content-Type**: Not defined
491
+ - **Accept**: application/json
492
+
493
+
494
+ ## insert_webhook
495
+
496
+ > <WebhookResponse> insert_webhook(webhook, opts)
497
+
498
+ Add a webhook
499
+
500
+ Adds a new webhook on the account. If you add a new webhook with the authentication_type set to basic, but do not specify the basic_username and basic_password, UltraCart will automatically generate random ones and return them. This allows your application to have simpler logic on the setup of a secure webhook.
501
+
502
+
503
+ ### Examples
504
+
505
+ ```ruby
506
+ require 'ultracart_api'
507
+ require_relative '../constants'
508
+
509
+ # Adds a new webhook on the account. If you add a new webhook with the authentication_type set to basic, but
510
+ # do not specify the basic_username and basic_password, UltraCart will automatically generate random ones and
511
+ # return them. This allows your application to have simpler logic on the setup of a secure webhook.
512
+ #
513
+ # Event Category Event Name Description
514
+ # auto_order auto_order_cancel Fired when an auto order is canceled
515
+ # auto_order auto_order_create Fired when an auto order is created
516
+ # auto_order auto_order_decline Fired when an auto order is declined
517
+ # auto_order auto_order_disable Fired when an auto order is disabled
518
+ # auto_order auto_order_preshipment Fired when an auto order generates a new pre-shipment notice
519
+ # auto_order auto_order_rebill Fired when an auto order is rebilled
520
+ # auto_order auto_order_update Fired when an auto order is updated
521
+ # chargeback chargeback_create Fired when a chargeback is created
522
+ # chargeback chargeback_delete Fired when a chargeback is deleted
523
+ # chargeback chargeback_update Fired when a chargeback is updated
524
+ # checkout checkout_cart_abandon Fired when a cart is abandoned
525
+ # checkout checkout_cart_send_return_email Fired when a return email should be sent to a customer
526
+ # customer customer_create Fired when a customer profile is created.
527
+ # customer customer_delete Fired when a customer profile is deleted.
528
+ # customer customer_update Fired when a customer profile is updated.
529
+ # fulfillment fulfillment_hold Fired when an order is held for review
530
+ # fulfillment fulfillment_transmit Fired to transmit an order to the fulfillment house
531
+ # item item_create Fired when a new item is created.
532
+ # item item_delete Fired when an item is deleted.
533
+ # item item_update Fired when an item is updated.
534
+ # order order_abandon_recovery Fired when a previously abandoned cart turns into an order
535
+ # order order_create Fired when an order is placed
536
+ # order order_delete Fired when an order is deleted
537
+ # order order_payment_failed Fired when a payment fails
538
+ # order order_payment_process Fired when a payment is processed
539
+ # order order_refund Fired when an order is refunded
540
+ # order order_reject Fired when an order is rejected
541
+ # order order_s3_invoice Fired when an invoice PDF is stored in S3 bucket
542
+ # order order_s3_packing_slip Fired when a packing slip PDF is stored in an S3 bucket
543
+ # order order_ship Fired when an order is shipped
544
+ # order order_ship_delivered Fired when an order has a shipment delivered
545
+ # order order_ship_expected Fired when an order has an expected delivery date
546
+ # order order_ship_out_for_delivery Fired when an order has a shipment out for delivery
547
+ # order order_stage_change Fired when an order stage changes
548
+ # order order_update Fired when an order is edited
549
+ # storefront screen_recording Fired when a screen recording is created
550
+ # user user_create Fired when a user is created
551
+ # user user_delete Fired when a user is deleted
552
+ # user user_login Fired when a user logs in
553
+ # user user_update Fired when a user is updated
554
+ # workflow_task workflow_task_create Fired when a workflow task is created
555
+ # workflow_task workflow_task_delete Fired when a workflow task is deleted
556
+ # workflow_task workflow_task_update Fired when a workflow task is updated
557
+ #
558
+ # Note: Each event uses the same expansions as the event category. To see a list of possible expansion values,
559
+ # visit www.ultracart.com/api/. Order Expansions (https://www.ultracart.com/api/#resource_order.html) are listed
560
+ # below because most webhooks are for order events.
561
+ # Order Expansion:
562
+ # affiliate auto_order billing checkout
563
+ # affiliate.ledger channel_partner coupon customer_profile
564
+ # digital_order edi fraud_score gift
565
+ # gift_certificate internal item linked_shipment
566
+ # marketing payment payment.transaction point_of_sale
567
+ # quote salesforce shipping shipping.tracking_number_details
568
+ # summary taxes utms
569
+ #
570
+ # Note: The WebhookEventSubscription.event_ruler field is processed with the AWS Event Ruler library to filter down
571
+ # events to just what you want. If you wish to employ a ruler filter, see https://github.com/aws/event-ruler
572
+ # for syntax examples. You'll need to apply the aws syntax against the UltraCart object models. Contact UltraCart
573
+ # support if you need assistance creating the proper ruler expression.
574
+
575
+ webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
576
+
577
+ webhook = UltracartClient::Webhook.new
578
+ webhook.webhook_url = "https://www.mywebiste.com/page/to/call/when/this/webhook/fires.php" # Must be HTTPS if customer related information is being delivered.
579
+ webhook.authentication_type = "basic" # "basic","none","api user","aws iam"
580
+ webhook.basic_username = "george"
581
+ webhook.basic_password = "LlamaLlamaRedPajama"
582
+ webhook.maximum_events = 10
583
+ webhook.maximum_size = 5242880 # 5 MB is pretty chunky.
584
+ webhook.api_version = "2017-03-01" # this is our only API version so far.
585
+ webhook.compress_events = true # compress events with gzip, then base64 encode them as a string.
586
+
587
+ event_sub1 = UltracartClient::WebhookEventSubscription.new
588
+ event_sub1.event_name = "order_create"
589
+ event_sub1.event_description = "when an order is placed"
590
+ event_sub1.expansion = "shipping,billing,item,coupon,summary" # whatever you need.
591
+ event_sub1.event_ruler = nil # no filtering. we want all objects.
592
+ event_sub1.comments = "Merchant specific comment, for example: Bobby needs this webhook for the Accounting department."
593
+
594
+ event_sub2 = UltracartClient::WebhookEventSubscription.new
595
+ event_sub2.event_name = "order_update"
596
+ event_sub2.event_description = "when an order is modified"
597
+ event_sub2.expansion = "shipping,billing,item,coupon,summary" # whatever you need.
598
+ event_sub2.event_ruler = nil # no filtering. we want all objects.
599
+ event_sub2.comments = "Merchant specific comment, for example: Bobby needs this webhook for the Accounting department."
600
+
601
+ event_sub3 = UltracartClient::WebhookEventSubscription.new
602
+ event_sub3.event_name = "order_delete"
603
+ event_sub3.event_description = "when an order is modified"
604
+ event_sub3.expansion = "" # don't need any expansion on delete. only need to know the order_id
605
+ event_sub3.event_ruler = nil # no filtering. we want all objects.
606
+ event_sub3.comments = "Merchant specific comment, for example: Bobby needs this webhook for the Accounting department."
607
+
608
+ event_category1 = UltracartClient::WebhookEventCategory.new
609
+ event_category1.event_category = "order"
610
+ event_category1.events = [event_sub1, event_sub2, event_sub3]
611
+
612
+ # api_response.webhook will return the newly created webhook.
613
+ api_response = webhook_api.insert_webhook(webhook, false)
614
+
615
+ if api_response.error
616
+ puts api_response.error.developer_message
617
+ puts api_response.error.user_message
618
+ exit
619
+ end
620
+
621
+ created_webhook = api_response.webhook
622
+ # TODO - store the webhook oid in case you ever need to make changes.
623
+
624
+ # This should equal what you submitted, plus contain much new information
625
+ puts created_webhook.inspect
626
+ ```
627
+
628
+
629
+ #### Using the insert_webhook_with_http_info variant
630
+
631
+ This returns an Array which contains the response data, status code and headers.
632
+
633
+ > <Array(<WebhookResponse>, Integer, Hash)> insert_webhook_with_http_info(webhook, opts)
634
+
635
+ ```ruby
636
+ begin
637
+ # Add a webhook
638
+ data, status_code, headers = api_instance.insert_webhook_with_http_info(webhook, opts)
639
+ p status_code # => 2xx
640
+ p headers # => { ... }
641
+ p data # => <WebhookResponse>
642
+ rescue UltracartClient::ApiError => e
643
+ puts "Error when calling WebhookApi->insert_webhook_with_http_info: #{e}"
644
+ end
645
+ ```
646
+
647
+ ### Parameters
648
+
649
+ | Name | Type | Description | Notes |
650
+ | ---- | ---- | ----------- | ----- |
651
+ | **webhook** | [**Webhook**](Webhook.md) | Webhook to create | |
652
+ | **_placeholders** | **Boolean** | Whether or not placeholder values should be returned in the result. Useful for UIs that consume this REST API. | [optional] |
653
+
654
+ ### Return type
655
+
656
+ [**WebhookResponse**](WebhookResponse.md)
657
+
658
+ ### Authorization
659
+
660
+ [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
661
+
662
+ ### HTTP request headers
663
+
664
+ - **Content-Type**: application/json; charset=UTF-8
665
+ - **Accept**: application/json
666
+
667
+
668
+ ## resend_event
669
+
670
+ > <WebhookReflowResponse> resend_event(webhook_oid, event_name)
671
+
672
+ Resend events to the webhook endpoint.
673
+
674
+ This method will resend events to the webhook endpoint. This method can be used for example to send all the existing items on an account to a webhook.
675
+
676
+
677
+ ### Examples
678
+
679
+ ```ruby
680
+ require 'ultracart_api'
681
+ require_relative '../constants'
682
+
683
+ # resentEvent is used to reflow an event. It will resend ALL events in history. So it is essentially a way to
684
+ # get all objects from an event. Currently, there are only two events available for reflow: "item_update", and "order_create".
685
+ # These two events provide the means to have a webhook receive all items or orders. This method is usually called
686
+ # at the beginning of a webhook's life to prepopulate a merchant's database with all items or orders.
687
+ #
688
+ # You will need the webhook_oid to call this method. Call getWebhooks() if you don't know your oid.
689
+
690
+ webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
691
+
692
+ webhook_oid = 123456789 # call getWebhooks if you don't know this.
693
+ event_name = "item_update" # or "order_create", but for this sample, we want all items.
694
+
695
+ api_response = webhook_api.resend_event(webhook_oid, event_name)
696
+ reflow = api_response.reflow
697
+ success = reflow.queued
698
+
699
+ if api_response.error
700
+ puts api_response.error.developer_message
701
+ puts api_response.error.user_message
702
+ exit
703
+ end
704
+
705
+ puts api_response.inspect
706
+ ```
707
+
708
+
709
+ #### Using the resend_event_with_http_info variant
710
+
711
+ This returns an Array which contains the response data, status code and headers.
712
+
713
+ > <Array(<WebhookReflowResponse>, Integer, Hash)> resend_event_with_http_info(webhook_oid, event_name)
714
+
715
+ ```ruby
716
+ begin
717
+ # Resend events to the webhook endpoint.
718
+ data, status_code, headers = api_instance.resend_event_with_http_info(webhook_oid, event_name)
719
+ p status_code # => 2xx
720
+ p headers # => { ... }
721
+ p data # => <WebhookReflowResponse>
722
+ rescue UltracartClient::ApiError => e
723
+ puts "Error when calling WebhookApi->resend_event_with_http_info: #{e}"
724
+ end
725
+ ```
726
+
727
+ ### Parameters
728
+
729
+ | Name | Type | Description | Notes |
730
+ | ---- | ---- | ----------- | ----- |
731
+ | **webhook_oid** | **Integer** | The webhook oid that is receiving the reflowed events. | |
732
+ | **event_name** | **String** | The event to reflow. | |
733
+
734
+ ### Return type
735
+
736
+ [**WebhookReflowResponse**](WebhookReflowResponse.md)
737
+
738
+ ### Authorization
739
+
740
+ [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
741
+
742
+ ### HTTP request headers
743
+
744
+ - **Content-Type**: Not defined
745
+ - **Accept**: application/json
746
+
747
+
748
+ ## update_webhook
749
+
750
+ > <WebhookResponse> update_webhook(webhook_oid, webhook, opts)
751
+
752
+ Update a webhook
753
+
754
+ Update a webhook on the account
755
+
756
+
757
+ ### Examples
758
+
759
+ ```ruby
760
+ require 'ultracart_api'
761
+ require_relative '../constants'
762
+
763
+ # Updates a webhook on the account. See insertWebhook.php for a complete example with field usage.
764
+ # For this example, we are just updating the basic password.
765
+
766
+ webhook_api = UltracartClient::WebhookApi.new_using_api_key(Constants::API_KEY)
767
+
768
+ # you should have stored this when you created the webhook. If you don't know it, call getWebhooks and iterate through
769
+ # them to find you target webhook (add useful comments to each webhook really helps in this endeavor) and get the
770
+ # webhook oid from that. You'll want to call getWebhooks any way to get the object for updating. It is HIGHLY
771
+ # recommended to get the object from UltraCart for updating rather than constructing it yourself to avoid accidentally
772
+ # deleting a part of the object during the update.
773
+ webhook_oid = 123456789
774
+
775
+ webhook_to_update = nil
776
+ opts = {
777
+ '_sort' => nil,
778
+ '_placeholders' => nil
779
+ }
780
+ webhooks = webhook_api.get_webhooks(100, 0, opts).webhooks
781
+ webhooks.each do |webhook|
782
+ if webhook.webhook_oid == webhook_oid
783
+ webhook_to_update = webhook
784
+ break
785
+ end
786
+ end
787
+
788
+ webhook_to_update.basic_password = "new password here"
789
+ api_response = webhook_api.update_webhook(webhook_oid, webhook_to_update)
790
+ updated_webhook = api_response.webhook
791
+
792
+ if api_response.error
793
+ puts api_response.error.developer_message
794
+ puts api_response.error.user_message
795
+ exit
796
+ end
797
+
798
+ puts updated_webhook.inspect
799
+ ```
800
+
801
+
802
+ #### Using the update_webhook_with_http_info variant
803
+
804
+ This returns an Array which contains the response data, status code and headers.
805
+
806
+ > <Array(<WebhookResponse>, Integer, Hash)> update_webhook_with_http_info(webhook_oid, webhook, opts)
807
+
808
+ ```ruby
809
+ begin
810
+ # Update a webhook
811
+ data, status_code, headers = api_instance.update_webhook_with_http_info(webhook_oid, webhook, opts)
812
+ p status_code # => 2xx
813
+ p headers # => { ... }
814
+ p data # => <WebhookResponse>
815
+ rescue UltracartClient::ApiError => e
816
+ puts "Error when calling WebhookApi->update_webhook_with_http_info: #{e}"
817
+ end
818
+ ```
819
+
820
+ ### Parameters
821
+
822
+ | Name | Type | Description | Notes |
823
+ | ---- | ---- | ----------- | ----- |
824
+ | **webhook_oid** | **Integer** | The webhook oid to update. | |
825
+ | **webhook** | [**Webhook**](Webhook.md) | Webhook to update | |
826
+ | **_placeholders** | **Boolean** | Whether or not placeholder values should be returned in the result. Useful for UIs that consume this REST API. | [optional] |
827
+
828
+ ### Return type
829
+
830
+ [**WebhookResponse**](WebhookResponse.md)
831
+
832
+ ### Authorization
833
+
834
+ [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
835
+
836
+ ### HTTP request headers
837
+
838
+ - **Content-Type**: application/json; charset=UTF-8
839
+ - **Accept**: application/json
840
+