square.rb 5.2.2.20200422 → 6.3.0.20200826

Sign up to get free protection for your applications and to get access to all the features.
@@ -209,6 +209,7 @@ module Square
209
209
  def list_employee_wages(employee_id: nil,
210
210
  limit: nil,
211
211
  cursor: nil)
212
+ warn 'Endpoint list_employee_wages in LaborApi is deprecated'
212
213
  # Prepare query url.
213
214
  _query_builder = config.get_base_uri
214
215
  _query_builder << '/v2/labor/employee-wages'
@@ -244,6 +245,7 @@ module Square
244
245
  # retrieved.
245
246
  # @return [GetEmployeeWageResponse Hash] response from the API call
246
247
  def get_employee_wage(id:)
248
+ warn 'Endpoint get_employee_wage in LaborApi is deprecated'
247
249
  # Prepare query url.
248
250
  _query_builder = config.get_base_uri
249
251
  _query_builder << '/v2/labor/employee-wages/{id}'
@@ -474,6 +476,81 @@ module Square
474
476
  ApiResponse.new(_response, data: decoded, errors: _errors)
475
477
  end
476
478
 
479
+ # Returns a paginated list of `TeamMemberWage` instances for a business.
480
+ # @param [String] team_member_id Optional parameter: Filter wages returned
481
+ # to only those that are associated with the specified team member.
482
+ # @param [Integer] limit Optional parameter: Maximum number of Team Member
483
+ # Wages to return per page. Can range between 1 and 200. The default is the
484
+ # maximum at 200.
485
+ # @param [String] cursor Optional parameter: Pointer to the next page of
486
+ # Employee Wage results to fetch.
487
+ # @return [ListTeamMemberWagesResponse Hash] response from the API call
488
+ def list_team_member_wages(team_member_id: nil,
489
+ limit: nil,
490
+ cursor: nil)
491
+ # Prepare query url.
492
+ _query_builder = config.get_base_uri
493
+ _query_builder << '/v2/labor/team-member-wages'
494
+ _query_builder = APIHelper.append_url_with_query_parameters(
495
+ _query_builder,
496
+ 'team_member_id' => team_member_id,
497
+ 'limit' => limit,
498
+ 'cursor' => cursor
499
+ )
500
+ _query_url = APIHelper.clean_url _query_builder
501
+
502
+ # Prepare headers.
503
+ _headers = {
504
+ 'accept' => 'application/json'
505
+ }
506
+
507
+ # Prepare and execute HttpRequest.
508
+ _request = config.http_client.get(
509
+ _query_url,
510
+ headers: _headers
511
+ )
512
+ OAuth2.apply(config, _request)
513
+ _response = execute_request(_request)
514
+
515
+ # Return appropriate response type.
516
+ decoded = APIHelper.json_deserialize(_response.raw_body)
517
+ _errors = APIHelper.map_response(decoded, ['errors'])
518
+ ApiResponse.new(_response, data: decoded, errors: _errors)
519
+ end
520
+
521
+ # Returns a single `TeamMemberWage` specified by id.
522
+ # @param [String] id Required parameter: UUID for the `TeamMemberWage` being
523
+ # retrieved.
524
+ # @return [GetTeamMemberWageResponse Hash] response from the API call
525
+ def get_team_member_wage(id:)
526
+ # Prepare query url.
527
+ _query_builder = config.get_base_uri
528
+ _query_builder << '/v2/labor/team-member-wages/{id}'
529
+ _query_builder = APIHelper.append_url_with_template_parameters(
530
+ _query_builder,
531
+ 'id' => id
532
+ )
533
+ _query_url = APIHelper.clean_url _query_builder
534
+
535
+ # Prepare headers.
536
+ _headers = {
537
+ 'accept' => 'application/json'
538
+ }
539
+
540
+ # Prepare and execute HttpRequest.
541
+ _request = config.http_client.get(
542
+ _query_url,
543
+ headers: _headers
544
+ )
545
+ OAuth2.apply(config, _request)
546
+ _response = execute_request(_request)
547
+
548
+ # Return appropriate response type.
549
+ decoded = APIHelper.json_deserialize(_response.raw_body)
550
+ _errors = APIHelper.map_response(decoded, ['errors'])
551
+ ApiResponse.new(_response, data: decoded, errors: _errors)
552
+ end
553
+
477
554
  # Returns a list of `WorkweekConfig` instances for a business.
