square.rb 20.1.0.20220616 → 22.0.0.20220817
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.
- checksums.yaml +4 -4
- data/lib/square/api/base_api.rb +8 -1
- data/lib/square/api/bookings_api.rb +3 -3
- data/lib/square/api/cards_api.rb +3 -2
- data/lib/square/api/catalog_api.rb +22 -22
- data/lib/square/api/checkout_api.rb +5 -5
- data/lib/square/api/customer_custom_attributes_api.rb +55 -34
- data/lib/square/api/customers_api.rb +3 -3
- data/lib/square/api/disputes_api.rb +24 -29
- data/lib/square/api/loyalty_api.rb +256 -31
- data/lib/square/api/orders_api.rb +2 -2
- data/lib/square/api/payments_api.rb +1 -1
- data/lib/square/api/v1_transactions_api.rb +4 -4
- data/lib/square/api/webhook_subscriptions_api.rb +328 -0
- data/lib/square/api_helper.rb +176 -4
- data/lib/square/client.rb +10 -5
- data/lib/square/configuration.rb +3 -4
- data/lib/square/exceptions/validation_exception.rb +13 -0
- data/lib/square/http/faraday_client.rb +1 -0
- data/lib/square.rb +2 -0
- data/test/test_helper.rb +1 -1
- metadata +22 -6
@@ -113,20 +113,30 @@ module Square
|
|
113
113
|
)
|
114
114
|
end
|
115
115
|
|
116
|
-
# Adds points earned from
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
# points
|
126
|
-
# that
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
116
|
+
# Adds points earned from a purchase to a [loyalty
|
117
|
+
# account]($m/LoyaltyAccount).
|
118
|
+
# - If you are using the Orders API to manage orders, provide the
|
119
|
+
# `order_id`. Square reads the order
|
120
|
+
# to compute the points earned from both the base loyalty program and an
|
121
|
+
# associated
|
122
|
+
# [loyalty promotion]($m/LoyaltyPromotion). For purchases that qualify for
|
123
|
+
# multiple accrual
|
124
|
+
# rules, Square computes points based on the accrual rule that grants the
|
125
|
+
# most points.
|
126
|
+
# For purchases that qualify for multiple promotions, Square computes points
|
127
|
+
# based on the most
|
128
|
+
# recently created promotion. A purchase must first qualify for program
|
129
|
+
# points to be eligible for promotion points.
|
130
|
+
# - If you are not using the Orders API to manage orders, provide `points`
|
131
|
+
# with the number of points to add.
|
132
|
+
# You must first perform a client-side computation of the points earned from
|
133
|
+
# the loyalty program and
|
134
|
+
# loyalty promotion. For spend-based and visit-based programs, you can call
|
135
|
+
# [CalculateLoyaltyPoints]($e/Loyalty/CalculateLoyaltyPoints)
|
136
|
+
# to compute the points earned from the loyalty program (but not points
|
137
|
+
# earned from a loyalty promotion).
|
138
|
+
# @param [String] account_id Required parameter: The ID of the target
|
139
|
+
# [loyalty account]($m/LoyaltyAccount).
|
130
140
|
# @param [AccumulateLoyaltyPointsRequest] body Required parameter: An object
|
131
141
|
# containing the fields to POST for the request. See the corresponding
|
132
142
|
# object definition for field details.
|
@@ -170,8 +180,8 @@ module Square
|
|
170
180
|
# in your application flow, you call
|
171
181
|
# [AccumulateLoyaltyPoints]($e/Loyalty/AccumulateLoyaltyPoints)
|
172
182
|
# to add points when a buyer pays for the purchase.
|
173
|
-
# @param [String] account_id Required parameter: The ID of the
|
174
|
-
# account]($m/LoyaltyAccount)
|
183
|
+
# @param [String] account_id Required parameter: The ID of the target
|
184
|
+
# [loyalty account]($m/LoyaltyAccount).
|
175
185
|
# @param [AdjustLoyaltyPointsRequest] body Required parameter: An object
|
176
186
|
# containing the fields to POST for the request. See the corresponding
|
177
187
|
# object definition for field details.
|
@@ -330,21 +340,32 @@ module Square
|
|
330
340
|
)
|
331
341
|
end
|
332
342
|
|
333
|
-
# Calculates the points a
|
334
|
-
#
|
335
|
-
#
|
336
|
-
#
|
337
|
-
#
|
338
|
-
#
|
339
|
-
#
|
340
|
-
#
|
341
|
-
#
|
342
|
-
#
|
343
|
-
#
|
344
|
-
#
|
345
|
-
#
|
346
|
-
#
|
347
|
-
#
|
343
|
+
# Calculates the number of points a buyer can earn from a purchase.
|
344
|
+
# Applications might call this endpoint
|
345
|
+
# to display the points to the buyer.
|
346
|
+
# - If you are using the Orders API to manage orders, provide the `order_id`
|
347
|
+
# and (optional) `loyalty_account_id`.
|
348
|
+
# Square reads the order to compute the points earned from the base loyalty
|
349
|
+
# program and an associated
|
350
|
+
# [loyalty promotion]($m/LoyaltyPromotion).
|
351
|
+
# - If you are not using the Orders API to manage orders, provide
|
352
|
+
# `transaction_amount_money` with the
|
353
|
+
# purchase amount. Square uses this amount to calculate the points earned
|
354
|
+
# from the base loyalty program,
|
355
|
+
# but not points earned from a loyalty promotion. For spend-based and
|
356
|
+
# visit-based programs, the `tax_mode`
|
357
|
+
# setting of the accrual rule indicates how taxes should be treated for
|
358
|
+
# loyalty points accrual.
|
359
|
+
# If the purchase qualifies for program points, call
|
360
|
+
# [ListLoyaltyPromotions]($e/Loyalty/ListLoyaltyPromotions) and perform a
|
361
|
+
# client-side computation
|
362
|
+
# to calculate whether the purchase also qualifies for promotion points. For
|
363
|
+
# more information, see
|
364
|
+
# [Calculating promotion
|
365
|
+
# points](https://developer.squareup.com/docs/loyalty-api/loyalty-promotions
|
366
|
+
# #calculate-promotion-points).
|
367
|
+
# @param [String] program_id Required parameter: The ID of the [loyalty
|
368
|
+
# program]($m/LoyaltyProgram), which defines the rules for accruing
|
348
369
|
# points.
|
349
370
|
# @param [CalculateLoyaltyPointsRequest] body Required parameter: An object
|
350
371
|
# containing the fields to POST for the request. See the corresponding
|
@@ -384,6 +405,210 @@ module Square
|
|
384
405
|
)
|
385
406
|
end
|
386
407
|
|
408
|
+
# Lists the loyalty promotions associated with a [loyalty
|
409
|
+
# program]($m/LoyaltyProgram).
|
410
|
+
# Results are sorted by the `created_at` date in descending order (newest to
|
411
|
+
# oldest).
|
412
|
+
# @param [String] program_id Required parameter: The ID of the base [loyalty
|
413
|
+
# program]($m/LoyaltyProgram). To get the program ID, call
|
414
|
+
# [RetrieveLoyaltyProgram]($e/Loyalty/RetrieveLoyaltyProgram) using the
|
415
|
+
# `main` keyword.
|
416
|
+
# @param [LoyaltyPromotionStatus] status Optional parameter: The status to
|
417
|
+
# filter the results by. If a status is provided, only loyalty promotions
|
418
|
+
# with the specified status are returned. Otherwise, all loyalty promotions
|
419
|
+
# associated with the loyalty program are returned.
|
420
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
421
|
+
# paged response from the previous call to this endpoint. Provide this
|
422
|
+
# cursor to retrieve the next page of results for your original request. For
|
423
|
+
# more information, see
|
424
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
425
|
+
# atterns/pagination).
|
426
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
427
|
+
# to return in a single paged response. The minimum value is 1 and the
|
428
|
+
# maximum value is 30. The default value is 30. For more information, see
|
429
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
430
|
+
# atterns/pagination).
|
431
|
+
# @return [ListLoyaltyPromotionsResponse Hash] response from the API call
|
432
|
+
def list_loyalty_promotions(program_id:,
|
433
|
+
status: nil,
|
434
|
+
cursor: nil,
|
435
|
+
limit: nil)
|
436
|
+
# Prepare query url.
|
437
|
+
_query_builder = config.get_base_uri
|
438
|
+
_query_builder << '/v2/loyalty/programs/{program_id}/promotions'
|
439
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
440
|
+
_query_builder,
|
441
|
+
'program_id' => { 'value' => program_id, 'encode' => true }
|
442
|
+
)
|
443
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
444
|
+
_query_builder,
|
445
|
+
'status' => status,
|
446
|
+
'cursor' => cursor,
|
447
|
+
'limit' => limit
|
448
|
+
)
|
449
|
+
_query_url = APIHelper.clean_url _query_builder
|
450
|
+
|
451
|
+
# Prepare headers.
|
452
|
+
_headers = {
|
453
|
+
'accept' => 'application/json'
|
454
|
+
}
|
455
|
+
|
456
|
+
# Prepare and execute HttpRequest.
|
457
|
+
_request = config.http_client.get(
|
458
|
+
_query_url,
|
459
|
+
headers: _headers
|
460
|
+
)
|
461
|
+
OAuth2.apply(config, _request)
|
462
|
+
_response = execute_request(_request)
|
463
|
+
|
464
|
+
# Return appropriate response type.
|
465
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
466
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
467
|
+
ApiResponse.new(
|
468
|
+
_response, data: decoded, errors: _errors
|
469
|
+
)
|
470
|
+
end
|
471
|
+
|
472
|
+
# Creates a loyalty promotion for a [loyalty program]($m/LoyaltyProgram). A
|
473
|
+
# loyalty promotion
|
474
|
+
# enables buyers to earn points in addition to those earned from the base
|
475
|
+
# loyalty program.
|
476
|
+
# This endpoint sets the loyalty promotion to the `ACTIVE` or `SCHEDULED`
|
477
|
+
# status, depending on the
|
478
|
+
# `available_time` setting. A loyalty program can have a maximum of 10
|
479
|
+
# loyalty promotions with an
|
480
|
+
# `ACTIVE` or `SCHEDULED` status.
|
481
|
+
# @param [String] program_id Required parameter: The ID of the [loyalty
|
482
|
+
# program]($m/LoyaltyProgram) to associate with the promotion. To get the
|
483
|
+
# program ID, call
|
484
|
+
# [RetrieveLoyaltyProgram]($e/Loyalty/RetrieveLoyaltyProgram) using the
|
485
|
+
# `main` keyword.
|
486
|
+
# @param [CreateLoyaltyPromotionRequest] body Required parameter: An object
|
487
|
+
# containing the fields to POST for the request. See the corresponding
|
488
|
+
# object definition for field details.
|
489
|
+
# @return [CreateLoyaltyPromotionResponse Hash] response from the API call
|
490
|
+
def create_loyalty_promotion(program_id:,
|
491
|
+
body:)
|
492
|
+
# Prepare query url.
|
493
|
+
_query_builder = config.get_base_uri
|
494
|
+
_query_builder << '/v2/loyalty/programs/{program_id}/promotions'
|
495
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
496
|
+
_query_builder,
|
497
|
+
'program_id' => { 'value' => program_id, 'encode' => true }
|
498
|
+
)
|
499
|
+
_query_url = APIHelper.clean_url _query_builder
|
500
|
+
|
501
|
+
# Prepare headers.
|
502
|
+
_headers = {
|
503
|
+
'accept' => 'application/json',
|
504
|
+
'Content-Type' => 'application/json'
|
505
|
+
}
|
506
|
+
|
507
|
+
# Prepare and execute HttpRequest.
|
508
|
+
_request = config.http_client.post(
|
509
|
+
_query_url,
|
510
|
+
headers: _headers,
|
511
|
+
parameters: body.to_json
|
512
|
+
)
|
513
|
+
OAuth2.apply(config, _request)
|
514
|
+
_response = execute_request(_request)
|
515
|
+
|
516
|
+
# Return appropriate response type.
|
517
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
518
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
519
|
+
ApiResponse.new(
|
520
|
+
_response, data: decoded, errors: _errors
|
521
|
+
)
|
522
|
+
end
|
523
|
+
|
524
|
+
# Retrieves a loyalty promotion.
|
525
|
+
# @param [String] promotion_id Required parameter: The ID of the [loyalty
|
526
|
+
# promotion]($m/LoyaltyPromotion) to retrieve.
|
527
|
+
# @param [String] program_id Required parameter: The ID of the base [loyalty
|
528
|
+
# program]($m/LoyaltyProgram). To get the program ID, call
|
529
|
+
# [RetrieveLoyaltyProgram]($e/Loyalty/RetrieveLoyaltyProgram) using the
|
530
|
+
# `main` keyword.
|
531
|
+
# @return [RetrieveLoyaltyPromotionResponse Hash] response from the API call
|
532
|
+
def retrieve_loyalty_promotion(promotion_id:,
|
533
|
+
program_id:)
|
534
|
+
# Prepare query url.
|
535
|
+
_query_builder = config.get_base_uri
|
536
|
+
_query_builder << '/v2/loyalty/programs/{program_id}/promotions/{promotion_id}'
|
537
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
538
|
+
_query_builder,
|
539
|
+
'promotion_id' => { 'value' => promotion_id, 'encode' => true },
|
540
|
+
'program_id' => { 'value' => program_id, 'encode' => true }
|
541
|
+
)
|
542
|
+
_query_url = APIHelper.clean_url _query_builder
|
543
|
+
|
544
|
+
# Prepare headers.
|
545
|
+
_headers = {
|
546
|
+
'accept' => 'application/json'
|
547
|
+
}
|
548
|
+
|
549
|
+
# Prepare and execute HttpRequest.
|
550
|
+
_request = config.http_client.get(
|
551
|
+
_query_url,
|
552
|
+
headers: _headers
|
553
|
+
)
|
554
|
+
OAuth2.apply(config, _request)
|
555
|
+
_response = execute_request(_request)
|
556
|
+
|
557
|
+
# Return appropriate response type.
|
558
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
559
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
560
|
+
ApiResponse.new(
|
561
|
+
_response, data: decoded, errors: _errors
|
562
|
+
)
|
563
|
+
end
|
564
|
+
|
565
|
+
# Cancels a loyalty promotion. Use this endpoint to cancel an `ACTIVE`
|
566
|
+
# promotion earlier than the
|
567
|
+
# end date, cancel an `ACTIVE` promotion when an end date is not specified,
|
568
|
+
# or cancel a `SCHEDULED` promotion.
|
569
|
+
# Because updating a promotion is not supported, you can also use this
|
570
|
+
# endpoint to cancel a promotion before
|
571
|
+
# you create a new one.
|
572
|
+
# This endpoint sets the loyalty promotion to the `CANCELED` state
|
573
|
+
# @param [String] promotion_id Required parameter: The ID of the [loyalty
|
574
|
+
# promotion]($m/LoyaltyPromotion) to cancel. You can cancel a promotion that
|
575
|
+
# has an `ACTIVE` or `SCHEDULED` status.
|
576
|
+
# @param [String] program_id Required parameter: The ID of the base [loyalty
|
577
|
+
# program]($m/LoyaltyProgram).
|
578
|
+
# @return [CancelLoyaltyPromotionResponse Hash] response from the API call
|
579
|
+
def cancel_loyalty_promotion(promotion_id:,
|
580
|
+
program_id:)
|
581
|
+
# Prepare query url.
|
582
|
+
_query_builder = config.get_base_uri
|
583
|
+
_query_builder << '/v2/loyalty/programs/{program_id}/promotions/{promotion_id}/cancel'
|
584
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
585
|
+
_query_builder,
|
586
|
+
'promotion_id' => { 'value' => promotion_id, 'encode' => true },
|
587
|
+
'program_id' => { 'value' => program_id, 'encode' => true }
|
588
|
+
)
|
589
|
+
_query_url = APIHelper.clean_url _query_builder
|
590
|
+
|
591
|
+
# Prepare headers.
|
592
|
+
_headers = {
|
593
|
+
'accept' => 'application/json'
|
594
|
+
}
|
595
|
+
|
596
|
+
# Prepare and execute HttpRequest.
|
597
|
+
_request = config.http_client.post(
|
598
|
+
_query_url,
|
599
|
+
headers: _headers
|
600
|
+
)
|
601
|
+
OAuth2.apply(config, _request)
|
602
|
+
_response = execute_request(_request)
|
603
|
+
|
604
|
+
# Return appropriate response type.
|
605
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
606
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
607
|
+
ApiResponse.new(
|
608
|
+
_response, data: decoded, errors: _errors
|
609
|
+
)
|
610
|
+
end
|
611
|
+
|
387
612
|
# Creates a loyalty reward. In the process, the endpoint does following:
|
388
613
|
# - Uses the `reward_tier_id` in the request to determine the number of
|
389
614
|
# points
|
@@ -244,8 +244,8 @@ module Square
|
|
244
244
|
# - The `order_id` in the endpoint path, identifying the order to update.
|
245
245
|
# - The latest `version` of the order to update.
|
246
246
|
# - The [sparse
|
247
|
-
# order](https://developer.squareup.com/docs/orders-api/manage-orders
|
248
|
-
# -order-objects)
|
247
|
+
# order](https://developer.squareup.com/docs/orders-api/manage-orders/update
|
248
|
+
# -orders#sparse-order-objects)
|
249
249
|
# containing only the fields to update and the version to which the update
|
250
250
|
# is
|
251
251
|
# being applied.
|
@@ -26,7 +26,7 @@ module Square
|
|
26
26
|
# @param [String] location_id Optional parameter: Limit results to the
|
27
27
|
# location supplied. By default, results are returned for the default (main)
|
28
28
|
# location associated with the seller.
|
29
|
-
# @param [
|
29
|
+
# @param [Integer] total Optional parameter: The exact amount in the
|
30
30
|
# `total_money` for a payment.
|
31
31
|
# @param [String] last_4 Optional parameter: The last four digits of a
|
32
32
|
# payment card.
|
@@ -175,10 +175,10 @@ module Square
|
|
175
175
|
# @param [String] batch_token Optional parameter: A pagination cursor to
|
176
176
|
# retrieve the next set of results for your original query to the
|
177
177
|
# endpoint.
|
178
|
-
# @param [
|
179
|
-
# not to include partial payments in the response.
|
180
|
-
# have the tenders collected so far, but the
|
181
|
-
# until the payment is completed.
|
178
|
+
# @param [TrueClass|FalseClass] include_partial Optional parameter:
|
179
|
+
# Indicates whether or not to include partial payments in the response.
|
180
|
+
# Partial payments will have the tenders collected so far, but the
|
181
|
+
# itemizations will be empty until the payment is completed.
|
182
182
|
# @return [List of V1Payment Hash] response from the API call
|
183
183
|
def list_payments(location_id:,
|
184
184
|
order: nil,
|
@@ -0,0 +1,328 @@
|
|
1
|
+
module Square
|
2
|
+
# WebhookSubscriptionsApi
|
3
|
+
class WebhookSubscriptionsApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Lists all webhook event types that can be subscribed to.
|
9
|
+
# @param [String] api_version Optional parameter: The API version for which
|
10
|
+
# to list event types. Setting this field overrides the default version used
|
11
|
+
# by the application.
|
12
|
+
# @return [ListWebhookEventTypesResponse Hash] response from the API call
|
13
|
+
def list_webhook_event_types(api_version: nil)
|
14
|
+
# Prepare query url.
|
15
|
+
_query_builder = config.get_base_uri
|
16
|
+
_query_builder << '/v2/webhooks/event-types'
|
17
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
18
|
+
_query_builder,
|
19
|
+
'api_version' => api_version
|
20
|
+
)
|
21
|
+
_query_url = APIHelper.clean_url _query_builder
|
22
|
+
|
23
|
+
# Prepare headers.
|
24
|
+
_headers = {
|
25
|
+
'accept' => 'application/json'
|
26
|
+
}
|
27
|
+
|
28
|
+
# Prepare and execute HttpRequest.
|
29
|
+
_request = config.http_client.get(
|
30
|
+
_query_url,
|
31
|
+
headers: _headers
|
32
|
+
)
|
33
|
+
OAuth2.apply(config, _request)
|
34
|
+
_response = execute_request(_request)
|
35
|
+
|
36
|
+
# Return appropriate response type.
|
37
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
38
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
39
|
+
ApiResponse.new(
|
40
|
+
_response, data: decoded, errors: _errors
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Lists all webhook subscriptions owned by your application.
|
45
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
46
|
+
# a previous call to this endpoint. Provide this to retrieve the next set of
|
47
|
+
# results for your original query. For more information, see
|
48
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
49
|
+
# .
|
50
|
+
# @param [TrueClass|FalseClass] include_disabled Optional parameter:
|
51
|
+
# Includes disabled [Subscription]($m/WebhookSubscription)s. By default, all
|
52
|
+
# enabled [Subscription]($m/WebhookSubscription)s are returned.
|
53
|
+
# @param [SortOrder] sort_order Optional parameter: Sorts the returned list
|
54
|
+
# by when the [Subscription]($m/WebhookSubscription) was created with the
|
55
|
+
# specified order. This field defaults to ASC.
|
56
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
57
|
+
# to be returned in a single page. It is possible to receive fewer results
|
58
|
+
# than the specified limit on a given page. The default value of 100 is also
|
59
|
+
# the maximum allowed value. If the provided value is greater than 100, it
|
60
|
+
# is ignored and the default value is used instead. Default: 100
|
61
|
+
# @return [ListWebhookSubscriptionsResponse Hash] response from the API call
|
62
|
+
def list_webhook_subscriptions(cursor: nil,
|
63
|
+
include_disabled: false,
|
64
|
+
sort_order: nil,
|
65
|
+
limit: nil)
|
66
|
+
# Prepare query url.
|
67
|
+
_query_builder = config.get_base_uri
|
68
|
+
_query_builder << '/v2/webhooks/subscriptions'
|
69
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
70
|
+
_query_builder,
|
71
|
+
'cursor' => cursor,
|
72
|
+
'include_disabled' => include_disabled,
|
73
|
+
'sort_order' => sort_order,
|
74
|
+
'limit' => limit
|
75
|
+
)
|
76
|
+
_query_url = APIHelper.clean_url _query_builder
|
77
|
+
|
78
|
+
# Prepare headers.
|
79
|
+
_headers = {
|
80
|
+
'accept' => 'application/json'
|
81
|
+
}
|
82
|
+
|
83
|
+
# Prepare and execute HttpRequest.
|
84
|
+
_request = config.http_client.get(
|
85
|
+
_query_url,
|
86
|
+
headers: _headers
|
87
|
+
)
|
88
|
+
OAuth2.apply(config, _request)
|
89
|
+
_response = execute_request(_request)
|
90
|
+
|
91
|
+
# Return appropriate response type.
|
92
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
93
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
94
|
+
ApiResponse.new(
|
95
|
+
_response, data: decoded, errors: _errors
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Creates a webhook subscription.
|
100
|
+
# @param [CreateWebhookSubscriptionRequest] body Required parameter: An
|
101
|
+
# object containing the fields to POST for the request. See the
|
102
|
+
# corresponding object definition for field details.
|
103
|
+
# @return [CreateWebhookSubscriptionResponse Hash] response from the API call
|
104
|
+
def create_webhook_subscription(body:)
|
105
|
+
# Prepare query url.
|
106
|
+
_query_builder = config.get_base_uri
|
107
|
+
_query_builder << '/v2/webhooks/subscriptions'
|
108
|
+
_query_url = APIHelper.clean_url _query_builder
|
109
|
+
|
110
|
+
# Prepare headers.
|
111
|
+
_headers = {
|
112
|
+
'accept' => 'application/json',
|
113
|
+
'Content-Type' => 'application/json'
|
114
|
+
}
|
115
|
+
|
116
|
+
# Prepare and execute HttpRequest.
|
117
|
+
_request = config.http_client.post(
|
118
|
+
_query_url,
|
119
|
+
headers: _headers,
|
120
|
+
parameters: body.to_json
|
121
|
+
)
|
122
|
+
OAuth2.apply(config, _request)
|
123
|
+
_response = execute_request(_request)
|
124
|
+
|
125
|
+
# Return appropriate response type.
|
126
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
127
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
128
|
+
ApiResponse.new(
|
129
|
+
_response, data: decoded, errors: _errors
|
130
|
+
)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Deletes a webhook subscription.
|
134
|
+
# @param [String] subscription_id Required parameter: [REQUIRED] The ID of
|
135
|
+
# the [Subscription]($m/WebhookSubscription) to delete.
|
136
|
+
# @return [DeleteWebhookSubscriptionResponse Hash] response from the API call
|
137
|
+
def delete_webhook_subscription(subscription_id:)
|
138
|
+
# Prepare query url.
|
139
|
+
_query_builder = config.get_base_uri
|
140
|
+
_query_builder << '/v2/webhooks/subscriptions/{subscription_id}'
|
141
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
142
|
+
_query_builder,
|
143
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
144
|
+
)
|
145
|
+
_query_url = APIHelper.clean_url _query_builder
|
146
|
+
|
147
|
+
# Prepare headers.
|
148
|
+
_headers = {
|
149
|
+
'accept' => 'application/json'
|
150
|
+
}
|
151
|
+
|
152
|
+
# Prepare and execute HttpRequest.
|
153
|
+
_request = config.http_client.delete(
|
154
|
+
_query_url,
|
155
|
+
headers: _headers
|
156
|
+
)
|
157
|
+
OAuth2.apply(config, _request)
|
158
|
+
_response = execute_request(_request)
|
159
|
+
|
160
|
+
# Return appropriate response type.
|
161
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
162
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
163
|
+
ApiResponse.new(
|
164
|
+
_response, data: decoded, errors: _errors
|
165
|
+
)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Retrieves a webhook subscription identified by its ID.
|
169
|
+
# @param [String] subscription_id Required parameter: [REQUIRED] The ID of
|
170
|
+
# the [Subscription]($m/WebhookSubscription) to retrieve.
|
171
|
+
# @return [RetrieveWebhookSubscriptionResponse Hash] response from the API call
|
172
|
+
def retrieve_webhook_subscription(subscription_id:)
|
173
|
+
# Prepare query url.
|
174
|
+
_query_builder = config.get_base_uri
|
175
|
+
_query_builder << '/v2/webhooks/subscriptions/{subscription_id}'
|
176
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
177
|
+
_query_builder,
|
178
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
179
|
+
)
|
180
|
+
_query_url = APIHelper.clean_url _query_builder
|
181
|
+
|
182
|
+
# Prepare headers.
|
183
|
+
_headers = {
|
184
|
+
'accept' => 'application/json'
|
185
|
+
}
|
186
|
+
|
187
|
+
# Prepare and execute HttpRequest.
|
188
|
+
_request = config.http_client.get(
|
189
|
+
_query_url,
|
190
|
+
headers: _headers
|
191
|
+
)
|
192
|
+
OAuth2.apply(config, _request)
|
193
|
+
_response = execute_request(_request)
|
194
|
+
|
195
|
+
# Return appropriate response type.
|
196
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
197
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
198
|
+
ApiResponse.new(
|
199
|
+
_response, data: decoded, errors: _errors
|
200
|
+
)
|
201
|
+
end
|
202
|
+
|
203
|
+
# Updates a webhook subscription.
|
204
|
+
# @param [String] subscription_id Required parameter: [REQUIRED] The ID of
|
205
|
+
# the [Subscription]($m/WebhookSubscription) to update.
|
206
|
+
# @param [UpdateWebhookSubscriptionRequest] body Required parameter: An
|
207
|
+
# object containing the fields to POST for the request. See the
|
208
|
+
# corresponding object definition for field details.
|
209
|
+
# @return [UpdateWebhookSubscriptionResponse Hash] response from the API call
|
210
|
+
def update_webhook_subscription(subscription_id:,
|
211
|
+
body:)
|
212
|
+
# Prepare query url.
|
213
|
+
_query_builder = config.get_base_uri
|
214
|
+
_query_builder << '/v2/webhooks/subscriptions/{subscription_id}'
|
215
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
216
|
+
_query_builder,
|
217
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
218
|
+
)
|
219
|
+
_query_url = APIHelper.clean_url _query_builder
|
220
|
+
|
221
|
+
# Prepare headers.
|
222
|
+
_headers = {
|
223
|
+
'accept' => 'application/json',
|
224
|
+
'Content-Type' => 'application/json'
|
225
|
+
}
|
226
|
+
|
227
|
+
# Prepare and execute HttpRequest.
|
228
|
+
_request = config.http_client.put(
|
229
|
+
_query_url,
|
230
|
+
headers: _headers,
|
231
|
+
parameters: body.to_json
|
232
|
+
)
|
233
|
+
OAuth2.apply(config, _request)
|
234
|
+
_response = execute_request(_request)
|
235
|
+
|
236
|
+
# Return appropriate response type.
|
237
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
238
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
239
|
+
ApiResponse.new(
|
240
|
+
_response, data: decoded, errors: _errors
|
241
|
+
)
|
242
|
+
end
|
243
|
+
|
244
|
+
# Updates a webhook subscription by replacing the existing signature key
|
245
|
+
# with a new one.
|
246
|
+
# @param [String] subscription_id Required parameter: [REQUIRED] The ID of
|
247
|
+
# the [Subscription]($m/WebhookSubscription) to update.
|
248
|
+
# @param [UpdateWebhookSubscriptionSignatureKeyRequest] body Required
|
249
|
+
# parameter: An object containing the fields to POST for the request. See
|
250
|
+
# the corresponding object definition for field details.
|
251
|
+
# @return [UpdateWebhookSubscriptionSignatureKeyResponse Hash] response from the API call
|
252
|
+
def update_webhook_subscription_signature_key(subscription_id:,
|
253
|
+
body:)
|
254
|
+
# Prepare query url.
|
255
|
+
_query_builder = config.get_base_uri
|
256
|
+
_query_builder << '/v2/webhooks/subscriptions/{subscription_id}/signature-key'
|
257
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
258
|
+
_query_builder,
|
259
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
260
|
+
)
|
261
|
+
_query_url = APIHelper.clean_url _query_builder
|
262
|
+
|
263
|
+
# Prepare headers.
|
264
|
+
_headers = {
|
265
|
+
'accept' => 'application/json',
|
266
|
+
'Content-Type' => 'application/json'
|
267
|
+
}
|
268
|
+
|
269
|
+
# Prepare and execute HttpRequest.
|
270
|
+
_request = config.http_client.post(
|
271
|
+
_query_url,
|
272
|
+
headers: _headers,
|
273
|
+
parameters: body.to_json
|
274
|
+
)
|
275
|
+
OAuth2.apply(config, _request)
|
276
|
+
_response = execute_request(_request)
|
277
|
+
|
278
|
+
# Return appropriate response type.
|
279
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
280
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
281
|
+
ApiResponse.new(
|
282
|
+
_response, data: decoded, errors: _errors
|
283
|
+
)
|
284
|
+
end
|
285
|
+
|
286
|
+
# Tests a webhook subscription by sending a test event to the notification
|
287
|
+
# URL.
|
288
|
+
# @param [String] subscription_id Required parameter: [REQUIRED] The ID of
|
289
|
+
# the [Subscription]($m/WebhookSubscription) to test.
|
290
|
+
# @param [TestWebhookSubscriptionRequest] body Required parameter: An object
|
291
|
+
# containing the fields to POST for the request. See the corresponding
|
292
|
+
# object definition for field details.
|
293
|
+
# @return [TestWebhookSubscriptionResponse Hash] response from the API call
|
294
|
+
def test_webhook_subscription(subscription_id:,
|
295
|
+
body:)
|
296
|
+
# Prepare query url.
|
297
|
+
_query_builder = config.get_base_uri
|
298
|
+
_query_builder << '/v2/webhooks/subscriptions/{subscription_id}/test'
|
299
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
300
|
+
_query_builder,
|
301
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
302
|
+
)
|
303
|
+
_query_url = APIHelper.clean_url _query_builder
|
304
|
+
|
305
|
+
# Prepare headers.
|
306
|
+
_headers = {
|
307
|
+
'accept' => 'application/json',
|
308
|
+
'Content-Type' => 'application/json'
|
309
|
+
}
|
310
|
+
|
311
|
+
# Prepare and execute HttpRequest.
|
312
|
+
_request = config.http_client.post(
|
313
|
+
_query_url,
|
314
|
+
headers: _headers,
|
315
|
+
parameters: body.to_json
|
316
|
+
)
|
317
|
+
OAuth2.apply(config, _request)
|
318
|
+
_response = execute_request(_request)
|
319
|
+
|
320
|
+
# Return appropriate response type.
|
321
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
322
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
323
|
+
ApiResponse.new(
|
324
|
+
_response, data: decoded, errors: _errors
|
325
|
+
)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|