square.rb 6.0.0.20200625 → 6.5.0.20201028

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +37 -30
  3. data/lib/square.rb +61 -60
  4. data/lib/square/api/apple_pay_api.rb +3 -1
  5. data/lib/square/api/bank_accounts_api.rb +12 -15
  6. data/lib/square/api/base_api.rb +2 -2
  7. data/lib/square/api/cash_drawers_api.rb +11 -5
  8. data/lib/square/api/catalog_api.rb +119 -49
  9. data/lib/square/api/checkout_api.rb +4 -2
  10. data/lib/square/api/customer_groups_api.rb +18 -8
  11. data/lib/square/api/customer_segments_api.rb +7 -3
  12. data/lib/square/api/customers_api.rb +47 -27
  13. data/lib/square/api/devices_api.rb +17 -6
  14. data/lib/square/api/disputes_api.rb +39 -34
  15. data/lib/square/api/employees_api.rb +10 -5
  16. data/lib/square/api/inventory_api.rb +30 -15
  17. data/lib/square/api/invoices_api.rb +359 -0
  18. data/lib/square/api/labor_api.rb +131 -22
  19. data/lib/square/api/locations_api.rb +20 -12
  20. data/lib/square/api/loyalty_api.rb +59 -65
  21. data/lib/square/api/merchants_api.rb +9 -4
  22. data/lib/square/api/mobile_authorization_api.rb +3 -1
  23. data/lib/square/api/o_auth_api.rb +10 -4
  24. data/lib/square/api/orders_api.rb +111 -90
  25. data/lib/square/api/payments_api.rb +75 -65
  26. data/lib/square/api/refunds_api.rb +21 -11
  27. data/lib/square/api/subscriptions_api.rb +263 -0
  28. data/lib/square/api/team_api.rb +32 -16
  29. data/lib/square/api/terminal_api.rb +156 -7
  30. data/lib/square/api/transactions_api.rb +32 -18
  31. data/lib/square/api/v1_employees_api.rb +59 -27
  32. data/lib/square/api/v1_items_api.rb +195 -115
  33. data/lib/square/api/v1_locations_api.rb +6 -2
  34. data/lib/square/api/v1_transactions_api.rb +49 -27
  35. data/lib/square/api_helper.rb +14 -9
  36. data/lib/square/client.rb +23 -16
  37. data/lib/square/configuration.rb +12 -4
  38. data/lib/square/http/api_response.rb +2 -0
  39. data/lib/square/http/faraday_client.rb +1 -0
  40. data/spec/user_journey_spec.rb +2 -5
  41. data/test/api/api_test_base.rb +1 -6
  42. data/test/api/test_catalog_api.rb +1 -4
  43. data/test/api/test_customers_api.rb +1 -4
  44. data/test/api/test_employees_api.rb +1 -4
  45. data/test/api/test_labor_api.rb +2 -6
  46. data/test/api/test_locations_api.rb +22 -33
  47. data/test/api/test_merchants_api.rb +1 -4
  48. data/test/api/test_payments_api.rb +3 -6
  49. data/test/api/test_refunds_api.rb +3 -6
  50. data/test/http_response_catcher.rb +0 -5
  51. data/test/test_helper.rb +0 -5
  52. metadata +33 -14
  53. data/lib/square/api/reporting_api.rb +0 -138
@@ -44,7 +44,9 @@ module Square
44
44
  # Return appropriate response type.
45
45
  decoded = APIHelper.json_deserialize(_response.raw_body)
46
46
  _errors = APIHelper.map_response(decoded, ['errors'])
47
- ApiResponse.new(_response, data: decoded, errors: _errors)
47
+ ApiResponse.new(
48
+ _response, data: decoded, errors: _errors
49
+ )
48
50
  end
49
51
 
50
52
  # Creates a new `BreakType`.
@@ -88,7 +90,9 @@ module Square
88
90
  # Return appropriate response type.
89
91
  decoded = APIHelper.json_deserialize(_response.raw_body)
90
92
  _errors = APIHelper.map_response(decoded, ['errors'])
91
- ApiResponse.new(_response, data: decoded, errors: _errors)
93
+ ApiResponse.new(
94
+ _response, data: decoded, errors: _errors
95
+ )
92
96
  end
93
97
 
94
98
  # Deletes an existing `BreakType`.
@@ -102,7 +106,7 @@ module Square
102
106
  _query_builder << '/v2/labor/break-types/{id}'
