square.rb 6.3.0.20200826 → 17.1.0.20220120

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +86 -51
  4. data/lib/square/api/apple_pay_api.rb +12 -9
  5. data/lib/square/api/bank_accounts_api.rb +21 -24
  6. data/lib/square/api/base_api.rb +20 -9
  7. data/lib/square/api/bookings_api.rb +391 -0
  8. data/lib/square/api/cards_api.rb +170 -0
  9. data/lib/square/api/cash_drawers_api.rb +13 -6
  10. data/lib/square/api/catalog_api.rb +195 -85
  11. data/lib/square/api/checkout_api.rb +7 -5
  12. data/lib/square/api/customer_groups_api.rb +34 -16
  13. data/lib/square/api/customer_segments_api.rb +21 -9
  14. data/lib/square/api/customers_api.rb +102 -55
  15. data/lib/square/api/devices_api.rb +20 -8
  16. data/lib/square/api/disputes_api.rb +156 -144
  17. data/lib/square/api/employees_api.rb +7 -3
  18. data/lib/square/api/gift_card_activities_api.rb +133 -0
  19. data/lib/square/api/gift_cards_api.rb +297 -0
  20. data/lib/square/api/inventory_api.rb +290 -37
  21. data/lib/square/api/invoices_api.rb +61 -57
  22. data/lib/square/api/labor_api.rb +127 -93
  23. data/lib/square/api/locations_api.rb +36 -25
  24. data/lib/square/api/loyalty_api.rb +134 -87
  25. data/lib/square/api/merchants_api.rb +8 -4
  26. data/lib/square/api/mobile_authorization_api.rb +9 -7
  27. data/lib/square/api/o_auth_api.rb +41 -32
  28. data/lib/square/api/orders_api.rb +132 -54
  29. data/lib/square/api/payments_api.rb +133 -75
  30. data/lib/square/api/refunds_api.rb +51 -30
  31. data/lib/square/api/sites_api.rb +43 -0
  32. data/lib/square/api/snippets_api.rb +146 -0
  33. data/lib/square/api/subscriptions_api.rb +216 -26
  34. data/lib/square/api/team_api.rb +81 -65
  35. data/lib/square/api/terminal_api.rb +166 -16
  36. data/lib/square/api/transactions_api.rb +32 -194
  37. data/lib/square/api/v1_transactions_api.rb +53 -103
  38. data/lib/square/api_helper.rb +38 -43
  39. data/lib/square/client.rb +54 -24
  40. data/lib/square/configuration.rb +61 -21
  41. data/lib/square/http/api_response.rb +3 -1
  42. data/lib/square/http/faraday_client.rb +34 -5
  43. data/lib/square/utilities/date_time_helper.rb +151 -0
  44. data/lib/square/utilities/file_wrapper.rb +1 -2
  45. data/lib/square.rb +65 -61
  46. data/spec/user_journey_spec.rb +2 -5
  47. data/test/api/api_test_base.rb +1 -6
  48. data/test/api/test_catalog_api.rb +1 -4
  49. data/test/api/test_customers_api.rb +1 -4
  50. data/test/api/test_employees_api.rb +1 -4
  51. data/test/api/test_labor_api.rb +2 -6
  52. data/test/api/test_locations_api.rb +21 -35
  53. data/test/api/test_merchants_api.rb +1 -4
  54. data/test/api/test_payments_api.rb +3 -6
  55. data/test/api/test_refunds_api.rb +3 -6
  56. data/test/http_response_catcher.rb +0 -5
  57. data/test/test_helper.rb +1 -6
  58. metadata +40 -18
  59. data/lib/square/api/v1_employees_api.rb +0 -723
  60. data/lib/square/api/v1_items_api.rb +0 -1686
  61. data/lib/square/api/v1_locations_api.rb +0 -65
@@ -5,10 +5,8 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Creates a loyalty account. For more information, see
9
- # [Create a loyalty
10
- # account](https://developer.squareup.com/docs/docs/loyalty-api/overview/#lo
11
- # yalty-overview-create-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.
12
10
  # @param [CreateLoyaltyAccountRequest] body Required parameter: An object
