square.rb 3.20190814.0 → 3.20190925.0

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