103
107
  _query_builder = APIHelper.append_url_with_template_parameters(
104
108
  _query_builder,
105
- 'id' => id
109
+ 'id' => { 'value' => id, 'encode' => true }
106
110
  )
107
111
  _query_url = APIHelper.clean_url _query_builder
108
112
 
@@ -122,7 +126,9 @@ module Square
122
126
  # Return appropriate response type.
123
127
  decoded = APIHelper.json_deserialize(_response.raw_body)
124
128
  _errors = APIHelper.map_response(decoded, ['errors'])
125
- ApiResponse.new(_response, data: decoded, errors: _errors)
129
+ ApiResponse.new(
130
+ _response, data: decoded, errors: _errors
131
+ )
126
132
  end
127
133
 
128
134
  # Returns a single `BreakType` specified by id.
@@ -135,7 +141,7 @@ module Square
135
141
  _query_builder << '/v2/labor/break-types/{id}'
136
142
  _query_builder = APIHelper.append_url_with_template_parameters(
137
143
  _query_builder,
138
- 'id' => id
144
+ 'id' => { 'value' => id, 'encode' => true }
139
145
  )
140
146
  _query_url = APIHelper.clean_url _query_builder
141
147
 
@@ -155,7 +161,9 @@ module Square
155
161
  # Return appropriate response type.
156
162
  decoded = APIHelper.json_deserialize(_response.raw_body)
157
163
  _errors = APIHelper.map_response(decoded, ['errors'])
158
- ApiResponse.new(_response, data: decoded, errors: _errors)
164
+ ApiResponse.new(
165
+ _response, data: decoded, errors: _errors
166
+ )
159
167
  end
160
168
 
161
169
  # Updates an existing `BreakType`.
@@ -172,7 +180,7 @@ module Square
172
180
  _query_builder << '/v2/labor/break-types/{id}'
173
181
  _query_builder = APIHelper.append_url_with_template_parameters(
174
182
  _query_builder,
175
- 'id' => id
183
+ 'id' => { 'value' => id, 'encode' => true }
176
184
  )
177
185
  _query_url = APIHelper.clean_url _query_builder
178
186
 
@@ -194,7 +202,9 @@ module Square
194
202
  # Return appropriate response type.
195
203
  decoded = APIHelper.json_deserialize(_response.raw_body)
196
204
  _errors = APIHelper.map_response(decoded, ['errors'])
197
- ApiResponse.new(_response, data: decoded, errors: _errors)
205
+ ApiResponse.new(
206
+ _response, data: decoded, errors: _errors
207
+ )
198
208
  end
199
209
 
200
210
  # Returns a paginated list of `EmployeeWage` instances for a business.
@@ -209,6 +219,7 @@ module Square
209
219
  def list_employee_wages(employee_id: nil,
210
220
  limit: nil,
211
221
  cursor: nil)
222
+ warn 'Endpoint list_employee_wages in LaborApi is deprecated'
212
223
  # Prepare query url.
213
224
  _query_builder = config.get_base_uri
214
225
  _query_builder << '/v2/labor/employee-wages'
@@ -236,7 +247,9 @@ module Square
236
247
  # Return appropriate response type.
237
248
  decoded = APIHelper.json_deserialize(_response.raw_body)
238
249
  _errors = APIHelper.map_response(decoded, ['errors'])
239
- ApiResponse.new(_response, data: decoded, errors: _errors)
250
+ ApiResponse.new(
251
+ _response, data: decoded, errors: _errors
252
+ )
240
253
  end
241
254
 
242
255
  # Returns a single `EmployeeWage` specified by id.
@@ -244,12 +257,13 @@ module Square
244
257
  # retrieved.
245
258
  # @return [GetEmployeeWageResponse Hash] response from the API call
246
259
  def get_employee_wage(id:)
260
+ warn 'Endpoint get_employee_wage in LaborApi is deprecated'
247
261
  # Prepare query url.
248
262
  _query_builder = config.get_base_uri
249
263
  _query_builder << '/v2/labor/employee-wages/{id}'
250
264
  _query_builder = APIHelper.append_url_with_template_parameters(
251
265
  _query_builder,
252
- 'id' => id
266
+ 'id' => { 'value' => id, 'encode' => true }
253
267
  )
254
268
  _query_url = APIHelper.clean_url _query_builder
255
269
 
@@ -269,7 +283,9 @@ module Square
269
283
  # Return appropriate response type.
270
284
  decoded = APIHelper.json_deserialize(_response.raw_body)