13
11
  # containing the fields to POST for the request. See the corresponding
14
12
  # object definition for field details.
@@ -22,7 +20,7 @@ module Square
22
20
  # Prepare headers.
23
21
  _headers = {
24
22
  'accept' => 'application/json',
25
- 'content-type' => 'application/json; charset=utf-8'
23
+ 'Content-Type' => 'application/json'
26
24
  }
27
25
 
28
26
  # Prepare and execute HttpRequest.
@@ -37,13 +35,16 @@ module Square
37
35
  # Return appropriate response type.
38
36
  decoded = APIHelper.json_deserialize(_response.raw_body)
39
37
  _errors = APIHelper.map_response(decoded, ['errors'])
40
- ApiResponse.new(_response, data: decoded, errors: _errors)
38
+ ApiResponse.new(
39
+ _response, data: decoded, errors: _errors
40
+ )
41
41
  end
42
42
 
43
- # Searches for loyalty accounts.
44
- # In the current implementation, you can search for a loyalty account using
45
- # the phone number associated with the account.
46
- # If no phone number is provided, all loyalty accounts are returned.
43
+ # Searches for loyalty accounts in a loyalty program.
44
+ # You can search for a loyalty account using the phone number or customer ID
45
+ # associated with the account. To return all loyalty accounts, specify an
46
+ # empty `query` object or omit it entirely.
47
+ # Search results are sorted by `created_at` in ascending order.
47
48
  # @param [SearchLoyaltyAccountsRequest] body Required parameter: An object
48
49
  # containing the fields to POST for the request. See the corresponding
49
50
  # object definition for field details.
@@ -57,7 +58,7 @@ module Square
57
58
  # Prepare headers.
58
59
  _headers = {
59
60
  'accept' => 'application/json',
60
- 'content-type' => 'application/json; charset=utf-8'
61
+ 'Content-Type' => 'application/json'
61
62
  }
62
63
 
63
64
  # Prepare and execute HttpRequest.
@@ -72,12 +73,14 @@ module Square
72
73
  # Return appropriate response type.
73
74
  decoded = APIHelper.json_deserialize(_response.raw_body)
74
75
  _errors = APIHelper.map_response(decoded, ['errors'])
75
- ApiResponse.new(_response, data: decoded, errors: _errors)
76
+ ApiResponse.new(
77
+ _response, data: decoded, errors: _errors
78
+ )
76
79
  end
77
80
 
78
81
  # Retrieves a loyalty account.
79
82
  # @param [String] account_id Required parameter: The ID of the [loyalty
80
- # account](#type-LoyaltyAccount) to retrieve.
83
+ # account]($m/LoyaltyAccount) to retrieve.
81
84
  # @return [RetrieveLoyaltyAccountResponse Hash] response from the API call
82
85
  def retrieve_loyalty_account(account_id:)
83
86
  # Prepare query url.
@@ -85,7 +88,7 @@ module Square
85
88
  _query_builder << '/v2/loyalty/accounts/{account_id}'
86
89
  _query_builder = APIHelper.append_url_with_template_parameters(
87
90
  _query_builder,
88
- 'account_id' => account_id
91
+ 'account_id' => { 'value' => account_id, 'encode' => true }
89
92
  )
90
93
  _query_url = APIHelper.clean_url _query_builder
91
94
 
@@ -105,7 +108,9 @@ module Square
105
108
  # Return appropriate response type.
106
109
  decoded = APIHelper.json_deserialize(_response.raw_body)
107
110
  _errors = APIHelper.map_response(decoded, ['errors'])
108
- ApiResponse.new(_response, data: decoded, errors: _errors)
111
+ ApiResponse.new(
112
+ _response, data: decoded, errors: _errors
113
+ )
109
114
  end
110
115
 
111
116
  # Adds points to a loyalty account.
@@ -115,16 +120,12 @@ module Square
115
120
  # account.
116
121
  # - If you are not using the Orders API to manage orders,
117
122
  # you first perform a client-side computation to compute the points.
