square.rb 8.0.0.20201216 → 26.1.0.20230119
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +79 -221
- data/lib/square/api/apple_pay_api.rb +15 -8
- data/lib/square/api/bank_accounts_api.rb +5 -5
- data/lib/square/api/base_api.rb +27 -9
- data/lib/square/api/booking_custom_attributes_api.rb +555 -0
- data/lib/square/api/bookings_api.rb +107 -15
- data/lib/square/api/cards_api.rb +171 -0
- data/lib/square/api/cash_drawers_api.rb +2 -2
- data/lib/square/api/catalog_api.rb +167 -73
- data/lib/square/api/checkout_api.rb +205 -3
- data/lib/square/api/customer_custom_attributes_api.rb +561 -0
- data/lib/square/api/customer_groups_api.rb +17 -8
- data/lib/square/api/customer_segments_api.rb +15 -6
- data/lib/square/api/customers_api.rb +67 -33
- data/lib/square/api/devices_api.rb +3 -2
- data/lib/square/api/disputes_api.rb +109 -105
- data/lib/square/api/gift_card_activities_api.rb +132 -0
- data/lib/square/api/gift_cards_api.rb +298 -0
- data/lib/square/api/inventory_api.rb +263 -24
- data/lib/square/api/invoices_api.rb +21 -21
- data/lib/square/api/labor_api.rb +70 -68
- data/lib/square/api/location_custom_attributes_api.rb +584 -0
- data/lib/square/api/locations_api.rb +21 -14
- data/lib/square/api/loyalty_api.rb +333 -50
- data/lib/square/api/merchants_api.rb +11 -9
- data/lib/square/api/mobile_authorization_api.rb +4 -4
- data/lib/square/api/o_auth_api.rb +78 -25
- data/lib/square/api/order_custom_attributes_api.rb +601 -0
- data/lib/square/api/orders_api.rb +84 -45
- data/lib/square/api/payments_api.rb +72 -24
- data/lib/square/api/payouts_api.rb +173 -0
- data/lib/square/api/refunds_api.rb +18 -7
- data/lib/square/api/sites_api.rb +43 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/subscriptions_api.rb +190 -15
- data/lib/square/api/team_api.rb +46 -46
- data/lib/square/api/terminal_api.rb +172 -22
- data/lib/square/api/transactions_api.rb +15 -191
- data/lib/square/api/v1_transactions_api.rb +52 -124
- data/lib/square/api/vendors_api.rb +257 -0
- data/lib/square/api/webhook_subscriptions_api.rb +327 -0
- data/lib/square/api_helper.rb +217 -57
- data/lib/square/client.rb +90 -18
- data/lib/square/configuration.rb +64 -20
- data/lib/square/exceptions/validation_exception.rb +13 -0
- data/lib/square/http/api_response.rb +7 -9
- data/lib/square/http/faraday_client.rb +40 -9
- data/lib/square/http/http_client.rb +31 -12
- data/lib/square/http/http_request.rb +6 -2
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +56 -44
- data/test/api/test_locations_api.rb +2 -5
- data/test/test_helper.rb +2 -2
- metadata +83 -15
- data/lib/square/api/v1_employees_api.rb +0 -751
- data/lib/square/api/v1_items_api.rb +0 -1766
@@ -5,7 +5,8 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Creates a loyalty account.
|
8
|
+
# Creates a loyalty account. To create a loyalty account, you must provide
|
9
|
+
# the `program_id` and a `mapping` with the `phone_number` of the buyer.
|
9
10
|
# @param [CreateLoyaltyAccountRequest] body Required parameter: An object
|
10
11
|
# containing the fields to POST for the request. See the corresponding
|
11
12
|
# object definition for field details.
|
@@ -19,7 +20,7 @@ module Square
|
|
19
20
|
# Prepare headers.
|
20
21
|
_headers = {
|
21
22
|
'accept' => 'application/json',
|
22
|
-
'
|
23
|
+
'Content-Type' => 'application/json'
|
23
24
|
}
|
24
25
|
|
25
26
|
# Prepare and execute HttpRequest.
|
@@ -57,7 +58,7 @@ module Square
|
|
57
58
|
# Prepare headers.
|
58
59
|
_headers = {
|
59
60
|
'accept' => 'application/json',
|
60
|
-
'
|
61
|
+
'Content-Type' => 'application/json'
|
61
62
|
}
|
62
63
|
|
63
64
|
# Prepare and execute HttpRequest.
|
@@ -79,7 +80,7 @@ module Square
|
|
79
80
|
|
80
81
|
# Retrieves a loyalty account.
|
81
82
|
# @param [String] account_id Required parameter: The ID of the [loyalty
|
82
|
-
# account](
|
83
|
+
# account]($m/LoyaltyAccount) to retrieve.
|
83
84
|
# @return [RetrieveLoyaltyAccountResponse Hash] response from the API call
|
84
85
|
def retrieve_loyalty_account(account_id:)
|
85
86
|
# Prepare query url.
|
@@ -112,21 +113,33 @@ module Square
|
|
112
113
|
)
|
113
114
|
end
|
114
115
|
|
115
|
-
# Adds points to a loyalty
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
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 base loyalty program. For
|
137
|
+
# information about computing points earned from a loyalty promotion, see
|
138
|
+
# [Calculating promotion
|
139
|
+
# points](https://developer.squareup.com/docs/loyalty-api/loyalty-promotions
|
140
|
+
# #calculate-promotion-points).
|
141
|
+
# @param [String] account_id Required parameter: The ID of the target
|
142
|
+
# [loyalty account]($m/LoyaltyAccount).
|
130
143
|
# @param [AccumulateLoyaltyPointsRequest] body Required parameter: An object
|
131
144
|
# containing the fields to POST for the request. See the corresponding
|
132
145
|
# object definition for field details.
|
@@ -145,7 +158,7 @@ module Square
|
|
145
158
|
# Prepare headers.
|
146
159
|
_headers = {
|
147
160
|
'accept' => 'application/json',
|
148
|
-
'
|
161
|
+
'Content-Type' => 'application/json'
|
149
162
|
}
|
150
163
|
|
151
164
|
# Prepare and execute HttpRequest.
|
@@ -168,10 +181,10 @@ module Square
|
|
168
181
|
# Adds points to or subtracts points from a buyer's account.
|
169
182
|
# Use this endpoint only when you need to manually adjust points. Otherwise,
|
170
183
|
# in your application flow, you call
|
171
|
-
# [AccumulateLoyaltyPoints](
|
184
|
+
# [AccumulateLoyaltyPoints]($e/Loyalty/AccumulateLoyaltyPoints)
|
172
185
|
# to add points when a buyer pays for the purchase.
|
173
|
-
# @param [String] account_id Required parameter: The ID of the
|
174
|
-
# account](
|
186
|
+
# @param [String] account_id Required parameter: The ID of the target
|
187
|
+
# [loyalty account]($m/LoyaltyAccount).
|
175
188
|
# @param [AdjustLoyaltyPointsRequest] body Required parameter: An object
|
176
189
|
# containing the fields to POST for the request. See the corresponding
|
177
190
|
# object definition for field details.
|
@@ -190,7 +203,7 @@ module Square
|
|
190
203
|
# Prepare headers.
|
191
204
|
_headers = {
|
192
205
|
'accept' => 'application/json',
|
193
|
-
'
|
206
|
+
'Content-Type' => 'application/json'
|
194
207
|
}
|
195
208
|
|
196
209
|
# Prepare and execute HttpRequest.
|
@@ -217,6 +230,7 @@ module Square
|
|
217
230
|
# (for example, points earned, points redeemed, and points expired) is
|
218
231
|
# recorded in the ledger. Using this endpoint, you can search the ledger for
|
219
232
|
# events.
|
233
|
+
# Search results are sorted by `created_at` in descending order.
|
220
234
|
# @param [SearchLoyaltyEventsRequest] body Required parameter: An object
|
221
235
|
# containing the fields to POST for the request. See the corresponding
|
222
236
|
# object definition for field details.
|
@@ -230,7 +244,7 @@ module Square
|
|
230
244
|
# Prepare headers.
|
231
245
|
_headers = {
|
232
246
|
'accept' => 'application/json',
|
233
|
-
'
|
247
|
+
'Content-Type' => 'application/json'
|
234
248
|
}
|
235
249
|
|
236
250
|
# Prepare and execute HttpRequest.
|
@@ -251,9 +265,16 @@ module Square
|
|
251
265
|
end
|
252
266
|
|
253
267
|
# Returns a list of loyalty programs in the seller's account.
|
254
|
-
#
|
268
|
+
# Loyalty programs define how buyers can earn points and redeem points for
|
269
|
+
# rewards. Square sellers can have only one loyalty program, which is
|
270
|
+
# created and managed from the Seller Dashboard. For more information, see
|
271
|
+
# [Loyalty Program
|
272
|
+
# Overview](https://developer.squareup.com/docs/loyalty/overview).
|
273
|
+
# Replaced with [RetrieveLoyaltyProgram]($e/Loyalty/RetrieveLoyaltyProgram)
|
274
|
+
# when used with the keyword `main`.
|
255
275
|
# @return [ListLoyaltyProgramsResponse Hash] response from the API call
|
256
276
|
def list_loyalty_programs
|
277
|
+
warn 'Endpoint list_loyalty_programs in LoyaltyApi is deprecated'
|
257
278
|
# Prepare query url.
|
258
279
|
_query_builder = config.get_base_uri
|
259
280
|
_query_builder << '/v2/loyalty/programs'
|
@@ -280,18 +301,74 @@ module Square
|
|
280
301
|
)
|
281
302
|
end
|
282
303
|
|
283
|
-
#
|
284
|
-
#
|
285
|
-
#
|
286
|
-
#
|
287
|
-
#
|
288
|
-
#
|
289
|
-
#
|
290
|
-
#
|
291
|
-
# can
|
292
|
-
#
|
293
|
-
# @
|
294
|
-
|
304
|
+
# Retrieves the loyalty program in a seller's account, specified by the
|
305
|
+
# program ID or the keyword `main`.
|
306
|
+
# Loyalty programs define how buyers can earn points and redeem points for
|
307
|
+
# rewards. Square sellers can have only one loyalty program, which is
|
308
|
+
# created and managed from the Seller Dashboard. For more information, see
|
309
|
+
# [Loyalty Program
|
310
|
+
# Overview](https://developer.squareup.com/docs/loyalty/overview).
|
311
|
+
# @param [String] program_id Required parameter: The ID of the loyalty
|
312
|
+
# program or the keyword `main`. Either value can be used to retrieve the
|
313
|
+
# single loyalty program that belongs to the seller.
|
314
|
+
# @return [RetrieveLoyaltyProgramResponse Hash] response from the API call
|
315
|
+
def retrieve_loyalty_program(program_id:)
|
316
|
+
# Prepare query url.
|
317
|
+
_query_builder = config.get_base_uri
|
318
|
+
_query_builder << '/v2/loyalty/programs/{program_id}'
|
319
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
320
|
+
_query_builder,
|
321
|
+
'program_id' => { 'value' => program_id, 'encode' => true }
|
322
|
+
)
|
323
|
+
_query_url = APIHelper.clean_url _query_builder
|
324
|
+
|
325
|
+
# Prepare headers.
|
326
|
+
_headers = {
|
327
|
+
'accept' => 'application/json'
|
328
|
+
}
|
329
|
+
|
330
|
+
# Prepare and execute HttpRequest.
|
331
|
+
_request = config.http_client.get(
|
332
|
+
_query_url,
|
333
|
+
headers: _headers
|
334
|
+
)
|
335
|
+
OAuth2.apply(config, _request)
|
336
|
+
_response = execute_request(_request)
|
337
|
+
|
338
|
+
# Return appropriate response type.
|
339
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
340
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
341
|
+
ApiResponse.new(
|
342
|
+
_response, data: decoded, errors: _errors
|
343
|
+
)
|
344
|
+
end
|
345
|
+
|
346
|
+
# Calculates the number of points a buyer can earn from a purchase.
|
347
|
+
# Applications might call this endpoint
|
348
|
+
# to display the points to the buyer.
|
349
|
+
# - If you are using the Orders API to manage orders, provide the `order_id`
|
350
|
+
# and (optional) `loyalty_account_id`.
|
351
|
+
# Square reads the order to compute the points earned from the base loyalty
|
352
|
+
# program and an associated
|
353
|
+
# [loyalty promotion]($m/LoyaltyPromotion).
|
354
|
+
# - If you are not using the Orders API to manage orders, provide
|
355
|
+
# `transaction_amount_money` with the
|
356
|
+
# purchase amount. Square uses this amount to calculate the points earned
|
357
|
+
# from the base loyalty program,
|
358
|
+
# but not points earned from a loyalty promotion. For spend-based and
|
359
|
+
# visit-based programs, the `tax_mode`
|
360
|
+
# setting of the accrual rule indicates how taxes should be treated for
|
361
|
+
# loyalty points accrual.
|
362
|
+
# If the purchase qualifies for program points, call
|
363
|
+
# [ListLoyaltyPromotions]($e/Loyalty/ListLoyaltyPromotions) and perform a
|
364
|
+
# client-side computation
|
365
|
+
# to calculate whether the purchase also qualifies for promotion points. For
|
366
|
+
# more information, see
|
367
|
+
# [Calculating promotion
|
368
|
+
# points](https://developer.squareup.com/docs/loyalty-api/loyalty-promotions
|
369
|
+
# #calculate-promotion-points).
|
370
|
+
# @param [String] program_id Required parameter: The ID of the [loyalty
|
371
|
+
# program]($m/LoyaltyProgram), which defines the rules for accruing
|
295
372
|
# points.
|
296
373
|
# @param [CalculateLoyaltyPointsRequest] body Required parameter: An object
|
297
374
|
# containing the fields to POST for the request. See the corresponding
|
@@ -311,7 +388,7 @@ module Square
|
|
311
388
|
# Prepare headers.
|
312
389
|
_headers = {
|
313
390
|
'accept' => 'application/json',
|
314
|
-
'
|
391
|
+
'Content-Type' => 'application/json'
|
315
392
|
}
|
316
393
|
|
317
394
|
# Prepare and execute HttpRequest.
|
@@ -331,6 +408,210 @@ module Square
|
|
331
408
|
)
|
332
409
|
end
|
333
410
|
|
411
|
+
# Lists the loyalty promotions associated with a [loyalty
|
412
|
+
# program]($m/LoyaltyProgram).
|
413
|
+
# Results are sorted by the `created_at` date in descending order (newest to
|
414
|
+
# oldest).
|
415
|
+
# @param [String] program_id Required parameter: The ID of the base [loyalty
|
416
|
+
# program]($m/LoyaltyProgram). To get the program ID, call
|
417
|
+
# [RetrieveLoyaltyProgram]($e/Loyalty/RetrieveLoyaltyProgram) using the
|
418
|
+
# `main` keyword.
|
419
|
+
# @param [LoyaltyPromotionStatus] status Optional parameter: The status to
|
420
|
+
# filter the results by. If a status is provided, only loyalty promotions
|
421
|
+
# with the specified status are returned. Otherwise, all loyalty promotions
|
422
|
+
# associated with the loyalty program are returned.
|
423
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
424
|
+
# paged response from the previous call to this endpoint. Provide this
|
425
|
+
# cursor to retrieve the next page of results for your original request. For
|
426
|
+
# more information, see
|
427
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
428
|
+
# atterns/pagination).
|
429
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
430
|
+
# to return in a single paged response. The minimum value is 1 and the
|
431
|
+
# maximum value is 30. The default value is 30. For more information, see
|
432
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
433
|
+
# atterns/pagination).
|
434
|
+
# @return [ListLoyaltyPromotionsResponse Hash] response from the API call
|
435
|
+
def list_loyalty_promotions(program_id:,
|
436
|
+
status: nil,
|
437
|
+
cursor: nil,
|
438
|
+
limit: nil)
|
439
|
+
# Prepare query url.
|
440
|
+
_query_builder = config.get_base_uri
|
441
|
+
_query_builder << '/v2/loyalty/programs/{program_id}/promotions'
|
442
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
443
|
+
_query_builder,
|
444
|
+
'program_id' => { 'value' => program_id, 'encode' => true }
|
445
|
+
)
|
446
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
447
|
+
_query_builder,
|
448
|
+
'status' => status,
|
449
|
+
'cursor' => cursor,
|
450
|
+
'limit' => limit
|
451
|
+
)
|
452
|
+
_query_url = APIHelper.clean_url _query_builder
|
453
|
+
|
454
|
+
# Prepare headers.
|
455
|
+
_headers = {
|
456
|
+
'accept' => 'application/json'
|
457
|
+
}
|
458
|
+
|
459
|
+
# Prepare and execute HttpRequest.
|
460
|
+
_request = config.http_client.get(
|
461
|
+
_query_url,
|
462
|
+
headers: _headers
|
463
|
+
)
|
464
|
+
OAuth2.apply(config, _request)
|
465
|
+
_response = execute_request(_request)
|
466
|
+
|
467
|
+
# Return appropriate response type.
|
468
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
469
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
470
|
+
ApiResponse.new(
|
471
|
+
_response, data: decoded, errors: _errors
|
472
|
+
)
|
473
|
+
end
|
474
|
+
|
475
|
+
# Creates a loyalty promotion for a [loyalty program]($m/LoyaltyProgram). A
|
476
|
+
# loyalty promotion
|
477
|
+
# enables buyers to earn points in addition to those earned from the base
|
478
|
+
# loyalty program.
|
479
|
+
# This endpoint sets the loyalty promotion to the `ACTIVE` or `SCHEDULED`
|
480
|
+
# status, depending on the
|
481
|
+
# `available_time` setting. A loyalty program can have a maximum of 10
|
482
|
+
# loyalty promotions with an
|
483
|
+
# `ACTIVE` or `SCHEDULED` status.
|
484
|
+
# @param [String] program_id Required parameter: The ID of the [loyalty
|
485
|
+
# program]($m/LoyaltyProgram) to associate with the promotion. To get the
|
486
|
+
# program ID, call
|
487
|
+
# [RetrieveLoyaltyProgram]($e/Loyalty/RetrieveLoyaltyProgram) using the
|
488
|
+
# `main` keyword.
|
489
|
+
# @param [CreateLoyaltyPromotionRequest] body Required parameter: An object
|
490
|
+
# containing the fields to POST for the request. See the corresponding
|
491
|
+
# object definition for field details.
|
492
|
+
# @return [CreateLoyaltyPromotionResponse Hash] response from the API call
|
493
|
+
def create_loyalty_promotion(program_id:,
|
494
|
+
body:)
|
495
|
+
# Prepare query url.
|
496
|
+
_query_builder = config.get_base_uri
|
497
|
+
_query_builder << '/v2/loyalty/programs/{program_id}/promotions'
|
498
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
499
|
+
_query_builder,
|
500
|
+
'program_id' => { 'value' => program_id, 'encode' => true }
|
501
|
+
)
|
502
|
+
_query_url = APIHelper.clean_url _query_builder
|
503
|
+
|
504
|
+
# Prepare headers.
|
505
|
+
_headers = {
|
506
|
+
'accept' => 'application/json',
|
507
|
+
'Content-Type' => 'application/json'
|
508
|
+
}
|
509
|
+
|
510
|
+
# Prepare and execute HttpRequest.
|
511
|
+
_request = config.http_client.post(
|
512
|
+
_query_url,
|
513
|
+
headers: _headers,
|
514
|
+
parameters: body.to_json
|
515
|
+
)
|
516
|
+
OAuth2.apply(config, _request)
|
517
|
+
_response = execute_request(_request)
|
518
|
+
|
519
|
+
# Return appropriate response type.
|
520
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
521
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
522
|
+
ApiResponse.new(
|
523
|
+
_response, data: decoded, errors: _errors
|
524
|
+
)
|
525
|
+
end
|
526
|
+
|
527
|
+
# Retrieves a loyalty promotion.
|
528
|
+
# @param [String] promotion_id Required parameter: The ID of the [loyalty
|
529
|
+
# promotion]($m/LoyaltyPromotion) to retrieve.
|
530
|
+
# @param [String] program_id Required parameter: The ID of the base [loyalty
|
531
|
+
# program]($m/LoyaltyProgram). To get the program ID, call
|
532
|
+
# [RetrieveLoyaltyProgram]($e/Loyalty/RetrieveLoyaltyProgram) using the
|
533
|
+
# `main` keyword.
|
534
|
+
# @return [RetrieveLoyaltyPromotionResponse Hash] response from the API call
|
535
|
+
def retrieve_loyalty_promotion(promotion_id:,
|
536
|
+
program_id:)
|
537
|
+
# Prepare query url.
|
538
|
+
_query_builder = config.get_base_uri
|
539
|
+
_query_builder << '/v2/loyalty/programs/{program_id}/promotions/{promotion_id}'
|
540
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
541
|
+
_query_builder,
|
542
|
+
'promotion_id' => { 'value' => promotion_id, 'encode' => true },
|
543
|
+
'program_id' => { 'value' => program_id, 'encode' => true }
|
544
|
+
)
|
545
|
+
_query_url = APIHelper.clean_url _query_builder
|
546
|
+
|
547
|
+
# Prepare headers.
|
548
|
+
_headers = {
|
549
|
+
'accept' => 'application/json'
|
550
|
+
}
|
551
|
+
|
552
|
+
# Prepare and execute HttpRequest.
|
553
|
+
_request = config.http_client.get(
|
554
|
+
_query_url,
|
555
|
+
headers: _headers
|
556
|
+
)
|
557
|
+
OAuth2.apply(config, _request)
|
558
|
+
_response = execute_request(_request)
|
559
|
+
|
560
|
+
# Return appropriate response type.
|
561
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
562
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
563
|
+
ApiResponse.new(
|
564
|
+
_response, data: decoded, errors: _errors
|
565
|
+
)
|
566
|
+
end
|
567
|
+
|
568
|
+
# Cancels a loyalty promotion. Use this endpoint to cancel an `ACTIVE`
|
569
|
+
# promotion earlier than the
|
570
|
+
# end date, cancel an `ACTIVE` promotion when an end date is not specified,
|
571
|
+
# or cancel a `SCHEDULED` promotion.
|
572
|
+
# Because updating a promotion is not supported, you can also use this
|
573
|
+
# endpoint to cancel a promotion before
|
574
|
+
# you create a new one.
|
575
|
+
# This endpoint sets the loyalty promotion to the `CANCELED` state
|
576
|
+
# @param [String] promotion_id Required parameter: The ID of the [loyalty
|
577
|
+
# promotion]($m/LoyaltyPromotion) to cancel. You can cancel a promotion that
|
578
|
+
# has an `ACTIVE` or `SCHEDULED` status.
|
579
|
+
# @param [String] program_id Required parameter: The ID of the base [loyalty
|
580
|
+
# program]($m/LoyaltyProgram).
|
581
|
+
# @return [CancelLoyaltyPromotionResponse Hash] response from the API call
|
582
|
+
def cancel_loyalty_promotion(promotion_id:,
|
583
|
+
program_id:)
|
584
|
+
# Prepare query url.
|
585
|
+
_query_builder = config.get_base_uri
|
586
|
+
_query_builder << '/v2/loyalty/programs/{program_id}/promotions/{promotion_id}/cancel'
|
587
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
588
|
+
_query_builder,
|
589
|
+
'promotion_id' => { 'value' => promotion_id, 'encode' => true },
|
590
|
+
'program_id' => { 'value' => program_id, 'encode' => true }
|
591
|
+
)
|
592
|
+
_query_url = APIHelper.clean_url _query_builder
|
593
|
+
|
594
|
+
# Prepare headers.
|
595
|
+
_headers = {
|
596
|
+
'accept' => 'application/json'
|
597
|
+
}
|
598
|
+
|
599
|
+
# Prepare and execute HttpRequest.
|
600
|
+
_request = config.http_client.post(
|
601
|
+
_query_url,
|
602
|
+
headers: _headers
|
603
|
+
)
|
604
|
+
OAuth2.apply(config, _request)
|
605
|
+
_response = execute_request(_request)
|
606
|
+
|
607
|
+
# Return appropriate response type.
|
608
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
609
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
610
|
+
ApiResponse.new(
|
611
|
+
_response, data: decoded, errors: _errors
|
612
|
+
)
|
613
|
+
end
|
614
|
+
|
334
615
|
# Creates a loyalty reward. In the process, the endpoint does following:
|
335
616
|
# - Uses the `reward_tier_id` in the request to determine the number of
|
336
617
|
# points
|
@@ -352,7 +633,7 @@ module Square
|
|
352
633
|
# Prepare headers.
|
353
634
|
_headers = {
|
354
635
|
'accept' => 'application/json',
|
355
|
-
'
|
636
|
+
'Content-Type' => 'application/json'
|
356
637
|
}
|
357
638
|
|
358
639
|
# Prepare and execute HttpRequest.
|
@@ -372,11 +653,13 @@ module Square
|
|
372
653
|
)
|
373
654
|
end
|
374
655
|
|
375
|
-
# Searches for loyalty rewards
|
376
|
-
#
|
377
|
-
# `
|
656
|
+
# Searches for loyalty rewards. This endpoint accepts a request with no
|
657
|
+
# query filters and returns results for all loyalty accounts.
|
658
|
+
# If you include a `query` object, `loyalty_account_id` is required and
|
659
|
+
# `status` is optional.
|
378
660
|
# If you know a reward ID, use the
|
379
|
-
# [RetrieveLoyaltyReward](
|
661
|
+
# [RetrieveLoyaltyReward]($e/Loyalty/RetrieveLoyaltyReward) endpoint.
|
662
|
+
# Search results are sorted by `updated_at` in descending order.
|
380
663
|
# @param [SearchLoyaltyRewardsRequest] body Required parameter: An object
|
381
664
|
# containing the fields to POST for the request. See the corresponding
|
382
665
|
# object definition for field details.
|
@@ -390,7 +673,7 @@ module Square
|
|
390
673
|
# Prepare headers.
|
391
674
|
_headers = {
|
392
675
|
'accept' => 'application/json',
|
393
|
-
'
|
676
|
+
'Content-Type' => 'application/json'
|
394
677
|
}
|
395
678
|
|
396
679
|
# Prepare and execute HttpRequest.
|
@@ -413,12 +696,12 @@ module Square
|
|
413
696
|
# Deletes a loyalty reward by doing the following:
|
414
697
|
# - Returns the loyalty points back to the loyalty account.
|
415
698
|
# - If an order ID was specified when the reward was created
|
416
|
-
# (see [CreateLoyaltyReward](
|
699
|
+
# (see [CreateLoyaltyReward]($e/Loyalty/CreateLoyaltyReward)),
|
417
700
|
# it updates the order by removing the reward and related
|
418
701
|
# discounts.
|
419
702
|
# You cannot delete a reward that has reached the terminal state (REDEEMED).
|
420
703
|
# @param [String] reward_id Required parameter: The ID of the [loyalty
|
421
|
-
# reward](
|
704
|
+
# reward]($m/LoyaltyReward) to delete.
|
422
705
|
# @return [DeleteLoyaltyRewardResponse Hash] response from the API call
|
423
706
|
def delete_loyalty_reward(reward_id:)
|
424
707
|
# Prepare query url.
|
@@ -453,7 +736,7 @@ module Square
|
|
453
736
|
|
454
737
|
# Retrieves a loyalty reward.
|
455
738
|
# @param [String] reward_id Required parameter: The ID of the [loyalty
|
456
|
-
# reward](
|
739
|
+
# reward]($m/LoyaltyReward) to retrieve.
|
457
740
|
# @return [RetrieveLoyaltyRewardResponse Hash] response from the API call
|
458
741
|
def retrieve_loyalty_reward(reward_id:)
|
459
742
|
# Prepare query url.
|
@@ -495,7 +778,7 @@ module Square
|
|
495
778
|
# In other words, points used for the reward cannot be returned
|
496
779
|
# to the account.
|
497
780
|
# @param [String] reward_id Required parameter: The ID of the [loyalty
|
498
|
-
# reward](
|
781
|
+
# reward]($m/LoyaltyReward) to redeem.
|
499
782
|
# @param [RedeemLoyaltyRewardRequest] body Required parameter: An object
|
500
783
|
# containing the fields to POST for the request. See the corresponding
|
501
784
|
# object definition for field details.
|
@@ -514,7 +797,7 @@ module Square
|
|
514
797
|
# Prepare headers.
|
515
798
|
_headers = {
|
516
799
|
'accept' => 'application/json',
|
517
|
-
'
|
800
|
+
'Content-Type' => 'application/json'
|
518
801
|
}
|
519
802
|
|
520
803
|
# Prepare and execute HttpRequest.
|
@@ -5,15 +5,17 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
8
|
+
# Provides details about the merchant associated with a given access token.
|
9
|
+
# The access token used to connect your application to a Square seller is
|
10
|
+
# associated
|
11
|
+
# with a single merchant. That means that `ListMerchants` returns a list
|
12
|
+
# with a single `Merchant` object. You can specify your personal access
|
13
|
+
# token
|
14
|
+
# to get your own merchant information or specify an OAuth token to get the
|
15
|
+
# information for the merchant that granted your application access.
|
14
16
|
# If you know the merchant ID, you can also use the
|
15
|
-
# [RetrieveMerchant](
|
16
|
-
# endpoint to
|
17
|
+
# [RetrieveMerchant]($e/Merchants/RetrieveMerchant)
|
18
|
+
# endpoint to retrieve the merchant information.
|
17
19
|
# @param [Integer] cursor Optional parameter: The cursor generated by the
|
18
20
|
# previous response.
|
19
21
|
# @return [ListMerchantsResponse Hash] response from the API call
|
@@ -48,7 +50,7 @@ module Square
|
|
48
50
|
)
|
49
51
|
end
|
50
52
|
|
51
|
-
#
|
53
|
+
# Retrieves the `Merchant` object for the given `merchant_id`.
|
52
54
|
# @param [String] merchant_id Required parameter: The ID of the merchant to
|
53
55
|
# retrieve. If the string "me" is supplied as the ID, then retrieve the
|
54
56
|
# merchant that is currently accessible to this call.
|
@@ -6,9 +6,9 @@ module Square
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# Generates code to authorize a mobile application to connect to a Square
|
9
|
-
# card reader
|
10
|
-
# Authorization codes are one-time-use and expire
|
11
|
-
# issued.
|
9
|
+
# card reader.
|
10
|
+
# Authorization codes are one-time-use codes and expire 60 minutes after
|
11
|
+
# being issued.
|
12
12
|
# __Important:__ The `Authorization` header you provide to this endpoint
|
13
13
|
# must have the following format:
|
14
14
|
# ```
|
@@ -31,7 +31,7 @@ module Square
|
|
31
31
|
# Prepare headers.
|
32
32
|
_headers = {
|
33
33
|
'accept' => 'application/json',
|
34
|
-
'
|
34
|
+
'Content-Type' => 'application/json'
|
35
35
|
}
|
36
36
|
|
37
37
|
# Prepare and execute HttpRequest.
|