271
285
  _errors = APIHelper.map_response(decoded, ['errors'])
272
- ApiResponse.new(_response, data: decoded, errors: _errors)
286
+ ApiResponse.new(
287
+ _response, data: decoded, errors: _errors
288
+ )
273
289
  end
274
290
 
275
291
  # Creates a new `Shift`.
@@ -317,7 +333,9 @@ module Square
317
333
  # Return appropriate response type.
318
334
  decoded = APIHelper.json_deserialize(_response.raw_body)
319
335
  _errors = APIHelper.map_response(decoded, ['errors'])
320
- ApiResponse.new(_response, data: decoded, errors: _errors)
336
+ ApiResponse.new(
337
+ _response, data: decoded, errors: _errors
338
+ )
321
339
  end
322
340
 
323
341
  # Returns a paginated list of `Shift` records for a business.
@@ -361,7 +379,9 @@ module Square
361
379
  # Return appropriate response type.
362
380
  decoded = APIHelper.json_deserialize(_response.raw_body)
363
381
  _errors = APIHelper.map_response(decoded, ['errors'])
364
- ApiResponse.new(_response, data: decoded, errors: _errors)
382
+ ApiResponse.new(
383
+ _response, data: decoded, errors: _errors
384
+ )
365
385
  end
366
386
 
367
387
  # Deletes a `Shift`.
@@ -374,7 +394,7 @@ module Square
374
394
  _query_builder << '/v2/labor/shifts/{id}'
375
395
  _query_builder = APIHelper.append_url_with_template_parameters(
376
396
  _query_builder,
377
- 'id' => id
397
+ 'id' => { 'value' => id, 'encode' => true }
378
398
  )
379
399
  _query_url = APIHelper.clean_url _query_builder
380
400
 
@@ -394,7 +414,9 @@ module Square
394
414
  # Return appropriate response type.
395
415
  decoded = APIHelper.json_deserialize(_response.raw_body)
396
416
  _errors = APIHelper.map_response(decoded, ['errors'])
397
- ApiResponse.new(_response, data: decoded, errors: _errors)
417
+ ApiResponse.new(
418
+ _response, data: decoded, errors: _errors
419
+ )
398
420
  end
399
421
 
400
422
  # Returns a single `Shift` specified by id.
@@ -407,7 +429,7 @@ module Square
407
429
  _query_builder << '/v2/labor/shifts/{id}'
408
430
  _query_builder = APIHelper.append_url_with_template_parameters(
409
431
  _query_builder,
410
- 'id' => id
432
+ 'id' => { 'value' => id, 'encode' => true }
411
433
  )
412
434
  _query_url = APIHelper.clean_url _query_builder
413
435
 
@@ -427,7 +449,9 @@ module Square
427
449
  # Return appropriate response type.
428
450
  decoded = APIHelper.json_deserialize(_response.raw_body)
429
451
  _errors = APIHelper.map_response(decoded, ['errors'])
430
- ApiResponse.new(_response, data: decoded, errors: _errors)
452
+ ApiResponse.new(
453
+ _response, data: decoded, errors: _errors
454
+ )
431
455
  end
432
456
 
433
457
  # Updates an existing `Shift`.
@@ -449,7 +473,7 @@ module Square
449
473
  _query_builder << '/v2/labor/shifts/{id}'
450
474
  _query_builder = APIHelper.append_url_with_template_parameters(
451
475
  _query_builder,
452
- 'id' => id
476
+ 'id' => { 'value' => id, 'encode' => true }
453
477
  )
454
478
  _query_url = APIHelper.clean_url _query_builder
455
479
 
@@ -471,7 +495,88 @@ module Square
471
495
  # Return appropriate response type.
472
496
  decoded = APIHelper.json_deserialize(_response.raw_body)
473
497
  _errors = APIHelper.map_response(decoded, ['errors'])