118
- # For spend-based and visit-based programs, you can call
119
- # `CalculateLoyaltyPoints` to compute the points. For more information,
120
- # see [Loyalty Program
121
- # Overview](https://developer.squareup.com/docs/docs/loyalty/overview).
122
- # You then provide the points in a request to this endpoint.
123
- # For more information, see [Accumulate
124
- # points](https://developer.squareup.com/docs/docs/loyalty-api/overview/#acc
125
- # umulate-points).
123
+ # For spend-based and visit-based programs, you can first call
124
+ # [CalculateLoyaltyPoints]($e/Loyalty/CalculateLoyaltyPoints) to compute the
125
+ # points
126
+ # that you provide to this endpoint.
126
127
  # @param [String] account_id Required parameter: The [loyalty
127
- # account](#type-LoyaltyAccount) ID to which to add the points.
128
+ # account]($m/LoyaltyAccount) ID to which to add the points.
128
129
  # @param [AccumulateLoyaltyPointsRequest] body Required parameter: An object
129
130
  # containing the fields to POST for the request. See the corresponding
130
131
  # object definition for field details.
@@ -136,14 +137,14 @@ module Square
136
137
  _query_builder << '/v2/loyalty/accounts/{account_id}/accumulate'
137
138
  _query_builder = APIHelper.append_url_with_template_parameters(
138
139
  _query_builder,
139
- 'account_id' => account_id
140
+ 'account_id' => { 'value' => account_id, 'encode' => true }
140
141
  )
141
142
  _query_url = APIHelper.clean_url _query_builder
142
143
 
143
144
  # Prepare headers.
144
145
  _headers = {
145
146
  'accept' => 'application/json',
146
- 'content-type' => 'application/json; charset=utf-8'
147
+ 'Content-Type' => 'application/json'
147
148
  }
148
149
 
149
150
  # Prepare and execute HttpRequest.
@@ -158,17 +159,18 @@ module Square
158
159
  # Return appropriate response type.
159
160
  decoded = APIHelper.json_deserialize(_response.raw_body)
160
161
  _errors = APIHelper.map_response(decoded, ['errors'])
161
- ApiResponse.new(_response, data: decoded, errors: _errors)
162
+ ApiResponse.new(
163
+ _response, data: decoded, errors: _errors
164
+ )
162
165
  end
163
166
 
164
167
  # Adds points to or subtracts points from a buyer's account.
165
168
  # Use this endpoint only when you need to manually adjust points. Otherwise,
166
169
  # in your application flow, you call
167
- # [AccumulateLoyaltyPoints](https://developer.squareup.com/docs/reference/sq
168
- # uare/loyalty-api/accumulate-loyalty-points)
170
+ # [AccumulateLoyaltyPoints]($e/Loyalty/AccumulateLoyaltyPoints)
169
171
  # to add points when a buyer pays for the purchase.
170
172
  # @param [String] account_id Required parameter: The ID of the [loyalty
171
- # account](#type-LoyaltyAccount) in which to adjust the points.
173
+ # account]($m/LoyaltyAccount) in which to adjust the points.
172
174
  # @param [AdjustLoyaltyPointsRequest] body Required parameter: An object
173
175
  # containing the fields to POST for the request. See the corresponding
174
176
  # object definition for field details.
@@ -180,14 +182,14 @@ module Square
180
182
  _query_builder << '/v2/loyalty/accounts/{account_id}/adjust'
181
183
  _query_builder = APIHelper.append_url_with_template_parameters(
182
184
  _query_builder,
183
- 'account_id' => account_id
185
+ 'account_id' => { 'value' => account_id, 'encode' => true }
184
186
  )
185
187
  _query_url = APIHelper.clean_url _query_builder
186
188
 
187
189
  # Prepare headers.
188
190
  _headers = {
189
191
  'accept' => 'application/json',
190
- 'content-type' => 'application/json; charset=utf-8'
192
+ 'Content-Type' => 'application/json'
191
193
  }
192
194
 
193
195
  # Prepare and execute HttpRequest.