478
555
  # @param [Integer] limit Optional parameter: Maximum number of Workweek
479
556
  # Configs to return per page.
@@ -71,9 +71,14 @@ module Square
71
71
  ApiResponse.new(_response, data: decoded, errors: _errors)
72
72
  end
73
73
 
74
- # Retrieves details of a location.
74
+ # Retrieves details of a location. You can specify "main"
75
+ # as the location ID to retrieve details of the
76
+ # main location. For more information,
77
+ # see [Locations API
78
+ # Overview](https://developer.squareup.com/docs/docs/locations-api).
75
79
  # @param [String] location_id Required parameter: The ID of the location to
76
- # retrieve.
80
+ # retrieve. If you specify the string "main", then the endpoint returns the
81
+ # main location.
77
82
  # @return [RetrieveLocationResponse Hash] response from the API call
78
83
  def retrieve_location(location_id:)
79
84
  # Prepare query url.
@@ -0,0 +1,543 @@
1
+ module Square
2
+ # LoyaltyApi
3
+ class LoyaltyApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
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).
12
+ # @param [CreateLoyaltyAccountRequest] body Required parameter: An object
13
+ # containing the fields to POST for the request. See the corresponding
14
+ # object definition for field details.
15
+ # @return [CreateLoyaltyAccountResponse Hash] response from the API call
16
+ def create_loyalty_account(body:)
17
+ # Prepare query url.
18
+ _query_builder = config.get_base_uri
19
+ _query_builder << '/v2/loyalty/accounts'
20
+ _query_url = APIHelper.clean_url _query_builder
21
+
22
+ # Prepare headers.
23
+ _headers = {
24
+ 'accept' => 'application/json',
25
+ 'content-type' => 'application/json; charset=utf-8'
26
+ }
27
+
28
+ # Prepare and execute HttpRequest.
29
+ _request = config.http_client.post(
30
+ _query_url,
31
+ headers: _headers,
32
+ parameters: body.to_json
33
+ )
34
+ OAuth2.apply(config, _request)
35
+ _response = execute_request(_request)
36
+
37
+ # Return appropriate response type.
38
+ decoded = APIHelper.json_deserialize(_response.raw_body)
39
+ _errors = APIHelper.map_response(decoded, ['errors'])
40
+ ApiResponse.new(_response, data: decoded, errors: _errors)
41
+ end
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.
47
+ # @param [SearchLoyaltyAccountsRequest] body Required parameter: An object
48
+ # containing the fields to POST for the request. See the corresponding
49
+ # object definition for field details.
50
+ # @return [SearchLoyaltyAccountsResponse Hash] response from the API call
51
+ def search_loyalty_accounts(body:)
52
+ # Prepare query url.
53
+ _query_builder = config.get_base_uri
54
+ _query_builder << '/v2/loyalty/accounts/search'
55
+ _query_url = APIHelper.clean_url _query_builder
56
+
57
+ # Prepare headers.
58
+ _headers = {
59
+ 'accept' => 'application/json',
60
+ 'content-type' => 'application/json; charset=utf-8'
61
+ }
62
+
63
+ # Prepare and execute HttpRequest.
64
+ _request = config.http_client.post(
65
+ _query_url,
66
+ headers: _headers,
67
+ parameters: body.to_json
68
+ )
69
+ OAuth2.apply(config, _request)
70
+ _response = execute_request(_request)
71
+
72
+ # Return appropriate response type.
73
+ decoded = APIHelper.json_deserialize(_response.raw_body)
74
+ _errors = APIHelper.map_response(decoded, ['errors'])
75
+ ApiResponse.new(_response, data: decoded, errors: _errors)
76
+ end
77
+
78
+ # Retrieves a loyalty account.
79
+ # @param [String] account_id Required parameter: The ID of the [loyalty
80
+ # account](#type-LoyaltyAccount) to retrieve.
81
+ # @return [RetrieveLoyaltyAccountResponse Hash] response from the API call
82
+ def retrieve_loyalty_account(account_id:)
83
+ # Prepare query url.
84
+ _query_builder = config.get_base_uri
85
+ _query_builder << '/v2/loyalty/accounts/{account_id}'
86
+ _query_builder = APIHelper.append_url_with_template_parameters(
87
+ _query_builder,
88
+ 'account_id' => account_id
89
+ )
90
+ _query_url = APIHelper.clean_url _query_builder
91
+
92
+ # Prepare headers.
93
+ _headers = {
94
+ 'accept' => 'application/json'
95
+ }
96
+
97
+ # Prepare and execute HttpRequest.
98
+ _request = config.http_client.get(
99
+ _query_url,
100
+ headers: _headers
101
+ )
102
+ OAuth2.apply(config, _request)
103
+ _response = execute_request(_request)
104
+
105
+ # Return appropriate response type.
106
+ decoded = APIHelper.json_deserialize(_response.raw_body)
107
+ _errors = APIHelper.map_response(decoded, ['errors'])
108
+ ApiResponse.new(_response, data: decoded, errors: _errors)
109
+ end
110
+
111
+ # Adds points to a loyalty account.
112
+ # - If you are using the Orders API to manage orders, you only provide the
113
+ # `order_id`.
114
+ # The endpoint reads the order to compute points to add to the buyer's
115
+ # account.
116
+ # - If you are not using the Orders API to manage orders,
117
+ # 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).
126
+ # @param [String] account_id Required parameter: The [loyalty
127
+ # account](#type-LoyaltyAccount) ID to which to add the points.
128
+ # @param [AccumulateLoyaltyPointsRequest] body Required parameter: An object
129
+ # containing the fields to POST for the request. See the corresponding
130
+ # object definition for field details.
131
+ # @return [AccumulateLoyaltyPointsResponse Hash] response from the API call
132
+ def accumulate_loyalty_points(account_id:,
133
+ body:)
134
+ # Prepare query url.
135
+ _query_builder = config.get_base_uri
136
+ _query_builder << '/v2/loyalty/accounts/{account_id}/accumulate'
137
+ _query_builder = APIHelper.append_url_with_template_parameters(
138
+ _query_builder,
139
+ 'account_id' => account_id
140
+ )
141
+ _query_url = APIHelper.clean_url _query_builder
142
+
143
+ # Prepare headers.
144
+ _headers = {
145
+ 'accept' => 'application/json',
146
+ 'content-type' => 'application/json; charset=utf-8'
147
+ }
148
+
149
+ # Prepare and execute HttpRequest.
150
+ _request = config.http_client.post(
151
+ _query_url,
152
+ headers: _headers,
153
+ parameters: body.to_json
154
+ )
155
+ OAuth2.apply(config, _request)
156
+ _response = execute_request(_request)
157
+
158
+ # Return appropriate response type.
159
+ decoded = APIHelper.json_deserialize(_response.raw_body)
160
+ _errors = APIHelper.map_response(decoded, ['errors'])
161
+ ApiResponse.new(_response, data: decoded, errors: _errors)
162
+ end
163
+
164
+ # Adds points to or subtracts points from a buyer's account.
165
+ # Use this endpoint only when you need to manually adjust points. Otherwise,
166
+ # in your application flow, you call
167
+ # [AccumulateLoyaltyPoints](https://developer.squareup.com/docs/reference/sq
168
+ # uare/loyalty-api/accumulate-loyalty-points)
169
+ # to add points when a buyer pays for the purchase.
170
+ # @param [String] account_id Required parameter: The ID of the [loyalty
171
+ # account](#type-LoyaltyAccount) in which to adjust the points.
172
+ # @param [AdjustLoyaltyPointsRequest] body Required parameter: An object
173
+ # containing the fields to POST for the request. See the corresponding
174
+ # object definition for field details.
175
+ # @return [AdjustLoyaltyPointsResponse Hash] response from the API call
176
+ def adjust_loyalty_points(account_id:,
177
+ body:)
178
+ # Prepare query url.
179
+ _query_builder = config.get_base_uri
180
+ _query_builder << '/v2/loyalty/accounts/{account_id}/adjust'
181
+ _query_builder = APIHelper.append_url_with_template_parameters(
182
+ _query_builder,
183
+ 'account_id' => account_id
184
+ )
185
+ _query_url = APIHelper.clean_url _query_builder
186
+
187
+ # Prepare headers.
188
+ _headers = {
189
+ 'accept' => 'application/json',
190
+ 'content-type' => 'application/json; charset=utf-8'
191
+ }
192
+
193
+ # Prepare and execute HttpRequest.
194
+ _request = config.http_client.post(
195
+ _query_url,
196
+ headers: _headers,
197
+ parameters: body.to_json
198
+ )
199
+ OAuth2.apply(config, _request)
200
+ _response = execute_request(_request)
201
+
202
+ # Return appropriate response type.
203
+ decoded = APIHelper.json_deserialize(_response.raw_body)
204
+ _errors = APIHelper.map_response(decoded, ['errors'])
205
+ ApiResponse.new(_response, data: decoded, errors: _errors)
206
+ end
207
+
208
+ # Searches for loyalty events.
209
+ # A Square loyalty program maintains a ledger of events that occur during
210
+ # the lifetime of a
211
+ # buyer's loyalty account. Each change in the point balance
212
+ # (for example, points earned, points redeemed, and points expired) is
213
+ # recorded in the ledger. Using this endpoint, you can search the ledger for
214
+ # events.
215
+ # For more information, see
216
+ # [Loyalty
217
+ # events](https://developer.squareup.com/docs/docs/loyalty-api/overview/#loy
218
+ # alty-events).
219
+ # @param [SearchLoyaltyEventsRequest] body Required parameter: An object
220
+ # containing the fields to POST for the request. See the corresponding
221
+ # object definition for field details.
222
+ # @return [SearchLoyaltyEventsResponse Hash] response from the API call
223
+ def search_loyalty_events(body:)
224
+ # Prepare query url.
225
+ _query_builder = config.get_base_uri
226
+ _query_builder << '/v2/loyalty/events/search'
227
+ _query_url = APIHelper.clean_url _query_builder
228
+
229
+ # Prepare headers.
230
+ _headers = {
231
+ 'accept' => 'application/json',
232
+ 'content-type' => 'application/json; charset=utf-8'
233
+ }
234
+
235
+ # Prepare and execute HttpRequest.
236
+ _request = config.http_client.post(
237
+ _query_url,
238
+ headers: _headers,
239
+ parameters: body.to_json
240
+ )
241
+ OAuth2.apply(config, _request)
242
+ _response = execute_request(_request)
243
+
244
+ # Return appropriate response type.
245
+ decoded = APIHelper.json_deserialize(_response.raw_body)
246
+ _errors = APIHelper.map_response(decoded, ['errors'])
247
+ ApiResponse.new(_response, data: decoded, errors: _errors)
248
+ end
249
+
250
+ # 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
+ # .
256
+ # @return [ListLoyaltyProgramsResponse Hash] response from the API call
257
+ def list_loyalty_programs
258
+ # Prepare query url.
259
+ _query_builder = config.get_base_uri
260
+ _query_builder << '/v2/loyalty/programs'
261
+ _query_url = APIHelper.clean_url _query_builder
262
+
263
+ # Prepare headers.
264
+ _headers = {
265
+ 'accept' => 'application/json'
266
+ }
267
+
268
+ # Prepare and execute HttpRequest.
269
+ _request = config.http_client.get(
270
+ _query_url,
271
+ headers: _headers
272
+ )
273
+ OAuth2.apply(config, _request)
274
+ _response = execute_request(_request)
275
+
276
+ # Return appropriate response type.
277
+ decoded = APIHelper.json_deserialize(_response.raw_body)
278
+ _errors = APIHelper.map_response(decoded, ['errors'])
279
+ ApiResponse.new(_response, data: decoded, errors: _errors)
280
+ end
281
+
282
+ # 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
285
+ # endpoint calculates the points by reading the order.
286
+ # - If you are not using the Orders API to manage orders, you provide the
287
+ # purchase amount in
288
+ # the request for the endpoint to calculate the points.
289
+ # An application might call this endpoint to show the points that a buyer
290
+ # can earn with the
291
+ # specific purchase.
292
+ # @param [String] program_id Required parameter: The [loyalty
293
+ # program](#type-LoyaltyProgram) ID, which defines the rules for accruing
294
+ # points.
295
+ # @param [CalculateLoyaltyPointsRequest] body Required parameter: An object
296
+ # containing the fields to POST for the request. See the corresponding
297
+ # object definition for field details.
298
+ # @return [CalculateLoyaltyPointsResponse Hash] response from the API call
299
+ def calculate_loyalty_points(program_id:,
300
+ body:)
301
+ # Prepare query url.
302
+ _query_builder = config.get_base_uri
303
+ _query_builder << '/v2/loyalty/programs/{program_id}/calculate'
304
+ _query_builder = APIHelper.append_url_with_template_parameters(
305
+ _query_builder,
306
+ 'program_id' => program_id
307
+ )
308
+ _query_url = APIHelper.clean_url _query_builder
309
+
310
+ # Prepare headers.
311
+ _headers = {
312
+ 'accept' => 'application/json',
313
+ 'content-type' => 'application/json; charset=utf-8'
314
+ }
315
+
316
+ # Prepare and execute HttpRequest.
317
+ _request = config.http_client.post(
318
+ _query_url,
319
+ headers: _headers,
320
+ parameters: body.to_json
321
+ )
322
+ OAuth2.apply(config, _request)
323
+ _response = execute_request(_request)
324
+
325
+ # Return appropriate response type.
326
+ decoded = APIHelper.json_deserialize(_response.raw_body)
327
+ _errors = APIHelper.map_response(decoded, ['errors'])
328
+ ApiResponse.new(_response, data: decoded, errors: _errors)
329
+ end
330
+
331
+ # Creates a loyalty reward. In the process, the endpoint does following:
332
+ # - Uses the `reward_tier_id` in the request to determine the number of
333
+ # points
334
+ # to lock for this reward.
335
+ # - If the request includes `order_id`, it adds the reward and related
336
+ # discount to the order.
337
+ # After a reward is created, the points are locked and
338
+ # 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
+ # @param [CreateLoyaltyRewardRequest] body Required parameter: An object
344
+ # containing the fields to POST for the request. See the corresponding
345
+ # object definition for field details.
346
+ # @return [CreateLoyaltyRewardResponse Hash] response from the API call
347
+ def create_loyalty_reward(body:)
348
+ # Prepare query url.
349
+ _query_builder = config.get_base_uri
350
+ _query_builder << '/v2/loyalty/rewards'
351
+ _query_url = APIHelper.clean_url _query_builder
352
+
353
+ # Prepare headers.
354
+ _headers = {
355
+ 'accept' => 'application/json',
356
+ 'content-type' => 'application/json; charset=utf-8'
357
+ }
358
+
359
+ # Prepare and execute HttpRequest.
360
+ _request = config.http_client.post(
361
+ _query_url,
362
+ headers: _headers,
363
+ parameters: body.to_json
364
+ )
365
+ OAuth2.apply(config, _request)
366
+ _response = execute_request(_request)
367
+
368
+ # Return appropriate response type.
369
+ decoded = APIHelper.json_deserialize(_response.raw_body)
370
+ _errors = APIHelper.map_response(decoded, ['errors'])
371
+ ApiResponse.new(_response, data: decoded, errors: _errors)
372
+ end
373
+
374
+ # Searches for loyalty rewards in a loyalty account.
375
+ # In the current implementation, the endpoint supports search by the reward
376
+ # `status`.
377
+ # 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).
384
+ # @param [SearchLoyaltyRewardsRequest] body Required parameter: An object
385
+ # containing the fields to POST for the request. See the corresponding
386
+ # object definition for field details.
387
+ # @return [SearchLoyaltyRewardsResponse Hash] response from the API call
388
+ def search_loyalty_rewards(body:)
389
+ # Prepare query url.
390
+ _query_builder = config.get_base_uri
391
+ _query_builder << '/v2/loyalty/rewards/search'
392
+ _query_url = APIHelper.clean_url _query_builder
393
+
394
+ # Prepare headers.
395
+ _headers = {
396
+ 'accept' => 'application/json',
397
+ 'content-type' => 'application/json; charset=utf-8'
398
+ }
399
+
400
+ # Prepare and execute HttpRequest.
401
+ _request = config.http_client.post(
402
+ _query_url,
403
+ headers: _headers,
404
+ parameters: body.to_json
405
+ )
406
+ OAuth2.apply(config, _request)
407
+ _response = execute_request(_request)
408
+
409
+ # Return appropriate response type.
410
+ decoded = APIHelper.json_deserialize(_response.raw_body)
411
+ _errors = APIHelper.map_response(decoded, ['errors'])
412
+ ApiResponse.new(_response, data: decoded, errors: _errors)
413
+ end
414
+
415
+ # Deletes a loyalty reward by doing the following:
416
+ # - Returns the loyalty points back to the loyalty account.
417
+ # - 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)),
421
+ # it updates the order by removing the reward and related
422
+ # discounts.
423
+ # 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
+ # @param [String] reward_id Required parameter: The ID of the [loyalty
429
+ # reward](#type-LoyaltyReward) to delete.
430
+ # @return [DeleteLoyaltyRewardResponse Hash] response from the API call
431
+ def delete_loyalty_reward(reward_id:)
432
+ # Prepare query url.
433
+ _query_builder = config.get_base_uri
434
+ _query_builder << '/v2/loyalty/rewards/{reward_id}'
435
+ _query_builder = APIHelper.append_url_with_template_parameters(
436
+ _query_builder,
437
+ 'reward_id' => reward_id
438
+ )
439
+ _query_url = APIHelper.clean_url _query_builder
440
+
441
+ # Prepare headers.
442
+ _headers = {
443
+ 'accept' => 'application/json'
444
+ }
445
+
446
+ # Prepare and execute HttpRequest.
447
+ _request = config.http_client.delete(
448
+ _query_url,
449
+ headers: _headers
450
+ )
451
+ OAuth2.apply(config, _request)
452
+ _response = execute_request(_request)
453
+
454
+ # Return appropriate response type.
455
+ decoded = APIHelper.json_deserialize(_response.raw_body)
456
+ _errors = APIHelper.map_response(decoded, ['errors'])
457
+ ApiResponse.new(_response, data: decoded, errors: _errors)
458
+ end
459
+
460
+ # Retrieves a loyalty reward.
461
+ # @param [String] reward_id Required parameter: The ID of the [loyalty
462
+ # reward](#type-LoyaltyReward) to retrieve.
463
+ # @return [RetrieveLoyaltyRewardResponse Hash] response from the API call
464
+ def retrieve_loyalty_reward(reward_id:)
465
+ # Prepare query url.
466
+ _query_builder = config.get_base_uri
467
+ _query_builder << '/v2/loyalty/rewards/{reward_id}'
468
+ _query_builder = APIHelper.append_url_with_template_parameters(
469
+ _query_builder,
470
+ 'reward_id' => reward_id
471
+ )
472
+ _query_url = APIHelper.clean_url _query_builder
473
+
474
+ # Prepare headers.
475
+ _headers = {
476
+ 'accept' => 'application/json'
477
+ }
478
+
479
+ # Prepare and execute HttpRequest.
480
+ _request = config.http_client.get(
481
+ _query_url,
482
+ headers: _headers
483
+ )
484
+ OAuth2.apply(config, _request)
485
+ _response = execute_request(_request)
486
+
487
+ # Return appropriate response type.
488
+ decoded = APIHelper.json_deserialize(_response.raw_body)
489
+ _errors = APIHelper.map_response(decoded, ['errors'])
490
+ ApiResponse.new(_response, data: decoded, errors: _errors)
491
+ end
492
+
493
+ # Redeems a loyalty reward.
494
+ # The endpoint sets the reward to the terminal state (`REDEEMED`).
495
+ # If you are using your own order processing system (not using the
496
+ # Orders API), you call this endpoint after the buyer paid for the
497
+ # purchase.
498
+ # After the reward reaches the terminal state, it cannot be deleted.
499
+ # In other words, points used for the reward cannot be returned
500
+ # 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
+ # @param [String] reward_id Required parameter: The ID of the [loyalty
506
+ # reward](#type-LoyaltyReward) to redeem.
507
+ # @param [RedeemLoyaltyRewardRequest] body Required parameter: An object
508
+ # containing the fields to POST for the request. See the corresponding
509
+ # object definition for field details.
510
+ # @return [RedeemLoyaltyRewardResponse Hash] response from the API call
511
+ def redeem_loyalty_reward(reward_id:,
512
+ body:)
513
+ # Prepare query url.
514
+ _query_builder = config.get_base_uri
515
+ _query_builder << '/v2/loyalty/rewards/{reward_id}/redeem'
516
+ _query_builder = APIHelper.append_url_with_template_parameters(
517
+ _query_builder,
518
+ 'reward_id' => reward_id
519
+ )
520
+ _query_url = APIHelper.clean_url _query_builder
521
+
522
+ # Prepare headers.
523
+ _headers = {
524
+ 'accept' => 'application/json',
525
+ 'content-type' => 'application/json; charset=utf-8'
526
+ }
527
+
528
+ # Prepare and execute HttpRequest.
529
+ _request = config.http_client.post(
530
+ _query_url,
531
+ headers: _headers,
532
+ parameters: body.to_json
533
+ )
534
+ OAuth2.apply(config, _request)
535
+ _response = execute_request(_request)
536
+
537
+ # Return appropriate response type.
538
+ decoded = APIHelper.json_deserialize(_response.raw_body)
539
+ _errors = APIHelper.map_response(decoded, ['errors'])
540
+ ApiResponse.new(_response, data: decoded, errors: _errors)
541
+ end
542
+ end
543
+ end