square.rb 21.0.0.20220720 → 22.1.0.20220823
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 +1 -1
- data/lib/square/api/checkout_api.rb +5 -5
- data/lib/square/api/customer_custom_attributes_api.rb +43 -22
- data/lib/square/api/customers_api.rb +2 -2
- data/lib/square/api/disputes_api.rb +24 -29
- data/lib/square/api/loyalty_api.rb +256 -31
- data/lib/square/api/webhook_subscriptions_api.rb +328 -0
- data/lib/square/client.rb +8 -2
- data/lib/square/configuration.rb +1 -1
- data/lib/square.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f952653c6d92ab4ba153d309a21a095d59ce4592c5f7660b3a0f91e15ff2815a
|
4
|
+
data.tar.gz: 2f714f5c6b9fcb2b93f999e0d351fffcd0f01a913bfddad6afa9df9429b6f143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ac0adc3626aea0ad54bf9a40b1200429e8359c19a72da3f8e359b33ea686642c29f0f97519a4d9f9831095e64e4b8d3b2dcec35c032dcdf20784baa4e1cb235
|
7
|
+
data.tar.gz: 6b6e81d0b85c809a44df30fd0e53754cc881ebe1c3a37722ef9b4db476f0b2fb8bcf67090ed061b79ea2b0468378fdc409ac2a278bf266fb5efc97567aa5a986
|
data/lib/square/api/base_api.rb
CHANGED
@@ -45,7 +45,7 @@ module Square
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def get_user_agent
|
48
|
-
user_agent = 'Square-Ruby-SDK/
|
48
|
+
user_agent = 'Square-Ruby-SDK/22.1.0.20220823 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
|
49
49
|
user_agent['{engine}'] = RUBY_ENGINE
|
50
50
|
user_agent['{engine-version}'] = RUBY_ENGINE_VERSION
|
51
51
|
user_agent['{os-info}'] = RUBY_PLATFORM
|
@@ -23,6 +23,7 @@ module Square
|
|
23
23
|
# @return [CreateCheckoutResponse Hash] response from the API call
|
24
24
|
def create_checkout(location_id:,
|
25
25
|
body:)
|
26
|
+
warn 'Endpoint create_checkout in CheckoutApi is deprecated'
|
26
27
|
# Prepare query url.
|
27
28
|
_query_builder = config.get_base_uri
|
28
29
|
_query_builder << '/v2/locations/{location_id}/checkouts'
|
@@ -57,14 +58,13 @@ module Square
|
|
57
58
|
|
58
59
|
# Lists all payment links.
|
59
60
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
60
|
-
# a previous call to this endpoint.
|
61
|
-
#
|
62
|
-
#
|
63
|
-
# information, see
|
61
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
62
|
+
# set of results for the original query. If a cursor is not provided, the
|
63
|
+
# endpoint returns the first page of the results. For more information, see
|
64
64
|
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
65
65
|
# .
|
66
66
|
# @param [Integer] limit Optional parameter: A limit on the number of
|
67
|
-
# results to return per page. The limit is advisory and
|
67
|
+
# results to return per page. The limit is advisory and the implementation
|
68
68
|
# might return more or less results. If the supplied limit is negative,
|
69
69
|
# zero, or greater than the maximum limit of 1000, it is ignored. Default
|
70
70
|
# value: `100`
|
@@ -5,14 +5,17 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Lists the customer-related custom attribute
|
9
|
-
# Square seller
|
8
|
+
# Lists the customer-related [custom attribute
|
9
|
+
# definitions]($m/CustomAttributeDefinition) that belong to a Square seller
|
10
|
+
# account.
|
10
11
|
# When all response pages are retrieved, the results include all custom
|
11
12
|
# attribute definitions
|
12
13
|
# that are visible to the requesting application, including those that are
|
13
14
|
# created by other
|
14
15
|
# applications and set to `VISIBILITY_READ_ONLY` or
|
15
|
-
# `VISIBILITY_READ_WRITE_VALUES`.
|
16
|
+
# `VISIBILITY_READ_WRITE_VALUES`. Note that
|
17
|
+
# seller-defined custom attributes (also known as custom fields) are always
|
18
|
+
# set to `VISIBILITY_READ_WRITE_VALUES`.
|
16
19
|
# @param [Integer] limit Optional parameter: The maximum number of results
|
17
20
|
# to return in a single paged response. This limit is advisory. The response
|
18
21
|
# might contain more or fewer results. The minimum value is 1 and the
|
@@ -59,10 +62,10 @@ module Square
|
|
59
62
|
)
|
60
63
|
end
|
61
64
|
|
62
|
-
# Creates a customer-related custom attribute
|
63
|
-
# account.
|
64
|
-
# endpoint to define a custom attribute that can be associated with
|
65
|
-
# profiles.
|
65
|
+
# Creates a customer-related [custom attribute
|
66
|
+
# definition]($m/CustomAttributeDefinition) for a Square seller account.
|
67
|
+
# Use this endpoint to define a custom attribute that can be associated with
|
68
|
+
# customer profiles.
|
66
69
|
# A custom attribute definition specifies the `key`, `visibility`, `schema`,
|
67
70
|
# and other properties
|
68
71
|
# for a custom attribute. After the definition is created, you can call
|
@@ -108,8 +111,8 @@ module Square
|
|
108
111
|
)
|
109
112
|
end
|
110
113
|
|
111
|
-
# Deletes a customer-related custom attribute
|
112
|
-
# seller account.
|
114
|
+
# Deletes a customer-related [custom attribute
|
115
|
+
# definition]($m/CustomAttributeDefinition) from a Square seller account.
|
113
116
|
# Deleting a custom attribute definition also deletes the corresponding
|
114
117
|
# custom attribute from
|
115
118
|
# all customer profiles in the seller's Customer Directory.
|
@@ -148,11 +151,14 @@ module Square
|
|
148
151
|
)
|
149
152
|
end
|
150
153
|
|
151
|
-
# Retrieves a customer-related custom attribute
|
152
|
-
# seller account.
|
154
|
+
# Retrieves a customer-related [custom attribute
|
155
|
+
# definition]($m/CustomAttributeDefinition) from a Square seller account.
|
153
156
|
# To retrieve a custom attribute definition created by another application,
|
154
157
|
# the `visibility`
|
155
158
|
# setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
159
|
+
# Note that seller-defined custom attributes
|
160
|
+
# (also known as custom fields) are always set to
|
161
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
156
162
|
# @param [String] key Required parameter: The key of the custom attribute
|
157
163
|
# definition to retrieve. If the requesting application is not the
|
158
164
|
# definition owner, you must use the qualified key.
|
@@ -199,8 +205,8 @@ module Square
|
|
199
205
|
)
|
200
206
|
end
|
201
207
|
|
202
|
-
# Updates a customer-related custom attribute
|
203
|
-
# account.
|
208
|
+
# Updates a customer-related [custom attribute
|
209
|
+
# definition]($m/CustomAttributeDefinition) for a Square seller account.
|
204
210
|
# Use this endpoint to update the following fields: `name`, `description`,
|
205
211
|
# `visibility`, or the
|
206
212
|
# `schema` for a `Selection` data type.
|
@@ -248,8 +254,8 @@ module Square
|
|
248
254
|
)
|
249
255
|
end
|
250
256
|
|
251
|
-
# Creates or updates custom attributes for customer
|
252
|
-
# operation.
|
257
|
+
# Creates or updates [custom attributes]($m/CustomAttribute) for customer
|
258
|
+
# profiles as a bulk operation.
|
253
259
|
# Use this endpoint to set the value of one or more custom attributes for
|
254
260
|
# one or more customer profiles.
|
255
261
|
# A custom attribute is based on a custom attribute definition in a Square
|
@@ -266,7 +272,10 @@ module Square
|
|
266
272
|
# of the corresponding request.
|
267
273
|
# To create or update a custom attribute owned by another application, the
|
268
274
|
# `visibility` setting
|
269
|
-
# must be `VISIBILITY_READ_WRITE_VALUES`.
|
275
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom
|
276
|
+
# attributes
|
277
|
+
# (also known as custom fields) are always set to
|
278
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
270
279
|
# @param [BulkUpsertCustomerCustomAttributesRequest] body Required
|
271
280
|
# parameter: An object containing the fields to POST for the request. See
|
272
281
|
# the corresponding object definition for field details.
|
@@ -300,7 +309,8 @@ module Square
|
|
300
309
|
)
|
301
310
|
end
|
302
311
|
|
303
|
-
# Lists the custom attributes associated with a
|
312
|
+
# Lists the [custom attributes]($m/CustomAttribute) associated with a
|
313
|
+
# customer profile.
|
304
314
|
# You can use the `with_definitions` query parameter to also retrieve custom
|
305
315
|
# attribute definitions
|
306
316
|
# in the same call.
|
@@ -370,9 +380,12 @@ module Square
|
|
370
380
|
)
|
371
381
|
end
|
372
382
|
|
373
|
-
# Deletes a custom attribute associated with a
|
383
|
+
# Deletes a [custom attribute]($m/CustomAttribute) associated with a
|
384
|
+
# customer profile.
|
374
385
|
# To delete a custom attribute owned by another application, the
|
375
386
|
# `visibility` setting must be
|
387
|
+
# `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attributes
|
388
|
+
# (also known as custom fields) are always set to
|
376
389
|
# `VISIBILITY_READ_WRITE_VALUES`.
|
377
390
|
# @param [String] customer_id Required parameter: The ID of the target
|
378
391
|
# [customer profile]($m/Customer).
|
@@ -414,13 +427,17 @@ module Square
|
|
414
427
|
)
|
415
428
|
end
|
416
429
|
|
417
|
-
# Retrieves a custom attribute associated with a
|
430
|
+
# Retrieves a [custom attribute]($m/CustomAttribute) associated with a
|
431
|
+
# customer profile.
|
418
432
|
# You can use the `with_definition` query parameter to also retrieve the
|
419
433
|
# custom attribute definition
|
420
434
|
# in the same call.
|
421
435
|
# To retrieve a custom attribute owned by another application, the
|
422
436
|
# `visibility` setting must be
|
423
|
-
# `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
437
|
+
# `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Note that
|
438
|
+
# seller-defined custom attributes
|
439
|
+
# (also known as custom fields) are always set to
|
440
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
424
441
|
# @param [String] customer_id Required parameter: The ID of the target
|
425
442
|
# [customer profile]($m/Customer).
|
426
443
|
# @param [String] key Required parameter: The key of the custom attribute to
|
@@ -480,7 +497,8 @@ module Square
|
|
480
497
|
)
|
481
498
|
end
|
482
499
|
|
483
|
-
# Creates or updates a custom attribute for a customer
|
500
|
+
# Creates or updates a [custom attribute]($m/CustomAttribute) for a customer
|
501
|
+
# profile.
|
484
502
|
# Use this endpoint to set the value of a custom attribute for a specified
|
485
503
|
# customer profile.
|
486
504
|
# A custom attribute is based on a custom attribute definition in a Square
|
@@ -490,7 +508,10 @@ module Square
|
|
490
508
|
# teCustomerCustomAttributeDefinition) endpoint.
|
491
509
|
# To create or update a custom attribute owned by another application, the
|
492
510
|
# `visibility` setting
|
493
|
-
# must be `VISIBILITY_READ_WRITE_VALUES`.
|
511
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom
|
512
|
+
# attributes
|
513
|
+
# (also known as custom fields) are always set to
|
514
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
494
515
|
# @param [String] customer_id Required parameter: The ID of the target
|
495
516
|
# [customer profile]($m/Customer).
|
496
517
|
# @param [String] key Required parameter: The key of the custom attribute to
|
@@ -110,8 +110,8 @@ module Square
|
|
110
110
|
)
|
111
111
|
end
|
112
112
|
|
113
|
-
# Searches the customer profiles associated with a Square account using
|
114
|
-
# supported query
|
113
|
+
# Searches the customer profiles associated with a Square account using one
|
114
|
+
# or more supported query filters.
|
115
115
|
# Calling `SearchCustomers` without any explicit query filter returns all
|
116
116
|
# customer profiles ordered alphabetically based on `given_name` and
|
117
117
|
# `family_name`.
|
@@ -11,13 +11,12 @@ module Square
|
|
11
11
|
# set of results for the original query. For more information, see
|
12
12
|
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
13
13
|
# .
|
14
|
-
# @param [DisputeState] states Optional parameter: The dispute states
|
15
|
-
# filter the result. If not specified, the endpoint returns all
|
16
|
-
# disputes
|
14
|
+
# @param [DisputeState] states Optional parameter: The dispute states used
|
15
|
+
# to filter the result. If not specified, the endpoint returns all
|
16
|
+
# disputes.
|
17
17
|
# @param [String] location_id Optional parameter: The ID of the location for
|
18
18
|
# which to return a list of disputes. If not specified, the endpoint returns
|
19
|
-
#
|
20
|
-
# `LOST`) associated with all locations.
|
19
|
+
# disputes associated with all locations.
|
21
20
|
# @return [ListDisputesResponse Hash] response from the API call
|
22
21
|
def list_disputes(cursor: nil,
|
23
22
|
states: nil,
|
@@ -134,8 +133,8 @@ module Square
|
|
134
133
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
135
134
|
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
136
135
|
# set of results for the original query. For more information, see
|
137
|
-
# [Pagination](https://developer.squareup.com/docs/basics/
|
138
|
-
# .
|
136
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
137
|
+
# atterns/pagination).
|
139
138
|
# @return [ListDisputeEvidenceResponse Hash] response from the API call
|
140
139
|
def list_dispute_evidence(dispute_id:,
|
141
140
|
cursor: nil)
|
@@ -177,8 +176,8 @@ module Square
|
|
177
176
|
# accepts HTTP
|
178
177
|
# multipart/form-data file uploads in HEIC, HEIF, JPEG, PDF, PNG, and TIFF
|
179
178
|
# formats.
|
180
|
-
# @param [String] dispute_id Required parameter: The ID of the dispute
|
181
|
-
# want to upload evidence
|
179
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute for
|
180
|
+
# which you want to upload evidence.
|
182
181
|
# @param [CreateDisputeEvidenceFileRequest] request Optional parameter:
|
183
182
|
# Defines the parameters for a `CreateDisputeEvidenceFile` request.
|
184
183
|
# @param [File | UploadIO] image_file Optional parameter: Example:
|
@@ -239,8 +238,8 @@ module Square
|
|
239
238
|
end
|
240
239
|
|
241
240
|
# Uploads text to use as evidence for a dispute challenge.
|
242
|
-
# @param [String] dispute_id Required parameter: The ID of the dispute
|
243
|
-
# want to upload evidence
|
241
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute for
|
242
|
+
# which you want to upload evidence.
|
244
243
|
# @param [CreateDisputeEvidenceTextRequest] body Required parameter: An
|
245
244
|
# object containing the fields to POST for the request. See the
|
246
245
|
# corresponding object definition for field details.
|
@@ -280,12 +279,9 @@ module Square
|
|
280
279
|
end
|
281
280
|
|
282
281
|
# Removes specified evidence from a dispute.
|
283
|
-
# Square does not send the bank any evidence that is removed.
|
284
|
-
#
|
285
|
-
#
|
286
|
-
# [SubmitEvidence]($e/Disputes/SubmitEvidence).
|
287
|
-
# @param [String] dispute_id Required parameter: The ID of the dispute you
|
288
|
-
# want to remove evidence from.
|
282
|
+
# Square does not send the bank any evidence that is removed.
|
283
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute from
|
284
|
+
# which you want to remove evidence.
|
289
285
|
# @param [String] evidence_id Required parameter: The ID of the evidence you
|
290
286
|
# want to remove.
|
291
287
|
# @return [DeleteDisputeEvidenceResponse Hash] response from the API call
|
@@ -322,13 +318,11 @@ module Square
|
|
322
318
|
)
|
323
319
|
end
|
324
320
|
|
325
|
-
# Returns the
|
326
|
-
#
|
327
|
-
#
|
328
|
-
#
|
329
|
-
#
|
330
|
-
# @param [String] dispute_id Required parameter: The ID of the dispute that
|
331
|
-
# you want to retrieve evidence from.
|
321
|
+
# Returns the metadata for the evidence specified in the request URL path.
|
322
|
+
# You must maintain a copy of any evidence uploaded if you want to reference
|
323
|
+
# it later. Evidence cannot be downloaded after you upload it.
|
324
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute from
|
325
|
+
# which you want to retrieve evidence metadata.
|
332
326
|
# @param [String] evidence_id Required parameter: The ID of the evidence to
|
333
327
|
# retrieve.
|
334
328
|
# @return [RetrieveDisputeEvidenceResponse Hash] response from the API call
|
@@ -366,15 +360,16 @@ module Square
|
|
366
360
|
end
|
367
361
|
|
368
362
|
# Submits evidence to the cardholder's bank.
|
369
|
-
#
|
370
|
-
# includes evidence uploaded
|
363
|
+
# The evidence submitted by this endpoint includes evidence uploaded
|
371
364
|
# using the
|
372
365
|
# [CreateDisputeEvidenceFile]($e/Disputes/CreateDisputeEvidenceFile) and
|
373
366
|
# [CreateDisputeEvidenceText]($e/Disputes/CreateDisputeEvidenceText)
|
374
367
|
# endpoints and
|
375
|
-
# evidence automatically provided by Square, when available.
|
376
|
-
#
|
377
|
-
#
|
368
|
+
# evidence automatically provided by Square, when available. Evidence cannot
|
369
|
+
# be removed from
|
370
|
+
# a dispute after submission.
|
371
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute for
|
372
|
+
# which you want to submit evidence.
|
378
373
|
# @return [SubmitEvidenceResponse Hash] response from the API call
|
379
374
|
def submit_evidence(dispute_id:)
|
380
375
|
# Prepare query url.
|
@@ -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
|
@@ -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
|
data/lib/square/client.rb
CHANGED
@@ -4,7 +4,7 @@ module Square
|
|
4
4
|
attr_reader :config
|
5
5
|
|
6
6
|
def sdk_version
|
7
|
-
'
|
7
|
+
'22.1.0.20220823'
|
8
8
|
end
|
9
9
|
|
10
10
|
def square_version
|
@@ -231,12 +231,18 @@ module Square
|
|
231
231
|
@vendors ||= VendorsApi.new config
|
232
232
|
end
|
233
233
|
|
234
|
+
# Access to webhook_subscriptions controller.
|
235
|
+
# @return [WebhookSubscriptionsApi] Returns the controller instance.
|
236
|
+
def webhook_subscriptions
|
237
|
+
@webhook_subscriptions ||= WebhookSubscriptionsApi.new config
|
238
|
+
end
|
239
|
+
|
234
240
|
def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
|
235
241
|
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
236
242
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
237
243
|
retry_methods: %i[get put], environment: 'production',
|
238
244
|
custom_url: 'https://connect.squareup.com',
|
239
|
-
square_version: '2022-
|
245
|
+
square_version: '2022-08-23', access_token: '',
|
240
246
|
user_agent_detail: '', additional_headers: {}, config: nil)
|
241
247
|
@config = if config.nil?
|
242
248
|
Configuration.new(connection: connection, adapter: adapter,
|
data/lib/square/configuration.rb
CHANGED
@@ -20,7 +20,7 @@ module Square
|
|
20
20
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
21
21
|
retry_methods: %i[get put], environment: 'production',
|
22
22
|
custom_url: 'https://connect.squareup.com',
|
23
|
-
square_version: '2022-
|
23
|
+
square_version: '2022-08-23', access_token: '',
|
24
24
|
user_agent_detail: '', additional_headers: {})
|
25
25
|
# The Faraday connection object passed by the SDK user for making requests
|
26
26
|
@connection = connection
|
data/lib/square.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: square.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 22.1.0.20220823
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Square Developer Platform
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -229,6 +229,7 @@ files:
|
|
229
229
|
- lib/square/api/transactions_api.rb
|
230
230
|
- lib/square/api/v1_transactions_api.rb
|
231
231
|
- lib/square/api/vendors_api.rb
|
232
|
+
- lib/square/api/webhook_subscriptions_api.rb
|
232
233
|
- lib/square/api_helper.rb
|
233
234
|
- lib/square/client.rb
|
234
235
|
- lib/square/configuration.rb
|