@@ -202,7 +204,9 @@ module Square
202
204
  # Return appropriate response type.
203
205
  decoded = APIHelper.json_deserialize(_response.raw_body)
204
206
  _errors = APIHelper.map_response(decoded, ['errors'])
205
- ApiResponse.new(_response, data: decoded, errors: _errors)
207
+ ApiResponse.new(
208
+ _response, data: decoded, errors: _errors
209
+ )
206
210
  end
207
211
 
208
212
  # Searches for loyalty events.
@@ -212,10 +216,7 @@ module Square
212
216
  # (for example, points earned, points redeemed, and points expired) is
213
217
  # recorded in the ledger. Using this endpoint, you can search the ledger for
214
218
  # events.
215
- # For more information, see
216
- # [Loyalty
217
- # events](https://developer.squareup.com/docs/docs/loyalty-api/overview/#loy
218
- # alty-events).
219
+ # Search results are sorted by `created_at` in descending order.
219
220
  # @param [SearchLoyaltyEventsRequest] body Required parameter: An object
220
221
  # containing the fields to POST for the request. See the corresponding
221
222
  # object definition for field details.
@@ -229,7 +230,7 @@ module Square
229
230
  # Prepare headers.
230
231
  _headers = {
231
232
  'accept' => 'application/json',
232
- 'content-type' => 'application/json; charset=utf-8'
233
+ 'Content-Type' => 'application/json'
233
234
  }
234
235
 
235
236
  # Prepare and execute HttpRequest.
@@ -244,17 +245,22 @@ module Square
244
245
  # Return appropriate response type.
245
246
  decoded = APIHelper.json_deserialize(_response.raw_body)
246
247
  _errors = APIHelper.map_response(decoded, ['errors'])
247
- ApiResponse.new(_response, data: decoded, errors: _errors)
248
+ ApiResponse.new(
249
+ _response, data: decoded, errors: _errors
250
+ )
248
251
  end
249
252
 
250
253
  # Returns a list of loyalty programs in the seller's account.
251
- # Currently, a seller can only have one loyalty program. For more
252
- # information, see
253
- # [Loyalty
254
- # Overview](https://developer.squareup.com/docs/docs/loyalty/overview).
255
- # .
254
+ # Loyalty programs define how buyers can earn points and redeem points for
255
+ # rewards. Square sellers can have only one loyalty program, which is
256
+ # created and managed from the Seller Dashboard. For more information, see
257
+ # [Loyalty Program
258
+ # Overview](https://developer.squareup.com/docs/loyalty/overview).
259
+ # Replaced with [RetrieveLoyaltyProgram]($e/Loyalty/RetrieveLoyaltyProgram)
260
+ # when used with the keyword `main`.
256
261
  # @return [ListLoyaltyProgramsResponse Hash] response from the API call
257
262
  def list_loyalty_programs
263
+ warn 'Endpoint list_loyalty_programs in LoyaltyApi is deprecated'
258
264
  # Prepare query url.
259
265
  _query_builder = config.get_base_uri
260
266
  _query_builder << '/v2/loyalty/programs'
@@ -276,12 +282,56 @@ module Square
276
282
  # Return appropriate response type.
277
283
  decoded = APIHelper.json_deserialize(_response.raw_body)
278
284
  _errors = APIHelper.map_response(decoded, ['errors'])