474
- ApiResponse.new(_response, data: decoded, errors: _errors)
498
+ ApiResponse.new(
499
+ _response, data: decoded, errors: _errors
500
+ )
501
+ end
502
+
503
+ # Returns a paginated list of `TeamMemberWage` instances for a business.
504
+ # @param [String] team_member_id Optional parameter: Filter wages returned
505
+ # to only those that are associated with the specified team member.
506
+ # @param [Integer] limit Optional parameter: Maximum number of Team Member
507
+ # Wages to return per page. Can range between 1 and 200. The default is the
508
+ # maximum at 200.
509
+ # @param [String] cursor Optional parameter: Pointer to the next page of
510
+ # Employee Wage results to fetch.
511
+ # @return [ListTeamMemberWagesResponse Hash] response from the API call
512
+ def list_team_member_wages(team_member_id: nil,
513
+ limit: nil,
514
+ cursor: nil)
515
+ # Prepare query url.
516
+ _query_builder = config.get_base_uri
517
+ _query_builder << '/v2/labor/team-member-wages'
518
+ _query_builder = APIHelper.append_url_with_query_parameters(
519
+ _query_builder,
520
+ 'team_member_id' => team_member_id,
521
+ 'limit' => limit,
522
+ 'cursor' => cursor
523
+ )
524
+ _query_url = APIHelper.clean_url _query_builder
525
+
526
+ # Prepare headers.
527
+ _headers = {
528
+ 'accept' => 'application/json'
529
+ }
530
+
531
+ # Prepare and execute HttpRequest.
532
+ _request = config.http_client.get(
533
+ _query_url,
534
+ headers: _headers
535
+ )
536
+ OAuth2.apply(config, _request)
537
+ _response = execute_request(_request)
538
+
539
+ # Return appropriate response type.
540
+ decoded = APIHelper.json_deserialize(_response.raw_body)
541
+ _errors = APIHelper.map_response(decoded, ['errors'])
542
+ ApiResponse.new(
543
+ _response, data: decoded, errors: _errors
544
+ )
545
+ end
546
+
547
+ # Returns a single `TeamMemberWage` specified by id.
548
+ # @param [String] id Required parameter: UUID for the `TeamMemberWage` being
549
+ # retrieved.
550
+ # @return [GetTeamMemberWageResponse Hash] response from the API call
551
+ def get_team_member_wage(id:)
552
+ # Prepare query url.
553
+ _query_builder = config.get_base_uri
554
+ _query_builder << '/v2/labor/team-member-wages/{id}'
555
+ _query_builder = APIHelper.append_url_with_template_parameters(
556
+ _query_builder,
557
+ 'id' => { 'value' => id, 'encode' => true }
558
+ )
559
+ _query_url = APIHelper.clean_url _query_builder
560
+
561
+ # Prepare headers.
562
+ _headers = {
563
+ 'accept' => 'application/json'
564
+ }
565
+
566
+ # Prepare and execute HttpRequest.
567
+ _request = config.http_client.get(
568
+ _query_url,
569
+ headers: _headers
570
+ )
571
+ OAuth2.apply(config, _request)
572
+ _response = execute_request(_request)
573
+
574
+ # Return appropriate response type.
575
+ decoded = APIHelper.json_deserialize(_response.raw_body)
576
+ _errors = APIHelper.map_response(decoded, ['errors'])
577
+ ApiResponse.new(
578
+ _response, data: decoded, errors: _errors
579
+ )
475
580
  end
476
581
 
477
582
  # Returns a list of `WorkweekConfig` instances for a business.
@@ -508,7 +613,9 @@ module Square
508
613
  # Return appropriate response type.
509
614
  decoded = APIHelper.json_deserialize(_response.raw_body)
510
615
  _errors = APIHelper.map_response(decoded, ['errors'])
511
- ApiResponse.new(_response, data: decoded, errors: _errors)
616
+ ApiResponse.new(
617
+ _response, data: decoded, errors: _errors
618
+ )
512
619
  end
513
620
 
514
621
  # Updates a `WorkweekConfig`.
@@ -525,7 +632,7 @@ module Square
525
632
  _query_builder << '/v2/labor/workweek-configs/{id}'
526
633
  _query_builder = APIHelper.append_url_with_template_parameters(
527
634
  _query_builder,
528
- 'id' => id
635
+ 'id' => { 'value' => id, 'encode' => true }
529
636
  )
530
637
  _query_url = APIHelper.clean_url _query_builder
531
638
 
@@ -547,7 +654,9 @@ module Square
547
654
  # Return appropriate response type.
548
655
  decoded = APIHelper.json_deserialize(_response.raw_body)
549
656
  _errors = APIHelper.map_response(decoded, ['errors'])
550
- ApiResponse.new(_response, data: decoded, errors: _errors)
657
+ ApiResponse.new(
658
+ _response, data: decoded, errors: _errors
659
+ )
551
660
  end
552
661
  end
553
662
  end
@@ -6,8 +6,7 @@ module Square
6
6
  end
7
7
 
8
8
  # Provides information of all locations of a business.
