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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +79 -221
  4. data/lib/square/api/apple_pay_api.rb +15 -8
  5. data/lib/square/api/bank_accounts_api.rb +5 -5
  6. data/lib/square/api/base_api.rb +27 -9
  7. data/lib/square/api/booking_custom_attributes_api.rb +555 -0
  8. data/lib/square/api/bookings_api.rb +107 -15
  9. data/lib/square/api/cards_api.rb +171 -0
  10. data/lib/square/api/cash_drawers_api.rb +2 -2
  11. data/lib/square/api/catalog_api.rb +167 -73
  12. data/lib/square/api/checkout_api.rb +205 -3
  13. data/lib/square/api/customer_custom_attributes_api.rb +561 -0
  14. data/lib/square/api/customer_groups_api.rb +17 -8
  15. data/lib/square/api/customer_segments_api.rb +15 -6
  16. data/lib/square/api/customers_api.rb +67 -33
  17. data/lib/square/api/devices_api.rb +3 -2
  18. data/lib/square/api/disputes_api.rb +109 -105
  19. data/lib/square/api/gift_card_activities_api.rb +132 -0
  20. data/lib/square/api/gift_cards_api.rb +298 -0
  21. data/lib/square/api/inventory_api.rb +263 -24
  22. data/lib/square/api/invoices_api.rb +21 -21
  23. data/lib/square/api/labor_api.rb +70 -68
  24. data/lib/square/api/location_custom_attributes_api.rb +584 -0
  25. data/lib/square/api/locations_api.rb +21 -14
  26. data/lib/square/api/loyalty_api.rb +333 -50
  27. data/lib/square/api/merchants_api.rb +11 -9
  28. data/lib/square/api/mobile_authorization_api.rb +4 -4
  29. data/lib/square/api/o_auth_api.rb +78 -25
  30. data/lib/square/api/order_custom_attributes_api.rb +601 -0
  31. data/lib/square/api/orders_api.rb +84 -45
  32. data/lib/square/api/payments_api.rb +72 -24
  33. data/lib/square/api/payouts_api.rb +173 -0
  34. data/lib/square/api/refunds_api.rb +18 -7
  35. data/lib/square/api/sites_api.rb +43 -0
  36. data/lib/square/api/snippets_api.rb +146 -0
  37. data/lib/square/api/subscriptions_api.rb +190 -15
  38. data/lib/square/api/team_api.rb +46 -46
  39. data/lib/square/api/terminal_api.rb +172 -22
  40. data/lib/square/api/transactions_api.rb +15 -191
  41. data/lib/square/api/v1_transactions_api.rb +52 -124
  42. data/lib/square/api/vendors_api.rb +257 -0
  43. data/lib/square/api/webhook_subscriptions_api.rb +327 -0
  44. data/lib/square/api_helper.rb +217 -57
  45. data/lib/square/client.rb +90 -18
  46. data/lib/square/configuration.rb +64 -20
  47. data/lib/square/exceptions/validation_exception.rb +13 -0
  48. data/lib/square/http/api_response.rb +7 -9
  49. data/lib/square/http/faraday_client.rb +40 -9
  50. data/lib/square/http/http_client.rb +31 -12
  51. data/lib/square/http/http_request.rb +6 -2
  52. data/lib/square/utilities/date_time_helper.rb +151 -0
  53. data/lib/square/utilities/file_wrapper.rb +1 -2
  54. data/lib/square.rb +56 -44
  55. data/test/api/test_locations_api.rb +2 -5
  56. data/test/test_helper.rb +2 -2
  57. metadata +83 -15
  58. data/lib/square/api/v1_employees_api.rb +0 -751
  59. data/lib/square/api/v1_items_api.rb +0 -1766