279
- ApiResponse.new(_response, data: decoded, errors: _errors)
285
+ ApiResponse.new(
286
+ _response, data: decoded, errors: _errors
287
+ )
288
+ end
289
+
290
+ # Retrieves the loyalty program in a seller's account, specified by the
291
+ # program ID or the keyword `main`.
292
+ # Loyalty programs define how buyers can earn points and redeem points for
293
+ # rewards. Square sellers can have only one loyalty program, which is
294
+ # created and managed from the Seller Dashboard. For more information, see
295
+ # [Loyalty Program
296
+ # Overview](https://developer.squareup.com/docs/loyalty/overview).
297
+ # @param [String] program_id Required parameter: The ID of the loyalty
298
+ # program or the keyword `main`. Either value can be used to retrieve the
299
+ # single loyalty program that belongs to the seller.
300
+ # @return [RetrieveLoyaltyProgramResponse Hash] response from the API call
301
+ def retrieve_loyalty_program(program_id:)
302
+ # Prepare query url.
303
+ _query_builder = config.get_base_uri
304
+ _query_builder << '/v2/loyalty/programs/{program_id}'
305
+ _query_builder = APIHelper.append_url_with_template_parameters(
306
+ _query_builder,
307
+ 'program_id' => { 'value' => program_id, 'encode' => true }
308
+ )
309
+ _query_url = APIHelper.clean_url _query_builder
310
+
311
+ # Prepare headers.
312
+ _headers = {
313
+ 'accept' => 'application/json'
314
+ }
315
+
316
+ # Prepare and execute HttpRequest.
317
+ _request = config.http_client.get(
318
+ _query_url,
319
+ headers: _headers
320
+ )
321
+ OAuth2.apply(config, _request)
322
+ _response = execute_request(_request)
323
+
324
+ # Return appropriate response type.
325
+ decoded = APIHelper.json_deserialize(_response.raw_body)
326
+ _errors = APIHelper.map_response(decoded, ['errors'])
327
+ ApiResponse.new(
328
+ _response, data: decoded, errors: _errors
329
+ )
280
330
  end
281
331
 
282
332
  # Calculates the points a purchase earns.
283
- # - If you are using the Orders API to manage orders, you provide `order_id`
284
- # in the request. The
333
+ # - If you are using the Orders API to manage orders, you provide the
334
+ # `order_id` in the request. The
285
335
  # endpoint calculates the points by reading the order.
286
336
  # - If you are not using the Orders API to manage orders, you provide the
287
337
  # purchase amount in
@@ -289,8 +339,11 @@ module Square
289
339
  # An application might call this endpoint to show the points that a buyer
290
340
  # can earn with the
291
341
  # specific purchase.
342
+ # For spend-based and visit-based programs, the `tax_mode` setting of the
343
+ # accrual rule indicates how taxes should be treated for loyalty points
344
+ # accrual.
292
345
  # @param [String] program_id Required parameter: The [loyalty
293
- # program](#type-LoyaltyProgram) ID, which defines the rules for accruing
346
+ # program]($m/LoyaltyProgram) ID, which defines the rules for accruing
294
347
  # points.
295
348
  # @param [CalculateLoyaltyPointsRequest] body Required parameter: An object
296
349
  # containing the fields to POST for the request. See the corresponding
@@ -303,14 +356,14 @@ module Square
303
356
  _query_builder << '/v2/loyalty/programs/{program_id}/calculate'
304
357
  _query_builder = APIHelper.append_url_with_template_parameters(
305
358
  _query_builder,
306
- 'program_id' => program_id
359
+ 'program_id' => { 'value' => program_id, 'encode' => true }
307
360
  )
308
361
  _query_url = APIHelper.clean_url _query_builder
309
362
 
310
363
  # Prepare headers.
311
364
  _headers = {
312
365
  'accept' => 'application/json',
313
- 'content-type' => 'application/json; charset=utf-8'
366
+ 'Content-Type' => 'application/json'
314
367
  }
315
368
 
316
369
  # Prepare and execute HttpRequest.
@@ -325,7 +378,9 @@ module Square
325
378
  # Return appropriate response type.
326
379
  decoded = APIHelper.json_deserialize(_response.raw_body)
327
380
  _errors = APIHelper.map_response(decoded, ['errors'])
328
- ApiResponse.new(_response, data: decoded, errors: _errors)
381
+ ApiResponse.new(
382
+ _response, data: decoded, errors: _errors
383
+ )
329
384
  end
330
385
 
331
386
  # Creates a loyalty reward. In the process, the endpoint does following:
@@ -336,10 +391,6 @@ module Square
336
391
  # discount to the order.
337
392
  # After a reward is created, the points are locked and
338
393
  # not available for the buyer to redeem another reward.