9
- # Most other Connect API endpoints have a required `location_id` path
10
- # parameter.
9
+ # Many Square API endpoints require a `location_id` parameter.
11
10
  # The `id` field of the [`Location`](#type-location) objects returned by
12
11
  # this
13
12
  # endpoint correspond to that `location_id` parameter.
@@ -34,12 +33,12 @@ module Square
34
33
  # Return appropriate response type.
35
34
  decoded = APIHelper.json_deserialize(_response.raw_body)
36
35
  _errors = APIHelper.map_response(decoded, ['errors'])
37
- ApiResponse.new(_response, data: decoded, errors: _errors)
36
+ ApiResponse.new(
37
+ _response, data: decoded, errors: _errors
38
+ )
38
39
  end
39
40
 
40
41
  # Creates a location.
41
- # For more information about locations, see [Locations API
42
- # Overview](https://developer.squareup.com/docs/locations-api).
43
42
  # @param [CreateLocationRequest] body Required parameter: An object
44
43
  # containing the fields to POST for the request. See the corresponding
45
44
  # object definition for field details.
@@ -68,12 +67,17 @@ module Square
68
67
  # Return appropriate response type.
69
68
  decoded = APIHelper.json_deserialize(_response.raw_body)
70
69
  _errors = APIHelper.map_response(decoded, ['errors'])
71
- ApiResponse.new(_response, data: decoded, errors: _errors)
70
+ ApiResponse.new(
71
+ _response, data: decoded, errors: _errors
72
+ )
72
73
  end
73
74
 
74
- # Retrieves details of a location.
75
+ # Retrieves details of a location. You can specify "main"
76
+ # as the location ID to retrieve details of the
77
+ # main location.
75
78
  # @param [String] location_id Required parameter: The ID of the location to
76
- # retrieve.
79
+ # retrieve. If you specify the string "main", then the endpoint returns the
80
+ # main location.
77
81
  # @return [RetrieveLocationResponse Hash] response from the API call
78
82
  def retrieve_location(location_id:)
79
83
  # Prepare query url.
@@ -81,7 +85,7 @@ module Square
81
85
  _query_builder << '/v2/locations/{location_id}'
82
86
  _query_builder = APIHelper.append_url_with_template_parameters(
83
87
  _query_builder,
84
- 'location_id' => location_id
88
+ 'location_id' => { 'value' => location_id, 'encode' => true }
85
89
  )
86
90
  _query_url = APIHelper.clean_url _query_builder
87
91
 
@@ -101,7 +105,9 @@ module Square
101
105
  # Return appropriate response type.
102
106
  decoded = APIHelper.json_deserialize(_response.raw_body)
103
107
  _errors = APIHelper.map_response(decoded, ['errors'])
104
- ApiResponse.new(_response, data: decoded, errors: _errors)
108
+ ApiResponse.new(
109
+ _response, data: decoded, errors: _errors
110
+ )
105
111
  end
106
112
 
107
113
  # Updates a location.
@@ -118,7 +124,7 @@ module Square
118
124
  _query_builder << '/v2/locations/{location_id}'
119
125
  _query_builder = APIHelper.append_url_with_template_parameters(
120
126
  _query_builder,
121
- 'location_id' => location_id
127
+ 'location_id' => { 'value' => location_id, 'encode' => true }
122
128
  )
123
129
  _query_url = APIHelper.clean_url _query_builder
124
130
 
@@ -140,7 +146,9 @@ module Square
140
146
  # Return appropriate response type.
141
147
  decoded = APIHelper.json_deserialize(_response.raw_body)
142
148
  _errors = APIHelper.map_response(decoded, ['errors'])
143
- ApiResponse.new(_response, data: decoded, errors: _errors)
149
+ ApiResponse.new(
150
+ _response, data: decoded, errors: _errors
151
+ )
144
152
  end
145
153
  end
146
154
  end
@@ -5,10 +5,7 @@ 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.
12
9
  # @param [CreateLoyaltyAccountRequest] body Required parameter: An object
13
10
  # containing the fields to POST for the request. See the corresponding
14
11
  # object definition for field details.
@@ -37,13 +34,16 @@ module Square
37
34
  # Return appropriate response type.
38
35
  decoded = APIHelper.json_deserialize(_response.raw_body)
39
36
  _errors = APIHelper.map_response(decoded, ['errors'])
40
- ApiResponse.new(_response, data: decoded, errors: _errors)
37
+ ApiResponse.new(
38
+ _response, data: decoded, errors: _errors
39
+ )
41
40
  end