@@ -1,751 +0,0 @@
1
- module Square
2
- # V1EmployeesApi
3
- class V1EmployeesApi < BaseApi
4
- def initialize(config, http_call_back: nil)
5
- super(config, http_call_back: http_call_back)
6
- end
7
-
8
- # Provides summary information for all of a business's employees.
9
- # @param [SortOrder] order Optional parameter: The order in which employees
10
- # are listed in the response, based on their created_at field. Default
11
- # value: ASC
12
- # @param [String] begin_updated_at Optional parameter: If filtering results
13
- # by their updated_at field, the beginning of the requested reporting
14
- # period, in ISO 8601 format
15
- # @param [String] end_updated_at Optional parameter: If filtering results by
16
- # there updated_at field, the end of the requested reporting period, in ISO
17
- # 8601 format.
18
- # @param [String] begin_created_at Optional parameter: If filtering results
19
- # by their created_at field, the beginning of the requested reporting
20
- # period, in ISO 8601 format.
21
- # @param [String] end_created_at Optional parameter: If filtering results by
22
- # their created_at field, the end of the requested reporting period, in ISO
23
- # 8601 format.
24
- # @param [V1ListEmployeesRequestStatus] status Optional parameter: If
25
- # provided, the endpoint returns only employee entities with the specified
26
- # status (ACTIVE or INACTIVE).
27
- # @param [String] external_id Optional parameter: If provided, the endpoint
28
- # returns only employee entities with the specified external_id.
29
- # @param [Integer] limit Optional parameter: The maximum integer number of
30
- # employee entities to return in a single response. Default 100, maximum
31
- # 200.
32
- # @param [String] batch_token Optional parameter: A pagination cursor to
33
- # retrieve the next set of results for your original query to the
34
- # endpoint.
35
- # @return [List of V1Employee Hash] response from the API call
36
- def list_employees(order: nil,
37
- begin_updated_at: nil,
38
- end_updated_at: nil,
39
- begin_created_at: nil,
40
- end_created_at: nil,
41
- status: nil,
42
- external_id: nil,
43
- limit: nil,
44
- batch_token: nil)
45
- # Prepare query url.
46
- _query_builder = config.get_base_uri
47
- _query_builder << '/v1/me/employees'
48
- _query_builder = APIHelper.append_url_with_query_parameters(
49
- _query_builder,
50
- 'order' => order,
51
- 'begin_updated_at' => begin_updated_at,
52
- 'end_updated_at' => end_updated_at,
53
- 'begin_created_at' => begin_created_at,
54
- 'end_created_at' => end_created_at,
55
- 'status' => status,
56
- 'external_id' => external_id,
57
- 'limit' => limit,
58
- 'batch_token' => batch_token
59
- )
60
- _query_url = APIHelper.clean_url _query_builder
61
-
62
- # Prepare headers.
63
- _headers = {
64
- 'accept' => 'application/json'
65
- }
66
-
67
- # Prepare and execute HttpRequest.
68
- _request = config.http_client.get(
69
- _query_url,
70
- headers: _headers
71
- )
72
- OAuth2.apply(config, _request)
73
- _response = execute_request(_request)
74
-
75
- # Return appropriate response type.
76
- decoded = APIHelper.json_deserialize(_response.raw_body)
77
- _errors = APIHelper.map_response(decoded, ['errors'])
78
- ApiResponse.new(
79
- _response, data: decoded, errors: _errors
80
- )
81
- end
82
-
83
- # Use the CreateEmployee endpoint to add an employee to a Square
84
- # account. Employees created with the Connect API have an initial status
85
- # of `INACTIVE`. Inactive employees cannot sign in to Square Point of Sale
86
- # until they are activated from the Square Dashboard. Employee status
87
- # cannot be changed with the Connect API.
88
- # Employee entities cannot be deleted. To disable employee profiles,
89
- # set the employee's status to <code>INACTIVE</code>
90
- # @param [V1Employee] body Required parameter: An object containing the
91
- # fields to POST for the request. See the corresponding object definition
92
- # for field details.
93
- # @return [V1Employee Hash] response from the API call
94
- def create_employee(body:)
95
- # Prepare query url.
96
- _query_builder = config.get_base_uri
97
- _query_builder << '/v1/me/employees'
98
- _query_url = APIHelper.clean_url _query_builder
99
-
100
- # Prepare headers.
101
- _headers = {
102
- 'accept' => 'application/json',
103
- 'content-type' => 'application/json; charset=utf-8'
104
- }
105
-
106
- # Prepare and execute HttpRequest.
107
- _request = config.http_client.post(
108
- _query_url,
109
- headers: _headers,
110
- parameters: body.to_json
111
- )
112
- OAuth2.apply(config, _request)
113
- _response = execute_request(_request)
114
-
115
- # Return appropriate response type.
116
- decoded = APIHelper.json_deserialize(_response.raw_body)
117
- _errors = APIHelper.map_response(decoded, ['errors'])
118
- ApiResponse.new(
119
- _response, data: decoded, errors: _errors
120
- )
121
- end
122
-
123
- # Provides the details for a single employee.
124
- # @param [String] employee_id Required parameter: The employee's ID.
125
- # @return [V1Employee Hash] response from the API call
126
- def retrieve_employee(employee_id:)
127
- # Prepare query url.
128
- _query_builder = config.get_base_uri
129
- _query_builder << '/v1/me/employees/{employee_id}'
130
- _query_builder = APIHelper.append_url_with_template_parameters(
131
- _query_builder,
132
- 'employee_id' => { 'value' => employee_id, 'encode' => true }
133
- )
134
- _query_url = APIHelper.clean_url _query_builder
135
-
136
- # Prepare headers.
137
- _headers = {
138
- 'accept' => 'application/json'
139
- }
140
-
141
- # Prepare and execute HttpRequest.
142
- _request = config.http_client.get(
143
- _query_url,
144
- headers: _headers
145
- )
146
- OAuth2.apply(config, _request)
147
- _response = execute_request(_request)
148
-
149
- # Return appropriate response type.
150
- decoded = APIHelper.json_deserialize(_response.raw_body)
151
- _errors = APIHelper.map_response(decoded, ['errors'])
152
- ApiResponse.new(
153
- _response, data: decoded, errors: _errors
154
- )
155
- end
156
-
157
- # UpdateEmployee
158
- # @param [String] employee_id Required parameter: The ID of the role to
159
- # modify.
160
- # @param [V1Employee] body Required parameter: An object containing the
161
- # fields to POST for the request. See the corresponding object definition
162
- # for field details.
163
- # @return [V1Employee Hash] response from the API call
164
- def update_employee(employee_id:,
165
- body:)
166
- # Prepare query url.
167
- _query_builder = config.get_base_uri
168
- _query_builder << '/v1/me/employees/{employee_id}'
169
- _query_builder = APIHelper.append_url_with_template_parameters(
170
- _query_builder,
171
- 'employee_id' => { 'value' => employee_id, 'encode' => true }
172
- )
173
- _query_url = APIHelper.clean_url _query_builder
174
-
175
- # Prepare headers.
176
- _headers = {
177
- 'accept' => 'application/json',
178
- 'content-type' => 'application/json; charset=utf-8'
179
- }
180
-
181
- # Prepare and execute HttpRequest.
182
- _request = config.http_client.put(
183
- _query_url,
184
- headers: _headers,
185
- parameters: body.to_json
186
- )
187
- OAuth2.apply(config, _request)
188
- _response = execute_request(_request)
189
-
190
- # Return appropriate response type.
191
- decoded = APIHelper.json_deserialize(_response.raw_body)
192
- _errors = APIHelper.map_response(decoded, ['errors'])
193
- ApiResponse.new(
194
- _response, data: decoded, errors: _errors
195
- )
196
- end
197
-
198
- # Provides summary information for all of a business's employee roles.
199
- # @param [SortOrder] order Optional parameter: The order in which employees
200
- # are listed in the response, based on their created_at field.Default value:
201
- # ASC
202
- # @param [Integer] limit Optional parameter: The maximum integer number of
203
- # employee entities to return in a single response. Default 100, maximum
204
- # 200.
205
- # @param [String] batch_token Optional parameter: A pagination cursor to
206
- # retrieve the next set of results for your original query to the
207
- # endpoint.
208
- # @return [List of V1EmployeeRole Hash] response from the API call
209
- def list_employee_roles(order: nil,
210
- limit: nil,
211
- batch_token: nil)
212
- # Prepare query url.
213
- _query_builder = config.get_base_uri
214
- _query_builder << '/v1/me/roles'
215
- _query_builder = APIHelper.append_url_with_query_parameters(
216
- _query_builder,
217
- 'order' => order,
218
- 'limit' => limit,
219
- 'batch_token' => batch_token
220
- )
221
- _query_url = APIHelper.clean_url _query_builder
222
-
223
- # Prepare headers.
224
- _headers = {
225
- 'accept' => 'application/json'
226
- }
227
-
228
- # Prepare and execute HttpRequest.
229
- _request = config.http_client.get(
230
- _query_url,
231
- headers: _headers
232
- )
233
- OAuth2.apply(config, _request)
234
- _response = execute_request(_request)
235
-
236
- # Return appropriate response type.
237
- decoded = APIHelper.json_deserialize(_response.raw_body)
238
- _errors = APIHelper.map_response(decoded, ['errors'])
239
- ApiResponse.new(
240
- _response, data: decoded, errors: _errors
241
- )
242
- end
243
-
244
- # Creates an employee role you can then assign to employees.
245
- # Square accounts can include any number of roles that can be assigned to
246
- # employees. These roles define the actions and permissions granted to an
247
- # employee with that role. For example, an employee with a "Shift Manager"
248
- # role might be able to issue refunds in Square Point of Sale, whereas an
249
- # employee with a "Clerk" role might not.
250
- # Roles are assigned with the [V1UpdateEmployee](#endpoint-v1updateemployee)
251
- # endpoint. An employee can have only one role at a time.
252
- # If an employee has no role, they have none of the permissions associated
253
- # with roles. All employees can accept payments with Square Point of Sale.
254
- # @param [V1EmployeeRole] body Required parameter: An EmployeeRole object
255
- # with a name and permissions, and an optional owner flag.
256
- # @return [V1EmployeeRole Hash] response from the API call
257
- def create_employee_role(body:)
258
- # Prepare query url.
259
- _query_builder = config.get_base_uri
260
- _query_builder << '/v1/me/roles'
261
- _query_url = APIHelper.clean_url _query_builder
262
-
263
- # Prepare headers.
264
- _headers = {
265
- 'accept' => 'application/json',
266
- 'content-type' => 'application/json; charset=utf-8'
267
- }
268
-
269
- # Prepare and execute HttpRequest.
270
- _request = config.http_client.post(
271
- _query_url,
272
- headers: _headers,
273
- parameters: body.to_json
274
- )
275
- OAuth2.apply(config, _request)
276
- _response = execute_request(_request)
277
-
278
- # Return appropriate response type.
279
- decoded = APIHelper.json_deserialize(_response.raw_body)
280
- _errors = APIHelper.map_response(decoded, ['errors'])
281
- ApiResponse.new(
282
- _response, data: decoded, errors: _errors
283
- )
284
- end
285
-
286
- # Provides the details for a single employee role.
287
- # @param [String] role_id Required parameter: The role's ID.
288
- # @return [V1EmployeeRole Hash] response from the API call
289
- def retrieve_employee_role(role_id:)
290
- # Prepare query url.
291
- _query_builder = config.get_base_uri
292
- _query_builder << '/v1/me/roles/{role_id}'
293
- _query_builder = APIHelper.append_url_with_template_parameters(
294
- _query_builder,
295
- 'role_id' => { 'value' => role_id, 'encode' => true }
296
- )
297
- _query_url = APIHelper.clean_url _query_builder
298
-
299
- # Prepare headers.
300
- _headers = {
301
- 'accept' => 'application/json'
302
- }
303
-
304
- # Prepare and execute HttpRequest.
305
- _request = config.http_client.get(
306
- _query_url,
307
- headers: _headers
308
- )
309
- OAuth2.apply(config, _request)
310
- _response = execute_request(_request)
311
-
312
- # Return appropriate response type.
313
- decoded = APIHelper.json_deserialize(_response.raw_body)
314
- _errors = APIHelper.map_response(decoded, ['errors'])
315
- ApiResponse.new(
316
- _response, data: decoded, errors: _errors
317
- )
318
- end
319
-
320
- # Modifies the details of an employee role.
321
- # @param [String] role_id Required parameter: The ID of the role to
322
- # modify.
323
- # @param [V1EmployeeRole] body Required parameter: An object containing the
324
- # fields to POST for the request. See the corresponding object definition
325
- # for field details.
326
- # @return [V1EmployeeRole Hash] response from the API call
327
- def update_employee_role(role_id:,
328
- body:)
329
- # Prepare query url.
330
- _query_builder = config.get_base_uri
331
- _query_builder << '/v1/me/roles/{role_id}'
332
- _query_builder = APIHelper.append_url_with_template_parameters(
333
- _query_builder,
334
- 'role_id' => { 'value' => role_id, 'encode' => true }
335
- )
336
- _query_url = APIHelper.clean_url _query_builder
337
-
338
- # Prepare headers.
339
- _headers = {
340
- 'accept' => 'application/json',
341
- 'content-type' => 'application/json; charset=utf-8'
342
- }
343
-
344
- # Prepare and execute HttpRequest.
345
- _request = config.http_client.put(
346
- _query_url,
347
- headers: _headers,
348
- parameters: body.to_json
349
- )
350
- OAuth2.apply(config, _request)
351
- _response = execute_request(_request)
352
-
353
- # Return appropriate response type.
354
- decoded = APIHelper.json_deserialize(_response.raw_body)
355
- _errors = APIHelper.map_response(decoded, ['errors'])
356
- ApiResponse.new(
357
- _response, data: decoded, errors: _errors
358
- )
359
- end
360
-
361
- # Provides summary information for all of a business's employee timecards.
362
- # @param [SortOrder] order Optional parameter: The order in which timecards
363
- # are listed in the response, based on their created_at field.
364
- # @param [String] employee_id Optional parameter: If provided, the endpoint
365
- # returns only timecards for the employee with the specified ID.
366
- # @param [String] begin_clockin_time Optional parameter: If filtering
367
- # results by their clockin_time field, the beginning of the requested
368
- # reporting period, in ISO 8601 format.
369
- # @param [String] end_clockin_time Optional parameter: If filtering results
370
- # by their clockin_time field, the end of the requested reporting period, in
371
- # ISO 8601 format.
372
- # @param [String] begin_clockout_time Optional parameter: If filtering
373
- # results by their clockout_time field, the beginning of the requested
374
- # reporting period, in ISO 8601 format.
375
- # @param [String] end_clockout_time Optional parameter: If filtering results
376
- # by their clockout_time field, the end of the requested reporting period,
377
- # in ISO 8601 format.
378
- # @param [String] begin_updated_at Optional parameter: If filtering results
379
- # by their updated_at field, the beginning of the requested reporting
380
- # period, in ISO 8601 format.
381
- # @param [String] end_updated_at Optional parameter: If filtering results by
382
- # their updated_at field, the end of the requested reporting period, in ISO
383
- # 8601 format.
384
- # @param [Boolean] deleted Optional parameter: If true, only deleted
385
- # timecards are returned. If false, only valid timecards are returned.If you
386
- # don't provide this parameter, both valid and deleted timecards are
387
- # returned.
388
- # @param [Integer] limit Optional parameter: The maximum integer number of
389
- # employee entities to return in a single response. Default 100, maximum
390
- # 200.
391
- # @param [String] batch_token Optional parameter: A pagination cursor to
392
- # retrieve the next set of results for your original query to the
393
- # endpoint.
394
- # @return [List of V1Timecard Hash] response from the API call
395
- def list_timecards(order: nil,
396
- employee_id: nil,
397
- begin_clockin_time: nil,
398
- end_clockin_time: nil,
399
- begin_clockout_time: nil,
400
- end_clockout_time: nil,
401
- begin_updated_at: nil,
402
- end_updated_at: nil,
403
- deleted: false,
404
- limit: nil,
405
- batch_token: nil)
406
- warn 'Endpoint list_timecards in V1EmployeesApi is deprecated'
407
- # Prepare query url.
408
- _query_builder = config.get_base_uri
409
- _query_builder << '/v1/me/timecards'
410
- _query_builder = APIHelper.append_url_with_query_parameters(
411
- _query_builder,
412
- 'order' => order,
413
- 'employee_id' => employee_id,
414
- 'begin_clockin_time' => begin_clockin_time,
415
- 'end_clockin_time' => end_clockin_time,
416
- 'begin_clockout_time' => begin_clockout_time,
417
- 'end_clockout_time' => end_clockout_time,
418
- 'begin_updated_at' => begin_updated_at,
419
- 'end_updated_at' => end_updated_at,
420
- 'deleted' => deleted,
421
- 'limit' => limit,
422
- 'batch_token' => batch_token
423
- )
424
- _query_url = APIHelper.clean_url _query_builder
425
-
426
- # Prepare headers.
427
- _headers = {
428
- 'accept' => 'application/json'
429
- }
430
-
431
- # Prepare and execute HttpRequest.
432
- _request = config.http_client.get(
433
- _query_url,
434
- headers: _headers
435
- )
436
- OAuth2.apply(config, _request)
437
- _response = execute_request(_request)
438
-
439
- # Return appropriate response type.
440
- decoded = APIHelper.json_deserialize(_response.raw_body)
441
- _errors = APIHelper.map_response(decoded, ['errors'])
442
- ApiResponse.new(
443
- _response, data: decoded, errors: _errors
444
- )
445
- end
446
-
447
- # Creates a timecard for an employee and clocks them in with an
448
- # `API_CREATE` event and a `clockin_time` set to the current time unless
449
- # the request provides a different value.
450
- # To import timecards from another
451
- # system (rather than clocking someone in). Specify the `clockin_time`
452
- # and* `clockout_time` in the request.
453
- # Timecards correspond to exactly one shift for a given employee, bounded
454
- # by the `clockin_time` and `clockout_time` fields. An employee is
455
- # considered clocked in if they have a timecard that doesn't have a
456
- # `clockout_time` set. An employee that is currently clocked in cannot
457
- # be clocked in a second time.
458
- # @param [V1Timecard] body Required parameter: An object containing the
459
- # fields to POST for the request. See the corresponding object definition
460
- # for field details.
461
- # @return [V1Timecard Hash] response from the API call
462
- def create_timecard(body:)
463
- warn 'Endpoint create_timecard in V1EmployeesApi is deprecated'
464
- # Prepare query url.
465
- _query_builder = config.get_base_uri
466
- _query_builder << '/v1/me/timecards'
467
- _query_url = APIHelper.clean_url _query_builder
468
-
469
- # Prepare headers.
470
- _headers = {
471
- 'accept' => 'application/json',
472
- 'content-type' => 'application/json; charset=utf-8'
473
- }
474
-
475
- # Prepare and execute HttpRequest.
476
- _request = config.http_client.post(
477
- _query_url,
478
- headers: _headers,
479
- parameters: body.to_json
480
- )
481
- OAuth2.apply(config, _request)
482
- _response = execute_request(_request)
483
-
484
- # Return appropriate response type.
485
- decoded = APIHelper.json_deserialize(_response.raw_body)
486
- _errors = APIHelper.map_response(decoded, ['errors'])
487
- ApiResponse.new(
488
- _response, data: decoded, errors: _errors
489
- )
490
- end
491
-
492
- # Deletes a timecard. Timecards can also be deleted through the
493
- # Square Dashboard. Deleted timecards are still accessible through
494
- # Connect API endpoints, but cannot be modified. The `deleted` field of
495
- # the `Timecard` object indicates whether the timecard has been deleted.
496
- # __Note__: By default, deleted timecards appear alongside valid timecards
497
- # in
498
- # results returned by the
499
- # [ListTimecards](#endpoint-v1employees-listtimecards)
500
- # endpoint. To filter deleted timecards, include the `deleted` query
501
- # parameter in the list request.
502
- # Only approved accounts can manage their employees with Square.
503
- # Unapproved accounts cannot use employee management features with the
504
- # API.
505
- # @param [String] timecard_id Required parameter: The ID of the timecard to
506
- # delete.
507
- # @return [Object] response from the API call
508
- def delete_timecard(timecard_id:)
509
- warn 'Endpoint delete_timecard in V1EmployeesApi is deprecated'
510
- # Prepare query url.
511
- _query_builder = config.get_base_uri
512
- _query_builder << '/v1/me/timecards/{timecard_id}'
513
- _query_builder = APIHelper.append_url_with_template_parameters(
514
- _query_builder,
515
- 'timecard_id' => { 'value' => timecard_id, 'encode' => true }
516
- )
517
- _query_url = APIHelper.clean_url _query_builder
518
-
519
- # Prepare and execute HttpRequest.
520
- _request = config.http_client.delete(
521
- _query_url
522
- )
523
- OAuth2.apply(config, _request)
524
- _response = execute_request(_request)
525
-
526
- # Return appropriate response type.
527
- ApiResponse.new(
528
- _response, data: _response.raw_body
529
- )
530
- end
531
-
532
- # Provides the details for a single timecard.
533
- # <aside>
534
- # Only approved accounts can manage their employees with Square.
535
- # Unapproved accounts cannot use employee management features with the
536
- # API.
537
- # </aside>
538
- # @param [String] timecard_id Required parameter: The timecard's ID.
539
- # @return [V1Timecard Hash] response from the API call
540
- def retrieve_timecard(timecard_id:)
541
- warn 'Endpoint retrieve_timecard in V1EmployeesApi is deprecated'
542
- # Prepare query url.
543
- _query_builder = config.get_base_uri
544
- _query_builder << '/v1/me/timecards/{timecard_id}'
545
- _query_builder = APIHelper.append_url_with_template_parameters(
546
- _query_builder,
547
- 'timecard_id' => { 'value' => timecard_id, 'encode' => true }
548
- )
549
- _query_url = APIHelper.clean_url _query_builder
550
-
551
- # Prepare headers.
552
- _headers = {
553
- 'accept' => 'application/json'
554
- }
555
-
556
- # Prepare and execute HttpRequest.
557
- _request = config.http_client.get(
558
- _query_url,
559
- headers: _headers
560
- )
561
- OAuth2.apply(config, _request)
562
- _response = execute_request(_request)
563
-
564
- # Return appropriate response type.
565
- decoded = APIHelper.json_deserialize(_response.raw_body)
566
- _errors = APIHelper.map_response(decoded, ['errors'])
567
- ApiResponse.new(
568
- _response, data: decoded, errors: _errors
569
- )
570
- end
571
-
572
- # Modifies the details of a timecard with an `API_EDIT` event for
573
- # the timecard. Updating an active timecard with a `clockout_time`
574
- # clocks the employee out.
575
- # @param [String] timecard_id Required parameter: TThe ID of the timecard to
576
- # modify.
577
- # @param [V1Timecard] body Required parameter: An object containing the
578
- # fields to POST for the request. See the corresponding object definition
579
- # for field details.
580
- # @return [V1Timecard Hash] response from the API call
581
- def update_timecard(timecard_id:,
582
- body:)
583
- warn 'Endpoint update_timecard in V1EmployeesApi is deprecated'
584
- # Prepare query url.
585
- _query_builder = config.get_base_uri
586
- _query_builder << '/v1/me/timecards/{timecard_id}'
587
- _query_builder = APIHelper.append_url_with_template_parameters(
588
- _query_builder,
589
- 'timecard_id' => { 'value' => timecard_id, 'encode' => true }
590
- )
591
- _query_url = APIHelper.clean_url _query_builder
592
-
593
- # Prepare headers.
594
- _headers = {
595
- 'accept' => 'application/json',
596
- 'content-type' => 'application/json; charset=utf-8'
597
- }
598
-
599
- # Prepare and execute HttpRequest.
600
- _request = config.http_client.put(
601
- _query_url,
602
- headers: _headers,
603
- parameters: body.to_json
604
- )
605
- OAuth2.apply(config, _request)
606
- _response = execute_request(_request)
607
-
608
- # Return appropriate response type.
609
- decoded = APIHelper.json_deserialize(_response.raw_body)
610
- _errors = APIHelper.map_response(decoded, ['errors'])
611
- ApiResponse.new(
612
- _response, data: decoded, errors: _errors
613
- )
614
- end
615
-
616
- # Provides summary information for all events associated with a
617
- # particular timecard.
618
- # Only approved accounts can manage their employees with Square.
619
- # Unapproved accounts cannot use employee management features with the
620
- # API.
621
- # @param [String] timecard_id Required parameter: The ID of the timecard to
622
- # list events for.
623
- # @return [List of V1TimecardEvent Hash] response from the API call
624
- def list_timecard_events(timecard_id:)
625
- warn 'Endpoint list_timecard_events in V1EmployeesApi is deprecated'
626
- # Prepare query url.
627
- _query_builder = config.get_base_uri
628
- _query_builder << '/v1/me/timecards/{timecard_id}/events'
629
- _query_builder = APIHelper.append_url_with_template_parameters(
630
- _query_builder,
631
- 'timecard_id' => { 'value' => timecard_id, 'encode' => true }
632
- )
633
- _query_url = APIHelper.clean_url _query_builder
634
-
635
- # Prepare headers.
636
- _headers = {
637
- 'accept' => 'application/json'
638
- }
639
-
640
- # Prepare and execute HttpRequest.
641
- _request = config.http_client.get(
642
- _query_url,
643
- headers: _headers
644
- )
645
- OAuth2.apply(config, _request)
646
- _response = execute_request(_request)
647
-
648
- # Return appropriate response type.
649
- decoded = APIHelper.json_deserialize(_response.raw_body)
650
- _errors = APIHelper.map_response(decoded, ['errors'])
651
- ApiResponse.new(
652
- _response, data: decoded, errors: _errors
653
- )
654
- end
655
-
656
- # Provides the details for all of a location's cash drawer shifts during a
657
- # date range. The date range you specify cannot exceed 90 days.
658
- # @param [String] location_id Required parameter: The ID of the location to
659
- # list cash drawer shifts for.
660
- # @param [SortOrder] order Optional parameter: The order in which cash
661
- # drawer shifts are listed in the response, based on their created_at field.
662
- # Default value: ASC
663
- # @param [String] begin_time Optional parameter: The beginning of the
664
- # requested reporting period, in ISO 8601 format. Default value: The current
665
- # time minus 90 days.
666
- # @param [String] end_time Optional parameter: The beginning of the
667
- # requested reporting period, in ISO 8601 format. Default value: The current
668
- # time.
669
- # @return [List of V1CashDrawerShift Hash] response from the API call
670
- def list_cash_drawer_shifts(location_id:,
671
- order: nil,
672
- begin_time: nil,
673
- end_time: nil)
674
- warn 'Endpoint list_cash_drawer_shifts in V1EmployeesApi is deprecated'
675
- # Prepare query url.
676
- _query_builder = config.get_base_uri
677
- _query_builder << '/v1/{location_id}/cash-drawer-shifts'
678
- _query_builder = APIHelper.append_url_with_template_parameters(
679
- _query_builder,
680
- 'location_id' => { 'value' => location_id, 'encode' => true }
681
- )
682
- _query_builder = APIHelper.append_url_with_query_parameters(
683
- _query_builder,
684
- 'order' => order,
685
- 'begin_time' => begin_time,
686
- 'end_time' => end_time
687
- )
688
- _query_url = APIHelper.clean_url _query_builder
689
-
690
- # Prepare headers.
691
- _headers = {
692
- 'accept' => 'application/json'
693
- }
694
-
695
- # Prepare and execute HttpRequest.
696
- _request = config.http_client.get(
697
- _query_url,
698
- headers: _headers
699
- )
700
- OAuth2.apply(config, _request)
701
- _response = execute_request(_request)
702
-
703
- # Return appropriate response type.
704
- decoded = APIHelper.json_deserialize(_response.raw_body)
705
- _errors = APIHelper.map_response(decoded, ['errors'])
706
- ApiResponse.new(
707
- _response, data: decoded, errors: _errors
708
- )
709
- end
710
-
711
- # Provides the details for a single cash drawer shift, including all events
712
- # that occurred during the shift.
713
- # @param [String] location_id Required parameter: The ID of the location to
714
- # list cash drawer shifts for.
715
- # @param [String] shift_id Required parameter: The shift's ID.
716
- # @return [V1CashDrawerShift Hash] response from the API call
717
- def retrieve_cash_drawer_shift(location_id:,
718
- shift_id:)
719
- warn 'Endpoint retrieve_cash_drawer_shift in V1EmployeesApi is deprecated'
720
- # Prepare query url.
721
- _query_builder = config.get_base_uri
722
- _query_builder << '/v1/{location_id}/cash-drawer-shifts/{shift_id}'
723
- _query_builder = APIHelper.append_url_with_template_parameters(
724
- _query_builder,
725
- 'location_id' => { 'value' => location_id, 'encode' => true },
726
- 'shift_id' => { 'value' => shift_id, 'encode' => true }
727
- )
728
- _query_url = APIHelper.clean_url _query_builder
729
-
730
- # Prepare headers.
731
- _headers = {
732
- 'accept' => 'application/json'
733
- }
734
-
735
- # Prepare and execute HttpRequest.
736
- _request = config.http_client.get(
737
- _query_url,
738
- headers: _headers
739
- )
740
- OAuth2.apply(config, _request)
741
- _response = execute_request(_request)
742
-
743
- # Return appropriate response type.
744
- decoded = APIHelper.json_deserialize(_response.raw_body)
745
- _errors = APIHelper.map_response(decoded, ['errors'])
746
- ApiResponse.new(
747
- _response, data: decoded, errors: _errors
748
- )
749
- end
750
- end
751
- end