339
- # For more information, see
340
- # [Loyalty
341
- # rewards](https://developer.squareup.com/docs/docs/loyalty-api/overview/#lo
342
- # yalty-overview-loyalty-rewards).
343
394
  # @param [CreateLoyaltyRewardRequest] body Required parameter: An object
344
395
  # containing the fields to POST for the request. See the corresponding
345
396
  # object definition for field details.
@@ -353,7 +404,7 @@ module Square
353
404
  # Prepare headers.
354
405
  _headers = {
355
406
  'accept' => 'application/json',
356
- 'content-type' => 'application/json; charset=utf-8'
407
+ 'Content-Type' => 'application/json'
357
408
  }
358
409
 
359
410
  # Prepare and execute HttpRequest.
@@ -368,19 +419,17 @@ module Square
368
419
  # Return appropriate response type.
369
420
  decoded = APIHelper.json_deserialize(_response.raw_body)
370
421
  _errors = APIHelper.map_response(decoded, ['errors'])
371
- ApiResponse.new(_response, data: decoded, errors: _errors)
422
+ ApiResponse.new(
423
+ _response, data: decoded, errors: _errors
424
+ )
372
425
  end
373
426
 
374
427
  # Searches for loyalty rewards in a loyalty account.
375
428
  # In the current implementation, the endpoint supports search by the reward
376
429
  # `status`.
377
430
  # If you know a reward ID, use the
378
- # [RetrieveLoyaltyReward](https://developer.squareup.com/docs/reference/squa
379
- # re/loyalty-api/retrieve-loyalty-reward) endpoint.
380
- # For more information about loyalty rewards, see
381
- # [Loyalty
382
- # Rewards](https://developer.squareup.com/docs/docs/loyalty-api/overview/#lo
383
- # yalty-rewards).
431
+ # [RetrieveLoyaltyReward]($e/Loyalty/RetrieveLoyaltyReward) endpoint.
432
+ # Search results are sorted by `updated_at` in descending order.
384
433
  # @param [SearchLoyaltyRewardsRequest] body Required parameter: An object
385
434
  # containing the fields to POST for the request. See the corresponding
386
435
  # object definition for field details.
@@ -394,7 +443,7 @@ module Square
394
443
  # Prepare headers.
395
444
  _headers = {
396
445
  'accept' => 'application/json',
397
- 'content-type' => 'application/json; charset=utf-8'
446
+ 'Content-Type' => 'application/json'
398
447
  }
399
448
 
400
449
  # Prepare and execute HttpRequest.
@@ -409,24 +458,20 @@ module Square
409
458
  # Return appropriate response type.
410
459
  decoded = APIHelper.json_deserialize(_response.raw_body)
411
460
  _errors = APIHelper.map_response(decoded, ['errors'])
412
- ApiResponse.new(_response, data: decoded, errors: _errors)
461
+ ApiResponse.new(
462
+ _response, data: decoded, errors: _errors
463
+ )
413
464
  end
414
465
 
415
466
  # Deletes a loyalty reward by doing the following:
416
467
  # - Returns the loyalty points back to the loyalty account.
417
468
  # - If an order ID was specified when the reward was created
418
- # (see
419
- # [CreateLoyaltyReward](https://developer.squareup.com/docs/reference/square
420
- # /loyalty-api/create-loyalty-reward)),
469
+ # (see [CreateLoyaltyReward]($e/Loyalty/CreateLoyaltyReward)),
421
470
  # it updates the order by removing the reward and related
422
471
  # discounts.
423
472
  # You cannot delete a reward that has reached the terminal state (REDEEMED).
424
- # For more information, see
425
- # [Loyalty
426
- # rewards](https://developer.squareup.com/docs/docs/loyalty-api/overview/#lo
427
- # yalty-overview-loyalty-rewards).
428
473
  # @param [String] reward_id Required parameter: The ID of the [loyalty
429
- # reward](#type-LoyaltyReward) to delete.
474
+ # reward]($m/LoyaltyReward) to delete.
430
475
  # @return [DeleteLoyaltyRewardResponse Hash] response from the API call
431
476
  def delete_loyalty_reward(reward_id:)