42
41
 
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.
42
+ # Searches for loyalty accounts in a loyalty program.
43
+ # You can search for a loyalty account using the phone number or customer ID
44
+ # associated with the account. To return all loyalty accounts, specify an
45
+ # empty `query` object or omit it entirely.
46
+ # Search results are sorted by `created_at` in ascending order.
47
47
  # @param [SearchLoyaltyAccountsRequest] body Required parameter: An object
48
48
  # containing the fields to POST for the request. See the corresponding
49
49
  # object definition for field details.
@@ -72,7 +72,9 @@ module Square
72
72
  # Return appropriate response type.
73
73
  decoded = APIHelper.json_deserialize(_response.raw_body)
74
74
  _errors = APIHelper.map_response(decoded, ['errors'])
75
- ApiResponse.new(_response, data: decoded, errors: _errors)
75
+ ApiResponse.new(
76
+ _response, data: decoded, errors: _errors
77
+ )
76
78
  end
77
79
 
78
80
  # Retrieves a loyalty account.
@@ -85,7 +87,7 @@ module Square
85
87
  _query_builder << '/v2/loyalty/accounts/{account_id}'
86
88
  _query_builder = APIHelper.append_url_with_template_parameters(
87
89
  _query_builder,
88
- 'account_id' => account_id
90
+ 'account_id' => { 'value' => account_id, 'encode' => true }
89
91
  )
90
92
  _query_url = APIHelper.clean_url _query_builder
91
93
 
@@ -105,7 +107,9 @@ module Square
105
107
  # Return appropriate response type.
106
108
  decoded = APIHelper.json_deserialize(_response.raw_body)
107
109
  _errors = APIHelper.map_response(decoded, ['errors'])
108
- ApiResponse.new(_response, data: decoded, errors: _errors)
110
+ ApiResponse.new(
111
+ _response, data: decoded, errors: _errors
112
+ )
109
113
  end
110
114
 
111
115
  # Adds points to a loyalty account.
@@ -116,13 +120,11 @@ module Square
116
120
  # - If you are not using the Orders API to manage orders,
117
121
  # you first perform a client-side computation to compute the points.
118
122
  # For spend-based and visit-based programs, you can call
119
- # `CalculateLoyaltyPoints` to compute the points. For more information,
123
+ # [CalculateLoyaltyPoints](#endpoint-Loyalty-CalculateLoyaltyPoints) to
124
+ # compute the points. For more information,
120
125
  # see [Loyalty Program
121
126
  # Overview](https://developer.squareup.com/docs/docs/loyalty/overview).
122
127
  # 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).
126
128
  # @param [String] account_id Required parameter: The [loyalty
127
129
  # account](#type-LoyaltyAccount) ID to which to add the points.
128
130
  # @param [AccumulateLoyaltyPointsRequest] body Required parameter: An object
@@ -136,7 +138,7 @@ module Square
136
138
  _query_builder << '/v2/loyalty/accounts/{account_id}/accumulate'
137
139
  _query_builder = APIHelper.append_url_with_template_parameters(
138
140
  _query_builder,
139
- 'account_id' => account_id
141
+ 'account_id' => { 'value' => account_id, 'encode' => true }
140
142
  )
141
143
  _query_url = APIHelper.clean_url _query_builder
142
144
 
@@ -158,14 +160,15 @@ module Square
158
160
  # Return appropriate response type.
159
161
  decoded = APIHelper.json_deserialize(_response.raw_body)
160
162
  _errors = APIHelper.map_response(decoded, ['errors'])
161
- ApiResponse.new(_response, data: decoded, errors: _errors)
163
+ ApiResponse.new(
164
+ _response, data: decoded, errors: _errors
165
+ )
162
166
  end
163
167
 
164
168
  # Adds points to or subtracts points from a buyer's account.
165
169
  # Use this endpoint only when you need to manually adjust points. Otherwise,
166
170
  # in your application flow, you call
167
- # [AccumulateLoyaltyPoints](https://developer.squareup.com/docs/reference/sq
168
- # uare/loyalty-api/accumulate-loyalty-points)
171
+ # [AccumulateLoyaltyPoints](#endpoint-Loyalty-AccumulateLoyaltyPoints)
169
172
  # to add points when a buyer pays for the purchase.
170
173
  # @param [String] account_id Required parameter: The ID of the [loyalty
171
174
  # account](#type-LoyaltyAccount) in which to adjust the points.