432
477
  # Prepare query url.
@@ -434,7 +479,7 @@ module Square
434
479
  _query_builder << '/v2/loyalty/rewards/{reward_id}'
435
480
  _query_builder = APIHelper.append_url_with_template_parameters(
436
481
  _query_builder,
437
- 'reward_id' => reward_id
482
+ 'reward_id' => { 'value' => reward_id, 'encode' => true }
438
483
  )
439
484
  _query_url = APIHelper.clean_url _query_builder
440
485
 
@@ -454,12 +499,14 @@ module Square
454
499
  # Return appropriate response type.
455
500
  decoded = APIHelper.json_deserialize(_response.raw_body)
456
501
  _errors = APIHelper.map_response(decoded, ['errors'])
457
- ApiResponse.new(_response, data: decoded, errors: _errors)
502
+ ApiResponse.new(
503
+ _response, data: decoded, errors: _errors
504
+ )
458
505
  end
459
506
 
460
507
  # Retrieves a loyalty reward.
461
508
  # @param [String] reward_id Required parameter: The ID of the [loyalty
462
- # reward](#type-LoyaltyReward) to retrieve.
509
+ # reward]($m/LoyaltyReward) to retrieve.
463
510
  # @return [RetrieveLoyaltyRewardResponse Hash] response from the API call
464
511
  def retrieve_loyalty_reward(reward_id:)
465
512
  # Prepare query url.
@@ -467,7 +514,7 @@ module Square
467
514
  _query_builder << '/v2/loyalty/rewards/{reward_id}'
468
515
  _query_builder = APIHelper.append_url_with_template_parameters(
469
516
  _query_builder,
470
- 'reward_id' => reward_id
517
+ 'reward_id' => { 'value' => reward_id, 'encode' => true }
471
518
  )
472
519
  _query_url = APIHelper.clean_url _query_builder
473
520
 
@@ -487,23 +534,21 @@ module Square
487
534
  # Return appropriate response type.
488
535
  decoded = APIHelper.json_deserialize(_response.raw_body)
489
536
  _errors = APIHelper.map_response(decoded, ['errors'])
490
- ApiResponse.new(_response, data: decoded, errors: _errors)
537
+ ApiResponse.new(
538
+ _response, data: decoded, errors: _errors
539
+ )
491
540
  end
492
541
 
493
542
  # Redeems a loyalty reward.
494
- # The endpoint sets the reward to the terminal state (`REDEEMED`).
543
+ # The endpoint sets the reward to the `REDEEMED` terminal state.
495
544
  # If you are using your own order processing system (not using the
496
545
  # Orders API), you call this endpoint after the buyer paid for the
497
546
  # purchase.
498
547
  # After the reward reaches the terminal state, it cannot be deleted.
499
548
  # In other words, points used for the reward cannot be returned
500
549
  # to the account.
501
- # For more information, see
502
- # [Loyalty
503
- # rewards](https://developer.squareup.com/docs/docs/loyalty-api/overview/#lo
504
- # yalty-overview-loyalty-rewards).
505
550
  # @param [String] reward_id Required parameter: The ID of the [loyalty
506
- # reward](#type-LoyaltyReward) to redeem.
551
+ # reward]($m/LoyaltyReward) to redeem.
507
552
  # @param [RedeemLoyaltyRewardRequest] body Required parameter: An object
508
553
  # containing the fields to POST for the request. See the corresponding
509
554
  # object definition for field details.
@@ -515,14 +560,14 @@ module Square
515
560
  _query_builder << '/v2/loyalty/rewards/{reward_id}/redeem'
516
561
  _query_builder = APIHelper.append_url_with_template_parameters(
517
562
  _query_builder,
518
- 'reward_id' => reward_id
563
+ 'reward_id' => { 'value' => reward_id, 'encode' => true }
519
564
  )
520
565
  _query_url = APIHelper.clean_url _query_builder
521
566
 
522
567
  # Prepare headers.
523
568
  _headers = {
524
569
  'accept' => 'application/json',
525
- 'content-type' => 'application/json; charset=utf-8'
570
+ 'Content-Type' => 'application/json'
526
571
  }