@@ -180,7 +183,7 @@ module Square
180
183
  _query_builder << '/v2/loyalty/accounts/{account_id}/adjust'
181
184
  _query_builder = APIHelper.append_url_with_template_parameters(
182
185
  _query_builder,
183
- 'account_id' => account_id
186
+ 'account_id' => { 'value' => account_id, 'encode' => true }
184
187
  )
185
188
  _query_url = APIHelper.clean_url _query_builder
186
189
 
@@ -202,7 +205,9 @@ module Square
202
205
  # Return appropriate response type.
203
206
  decoded = APIHelper.json_deserialize(_response.raw_body)
204
207
  _errors = APIHelper.map_response(decoded, ['errors'])
205
- ApiResponse.new(_response, data: decoded, errors: _errors)
208
+ ApiResponse.new(
209
+ _response, data: decoded, errors: _errors
210
+ )
206
211
  end
207
212
 
208
213
  # Searches for loyalty events.
@@ -212,10 +217,6 @@ module Square
212
217
  # (for example, points earned, points redeemed, and points expired) is
213
218
  # recorded in the ledger. Using this endpoint, you can search the ledger for
214
219
  # events.
215
- # For more information, see
216
- # [Loyalty
217
- # events](https://developer.squareup.com/docs/docs/loyalty-api/overview/#loy
218
- # alty-events).
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.
@@ -244,15 +245,13 @@ 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
+ # Currently, a seller can only have one loyalty program.
256
255
  # @return [ListLoyaltyProgramsResponse Hash] response from the API call
257
256
  def list_loyalty_programs
258
257
  # Prepare query url.
@@ -276,7 +275,9 @@ module Square
276
275
  # Return appropriate response type.
277
276
  decoded = APIHelper.json_deserialize(_response.raw_body)
278
277
  _errors = APIHelper.map_response(decoded, ['errors'])
279
- ApiResponse.new(_response, data: decoded, errors: _errors)
278
+ ApiResponse.new(
279
+ _response, data: decoded, errors: _errors
280
+ )
280
281
  end
281
282
 
282
283
  # Calculates the points a purchase earns.
@@ -303,7 +304,7 @@ module Square
303
304
  _query_builder << '/v2/loyalty/programs/{program_id}/calculate'
304
305
  _query_builder = APIHelper.append_url_with_template_parameters(
305
306
  _query_builder,
306
- 'program_id' => program_id
307
+ 'program_id' => { 'value' => program_id, 'encode' => true }
307
308
  )
308
309
  _query_url = APIHelper.clean_url _query_builder
309
310
 
@@ -325,7 +326,9 @@ module Square
325
326
  # Return appropriate response type.
326
327
  decoded = APIHelper.json_deserialize(_response.raw_body)
327
328
  _errors = APIHelper.map_response(decoded, ['errors'])
328
- ApiResponse.new(_response, data: decoded, errors: _errors)
329
+ ApiResponse.new(
330
+ _response, data: decoded, errors: _errors
331
+ )
329
332
  end
330
333
 
331
334
  # Creates a loyalty reward. In the process, the endpoint does following:
@@ -336,10 +339,6 @@ module Square
336
339
  # discount to the order.
337
340
  # After a reward is created, the points are locked and
338
341
  # 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
342
  # @param [CreateLoyaltyRewardRequest] body Required parameter: An object
344
343
  # containing the fields to POST for the request. See the corresponding
345
344
  # object definition for field details.
@@ -368,19 +367,16 @@ module Square
368
367
  # Return appropriate response type.
369
368
  decoded = APIHelper.json_deserialize(_response.raw_body)
370
369
  _errors = APIHelper.map_response(decoded, ['errors'])
371
- ApiResponse.new(_response, data: decoded, errors: _errors)
370
+ ApiResponse.new(
371
+ _response, data: decoded, errors: _errors
372
+ )
372
373
  end
373
374
 
374
375
  # Searches for loyalty rewards in a loyalty account.
375
376
  # In the current implementation, the endpoint supports search by the reward
376
377
  # `status`.
377
378
  # 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).
379
+ # [RetrieveLoyaltyReward](#endpoint-Loyalty-RetrieveLoyaltyReward) endpoint.
384
380
  # @param [SearchLoyaltyRewardsRequest] body Required parameter: An object
385
381
  # containing the fields to POST for the request. See the corresponding
386
382
  # object definition for field details.
@@ -409,22 +405,18 @@ module Square
409
405
  # Return appropriate response type.