527
572
 
528
573
  # Prepare and execute HttpRequest.
@@ -537,7 +582,9 @@ module Square
537
582
  # Return appropriate response type.
538
583
  decoded = APIHelper.json_deserialize(_response.raw_body)
539
584
  _errors = APIHelper.map_response(decoded, ['errors'])
540
- ApiResponse.new(_response, data: decoded, errors: _errors)
585
+ ApiResponse.new(
586
+ _response, data: decoded, errors: _errors
587
+ )
541
588
  end
542
589
  end
543
590
  end
@@ -12,7 +12,7 @@ module Square
12
12
  # information or specify an OAuth token
13
13
  # to get the information for the merchant that granted you access.
14
14
  # If you know the merchant ID, you can also use the
15
- # [RetrieveMerchant](#endpoint-merchants-retrievemerchant)
15
+ # [RetrieveMerchant]($e/Merchants/RetrieveMerchant)
16
16
  # endpoint to get the merchant information.
17
17
  # @param [Integer] cursor Optional parameter: The cursor generated by the
18
18
  # previous response.
@@ -43,7 +43,9 @@ module Square
43
43
  # Return appropriate response type.
44
44
  decoded = APIHelper.json_deserialize(_response.raw_body)
45
45
  _errors = APIHelper.map_response(decoded, ['errors'])
46
- ApiResponse.new(_response, data: decoded, errors: _errors)
46
+ ApiResponse.new(
47
+ _response, data: decoded, errors: _errors
48
+ )
47
49
  end
48
50
 
49
51
  # Retrieve a `Merchant` object for the given `merchant_id`.
@@ -57,7 +59,7 @@ module Square
57
59
  _query_builder << '/v2/merchants/{merchant_id}'
58
60
  _query_builder = APIHelper.append_url_with_template_parameters(
59
61
  _query_builder,
60
- 'merchant_id' => merchant_id
62
+ 'merchant_id' => { 'value' => merchant_id, 'encode' => true }
61
63
  )
62
64
  _query_url = APIHelper.clean_url _query_builder
63
65
 
@@ -77,7 +79,9 @@ module Square
77
79
  # Return appropriate response type.
78
80
  decoded = APIHelper.json_deserialize(_response.raw_body)
79
81
  _errors = APIHelper.map_response(decoded, ['errors'])
80
- ApiResponse.new(_response, data: decoded, errors: _errors)
82
+ ApiResponse.new(
83
+ _response, data: decoded, errors: _errors
84
+ )
81
85
  end
82
86
  end
83
87
  end
@@ -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 __60 minutes__ after being
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
  # ```
@@ -16,8 +16,8 @@ module Square
16
16
  # ```
17
17
  # Replace `ACCESS_TOKEN` with a
18
18
  # [valid production authorization
19
- # credential](https://developer.squareup.com/docs/docs/build-basics/access-t
20
- # okens).
19
+ # credential](https://developer.squareup.com/docs/build-basics/access-tokens
20
+ # ).
21
21
  # @param [CreateMobileAuthorizationCodeRequest] body Required parameter: An
22
22
  # object containing the fields to POST for the request. See the
23
23
  # corresponding object definition for field details.
@@ -31,7 +31,7 @@ module Square
31
31
  # Prepare headers.
32
32
  _headers = {
33
33
  'accept' => 'application/json',
34
- 'content-type' => 'application/json; charset=utf-8'
34
+ 'Content-Type' => 'application/json'
35
35
  }
36
36
 
37
37
  # Prepare and execute HttpRequest.
@@ -46,7 +46,9 @@ module Square
46
46
  # Return appropriate response type.
47
47
  decoded = APIHelper.json_deserialize(_response.raw_body)
48
48
  _errors = APIHelper.map_response(decoded, ['errors'])
49
- ApiResponse.new(_response, data: decoded, errors: _errors)
49
+ ApiResponse.new(
50
+ _response, data: decoded, errors: _errors
51
+ )
50
52
  end
51
53
  end
52
54
  end