410
406
  decoded = APIHelper.json_deserialize(_response.raw_body)
411
407
  _errors = APIHelper.map_response(decoded, ['errors'])
412
- ApiResponse.new(_response, data: decoded, errors: _errors)
408
+ ApiResponse.new(
409
+ _response, data: decoded, errors: _errors
410
+ )
413
411
  end
414
412
 
415
413
  # Deletes a loyalty reward by doing the following:
416
414
  # - Returns the loyalty points back to the loyalty account.
417
415
  # - 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)),
416
+ # (see [CreateLoyaltyReward](#endpoint-Loyalty-CreateLoyaltyReward)),
421
417
  # it updates the order by removing the reward and related
422
418
  # discounts.
423
419
  # 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
420
  # @param [String] reward_id Required parameter: The ID of the [loyalty
429
421
  # reward](#type-LoyaltyReward) to delete.
430
422
  # @return [DeleteLoyaltyRewardResponse Hash] response from the API call
@@ -434,7 +426,7 @@ module Square
434
426
  _query_builder << '/v2/loyalty/rewards/{reward_id}'
435
427
  _query_builder = APIHelper.append_url_with_template_parameters(
436
428
  _query_builder,
437
- 'reward_id' => reward_id
429
+ 'reward_id' => { 'value' => reward_id, 'encode' => true }
438
430
  )
439
431
  _query_url = APIHelper.clean_url _query_builder
440
432
 
@@ -454,7 +446,9 @@ module Square
454
446
  # Return appropriate response type.
455
447
  decoded = APIHelper.json_deserialize(_response.raw_body)
456
448
  _errors = APIHelper.map_response(decoded, ['errors'])
457
- ApiResponse.new(_response, data: decoded, errors: _errors)
449
+ ApiResponse.new(
450
+ _response, data: decoded, errors: _errors
451
+ )
458
452
  end
459
453
 
460
454
  # Retrieves a loyalty reward.
@@ -467,7 +461,7 @@ module Square
467
461
  _query_builder << '/v2/loyalty/rewards/{reward_id}'
468
462
  _query_builder = APIHelper.append_url_with_template_parameters(
469
463
  _query_builder,
470
- 'reward_id' => reward_id
464
+ 'reward_id' => { 'value' => reward_id, 'encode' => true }
471
465
  )
472
466
  _query_url = APIHelper.clean_url _query_builder
473
467
 
@@ -487,21 +481,19 @@ module Square
487
481
  # Return appropriate response type.
488
482
  decoded = APIHelper.json_deserialize(_response.raw_body)
489
483
  _errors = APIHelper.map_response(decoded, ['errors'])
490
- ApiResponse.new(_response, data: decoded, errors: _errors)
484
+ ApiResponse.new(
485
+ _response, data: decoded, errors: _errors
486
+ )
491
487
  end
492
488
 
493
489
  # Redeems a loyalty reward.
494
- # The endpoint sets the reward to the terminal state (`REDEEMED`).
490
+ # The endpoint sets the reward to the `REDEEMED` terminal state.
495
491
  # If you are using your own order processing system (not using the
496
492
  # Orders API), you call this endpoint after the buyer paid for the
497
493
  # purchase.
498
494
  # After the reward reaches the terminal state, it cannot be deleted.
499
495
  # In other words, points used for the reward cannot be returned
500
496
  # 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
497
  # @param [String] reward_id Required parameter: The ID of the [loyalty
506
498
  # reward](#type-LoyaltyReward) to redeem.
507
499
  # @param [RedeemLoyaltyRewardRequest] body Required parameter: An object
@@ -515,7 +507,7 @@ module Square
515
507
  _query_builder << '/v2/loyalty/rewards/{reward_id}/redeem'
516
508
  _query_builder = APIHelper.append_url_with_template_parameters(
517
509
  _query_builder,
518
- 'reward_id' => reward_id
510
+ 'reward_id' => { 'value' => reward_id, 'encode' => true }
519
511
  )
520
512
  _query_url = APIHelper.clean_url _query_builder
521
513
 
@@ -537,7 +529,9 @@ module Square
537
529
  # Return appropriate response type.
538
530
  decoded = APIHelper.json_deserialize(_response.raw_body)
539
531
  _errors = APIHelper.map_response(decoded, ['errors'])
540
- ApiResponse.new(_response, data: decoded, errors: _errors)
532
+ ApiResponse.new(
533
+ _response, data: decoded, errors: _errors
534
+ )
541
535
  end
542
536
  end
543
537
  end