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,558 +1,558 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # LaborApi
8
- class LaborApi < BaseApi
9
- def initialize(config, http_call_back: nil)
10
- super(config, http_call_back: http_call_back)
11
- end
12
-
13
- # Returns a paginated list of `BreakType` instances for a business.
14
- # @param [String] location_id Optional parameter: Filter Break Types
15
- # returned to only those that are associated with the specified location.
16
- # @param [Integer] limit Optional parameter: Maximum number of Break Types
17
- # to return per page. Can range between 1 and 200. The default is the
18
- # maximum at 200.
19
- # @param [String] cursor Optional parameter: Pointer to the next page of
20
- # Break Type results to fetch.
21
- # @return [ListBreakTypesResponse Hash] response from the API call
22
- def list_break_types(location_id: nil,
23
- limit: nil,
24
- cursor: nil)
25
- # Prepare query url.
26
- _query_builder = config.get_base_uri
27
- _query_builder << '/v2/labor/break-types'
28
- _query_builder = APIHelper.append_url_with_query_parameters(
29
- _query_builder,
30
- 'location_id' => location_id,
31
- 'limit' => limit,
32
- 'cursor' => cursor
33
- )
34
- _query_url = APIHelper.clean_url _query_builder
35
-
36
- # Prepare headers.
37
- _headers = {
38
- 'accept' => 'application/json'
39
- }
40
-
41
- # Prepare and execute HttpRequest.
42
- _request = config.http_client.get(
43
- _query_url,
44
- headers: _headers
45
- )
46
- OAuth2.apply(config, _request)
47
- _response = execute_request(_request)
48
-
49
- # Return appropriate response type.
50
- decoded = APIHelper.json_deserialize(_response.raw_body)
51
- _errors = APIHelper.map_response(decoded, ['errors'])
52
- ApiResponse.new(_response, data: decoded, errors: _errors)
53
- end
54
-
55
- # Creates a new `BreakType`.
56
- # A `BreakType` is a template for creating `Break` objects.
57
- # You must provide the following values in your request to this
58
- # endpoint:
59
- # - `location_id`
60
- # - `break_name`
61
- # - `expected_duration`
62
- # - `is_paid`
63
- # You can only have 3 `BreakType` instances per location. If you attempt to
64
- # add a 4th
65
- # `BreakType` for a location, an `INVALID_REQUEST_ERROR` "Exceeded limit of
66
- # 3 breaks per location."
67
- # is returned.
68
- # @param [CreateBreakTypeRequest] body Required parameter: An object
69
- # containing the fields to POST for the request. See the corresponding
70
- # object definition for field details.
71
- # @return [CreateBreakTypeResponse Hash] response from the API call
72
- def create_break_type(body:)
73
- # Prepare query url.
74
- _query_builder = config.get_base_uri
75
- _query_builder << '/v2/labor/break-types'
76
- _query_url = APIHelper.clean_url _query_builder
77
-
78
- # Prepare headers.
79
- _headers = {
80
- 'accept' => 'application/json',
81
- 'content-type' => 'application/json; charset=utf-8'
82
- }
83
-
84
- # Prepare and execute HttpRequest.
85
- _request = config.http_client.post(
86
- _query_url,
87
- headers: _headers,
88
- parameters: body.to_json
89
- )
90
- OAuth2.apply(config, _request)
91
- _response = execute_request(_request)
92
-
93
- # Return appropriate response type.
94
- decoded = APIHelper.json_deserialize(_response.raw_body)
95
- _errors = APIHelper.map_response(decoded, ['errors'])
96
- ApiResponse.new(_response, data: decoded, errors: _errors)
97
- end
98
-
99
- # Deletes an existing `BreakType`.
100
- # A `BreakType` can be deleted even if it is referenced from a `Shift`.
101
- # @param [String] id Required parameter: UUID for the `BreakType` being
102
- # deleted.
103
- # @return [DeleteBreakTypeResponse Hash] response from the API call
104
- def delete_break_type(id:)
105
- # Prepare query url.
106
- _query_builder = config.get_base_uri
107
- _query_builder << '/v2/labor/break-types/{id}'
108
- _query_builder = APIHelper.append_url_with_template_parameters(
109
- _query_builder,
110
- 'id' => id
111
- )
112
- _query_url = APIHelper.clean_url _query_builder
113
-
114
- # Prepare headers.
115
- _headers = {
116
- 'accept' => 'application/json'
117
- }
118
-
119
- # Prepare and execute HttpRequest.
120
- _request = config.http_client.delete(
121
- _query_url,
122
- headers: _headers
123
- )
124
- OAuth2.apply(config, _request)
125
- _response = execute_request(_request)
126
-
127
- # Return appropriate response type.
128
- decoded = APIHelper.json_deserialize(_response.raw_body)
129
- _errors = APIHelper.map_response(decoded, ['errors'])
130
- ApiResponse.new(_response, data: decoded, errors: _errors)
131
- end
132
-
133
- # Returns a single `BreakType` specified by id.
134
- # @param [String] id Required parameter: UUID for the `BreakType` being
135
- # retrieved.
136
- # @return [GetBreakTypeResponse Hash] response from the API call
137
- def get_break_type(id:)
138
- # Prepare query url.
139
- _query_builder = config.get_base_uri
140
- _query_builder << '/v2/labor/break-types/{id}'
141
- _query_builder = APIHelper.append_url_with_template_parameters(
142
- _query_builder,
143
- 'id' => id
144
- )
145
- _query_url = APIHelper.clean_url _query_builder
146
-
147
- # Prepare headers.
148
- _headers = {
149
- 'accept' => 'application/json'
150
- }
151
-
152
- # Prepare and execute HttpRequest.
153
- _request = config.http_client.get(
154
- _query_url,
155
- headers: _headers
156
- )
157
- OAuth2.apply(config, _request)
158
- _response = execute_request(_request)
159
-
160
- # Return appropriate response type.
161
- decoded = APIHelper.json_deserialize(_response.raw_body)
162
- _errors = APIHelper.map_response(decoded, ['errors'])
163
- ApiResponse.new(_response, data: decoded, errors: _errors)
164
- end
165
-
166
- # Updates an existing `BreakType`.
167
- # @param [String] id Required parameter: UUID for the `BreakType` being
168
- # updated.
169
- # @param [UpdateBreakTypeRequest] body Required parameter: An object
170
- # containing the fields to POST for the request. See the corresponding
171
- # object definition for field details.
172
- # @return [UpdateBreakTypeResponse Hash] response from the API call
173
- def update_break_type(id:,
174
- body:)
175
- # Prepare query url.
176
- _query_builder = config.get_base_uri
177
- _query_builder << '/v2/labor/break-types/{id}'
178
- _query_builder = APIHelper.append_url_with_template_parameters(
179
- _query_builder,
180
- 'id' => id
181
- )
182
- _query_url = APIHelper.clean_url _query_builder
183
-
184
- # Prepare headers.
185
- _headers = {
186
- 'accept' => 'application/json',
187
- 'content-type' => 'application/json; charset=utf-8'
188
- }
189
-
190
- # Prepare and execute HttpRequest.
191
- _request = config.http_client.put(
192
- _query_url,
193
- headers: _headers,
194
- parameters: body.to_json
195
- )
196
- OAuth2.apply(config, _request)
197
- _response = execute_request(_request)
198
-
199
- # Return appropriate response type.
200
- decoded = APIHelper.json_deserialize(_response.raw_body)
201
- _errors = APIHelper.map_response(decoded, ['errors'])
202
- ApiResponse.new(_response, data: decoded, errors: _errors)
203
- end
204
-
205
- # Returns a paginated list of `EmployeeWage` instances for a business.
206
- # @param [String] employee_id Optional parameter: Filter wages returned to
207
- # only those that are associated with the specified employee.
208
- # @param [Integer] limit Optional parameter: Maximum number of Employee
209
- # Wages to return per page. Can range between 1 and 200. The default is the
210
- # maximum at 200.
211
- # @param [String] cursor Optional parameter: Pointer to the next page of
212
- # Employee Wage results to fetch.
213
- # @return [ListEmployeeWagesResponse Hash] response from the API call
214
- def list_employee_wages(employee_id: nil,
215
- limit: nil,
216
- cursor: nil)
217
- # Prepare query url.
218
- _query_builder = config.get_base_uri
219
- _query_builder << '/v2/labor/employee-wages'
220
- _query_builder = APIHelper.append_url_with_query_parameters(
221
- _query_builder,
222
- 'employee_id' => employee_id,
223
- 'limit' => limit,
224
- 'cursor' => cursor
225
- )
226
- _query_url = APIHelper.clean_url _query_builder
227
-
228
- # Prepare headers.
229
- _headers = {
230
- 'accept' => 'application/json'
231
- }
232
-
233
- # Prepare and execute HttpRequest.
234
- _request = config.http_client.get(
235
- _query_url,
236
- headers: _headers
237
- )
238
- OAuth2.apply(config, _request)
239
- _response = execute_request(_request)
240
-
241
- # Return appropriate response type.
242
- decoded = APIHelper.json_deserialize(_response.raw_body)
243
- _errors = APIHelper.map_response(decoded, ['errors'])
244
- ApiResponse.new(_response, data: decoded, errors: _errors)
245
- end
246
-
247
- # Returns a single `EmployeeWage` specified by id.
248
- # @param [String] id Required parameter: UUID for the `EmployeeWage` being
249
- # retrieved.
250
- # @return [GetEmployeeWageResponse Hash] response from the API call
251
- def get_employee_wage(id:)
252
- # Prepare query url.
253
- _query_builder = config.get_base_uri
254
- _query_builder << '/v2/labor/employee-wages/{id}'
255
- _query_builder = APIHelper.append_url_with_template_parameters(
256
- _query_builder,
257
- 'id' => id
258
- )
259
- _query_url = APIHelper.clean_url _query_builder
260
-
261
- # Prepare headers.
262
- _headers = {
263
- 'accept' => 'application/json'
264
- }
265
-
266
- # Prepare and execute HttpRequest.
267
- _request = config.http_client.get(
268
- _query_url,
269
- headers: _headers
270
- )
271
- OAuth2.apply(config, _request)
272
- _response = execute_request(_request)
273
-
274
- # Return appropriate response type.
275
- decoded = APIHelper.json_deserialize(_response.raw_body)
276
- _errors = APIHelper.map_response(decoded, ['errors'])
277
- ApiResponse.new(_response, data: decoded, errors: _errors)
278
- end
279
-
280
- # Creates a new `Shift`.
281
- # A `Shift` represents a complete work day for a single employee.
282
- # You must provide the following values in your request to this
283
- # endpoint:
284
- # - `location_id`
285
- # - `employee_id`
286
- # - `start_at`
287
- # An attempt to create a new `Shift` can result in a `BAD_REQUEST` error
288
- # when:
289
- # - The `status` of the new `Shift` is `OPEN` and the employee has another
290
- # shift with an `OPEN` status.
291
- # - The `start_at` date is in the future
292
- # - the `start_at` or `end_at` overlaps another shift for the same employee
293
- # - If `Break`s are set in the request, a break `start_at`
294
- # must not be before the `Shift.start_at`. A break `end_at` must not be
295
- # after
296
- # the `Shift.end_at`
297
- # @param [CreateShiftRequest] body Required parameter: An object containing
298
- # the fields to POST for the request. See the corresponding object
299
- # definition for field details.
300
- # @return [CreateShiftResponse Hash] response from the API call
301
- def create_shift(body:)
302
- # Prepare query url.
303
- _query_builder = config.get_base_uri
304
- _query_builder << '/v2/labor/shifts'
305
- _query_url = APIHelper.clean_url _query_builder
306
-
307
- # Prepare headers.
308
- _headers = {
309
- 'accept' => 'application/json',
310
- 'content-type' => 'application/json; charset=utf-8'
311
- }
312
-
313
- # Prepare and execute HttpRequest.
314
- _request = config.http_client.post(
315
- _query_url,
316
- headers: _headers,
317
- parameters: body.to_json
318
- )
319
- OAuth2.apply(config, _request)
320
- _response = execute_request(_request)
321
-
322
- # Return appropriate response type.
323
- decoded = APIHelper.json_deserialize(_response.raw_body)
324
- _errors = APIHelper.map_response(decoded, ['errors'])
325
- ApiResponse.new(_response, data: decoded, errors: _errors)
326
- end
327
-
328
- # Returns a paginated list of `Shift` records for a business.
329
- # The list to be returned can be filtered by:
330
- # - Location IDs **and**
331
- # - employee IDs **and**
332
- # - shift status (`OPEN`, `CLOSED`) **and**
333
- # - shift start **and**
334
- # - shift end **and**
335
- # - work day details
336
- # The list can be sorted by:
337
- # - `start_at`
338
- # - `end_at`
339
- # - `created_at`
340
- # - `updated_at`
341
- # @param [SearchShiftsRequest] body Required parameter: An object containing
342
- # the fields to POST for the request. See the corresponding object
343
- # definition for field details.
344
- # @return [SearchShiftsResponse Hash] response from the API call
345
- def search_shifts(body:)
346
- # Prepare query url.
347
- _query_builder = config.get_base_uri
348
- _query_builder << '/v2/labor/shifts/search'
349
- _query_url = APIHelper.clean_url _query_builder
350
-
351
- # Prepare headers.
352
- _headers = {
353
- 'accept' => 'application/json',
354
- 'content-type' => 'application/json; charset=utf-8'
355
- }
356
-
357
- # Prepare and execute HttpRequest.
358
- _request = config.http_client.post(
359
- _query_url,
360
- headers: _headers,
361
- parameters: body.to_json
362
- )
363
- OAuth2.apply(config, _request)
364
- _response = execute_request(_request)
365
-
366
- # Return appropriate response type.
367
- decoded = APIHelper.json_deserialize(_response.raw_body)
368
- _errors = APIHelper.map_response(decoded, ['errors'])
369
- ApiResponse.new(_response, data: decoded, errors: _errors)
370
- end
371
-
372
- # Deletes a `Shift`.
373
- # @param [String] id Required parameter: UUID for the `Shift` being
374
- # deleted.
375
- # @return [DeleteShiftResponse Hash] response from the API call
376
- def delete_shift(id:)
377
- # Prepare query url.
378
- _query_builder = config.get_base_uri
379
- _query_builder << '/v2/labor/shifts/{id}'
380
- _query_builder = APIHelper.append_url_with_template_parameters(
381
- _query_builder,
382
- 'id' => id
383
- )
384
- _query_url = APIHelper.clean_url _query_builder
385
-
386
- # Prepare headers.
387
- _headers = {
388
- 'accept' => 'application/json'
389
- }
390
-
391
- # Prepare and execute HttpRequest.
392
- _request = config.http_client.delete(
393
- _query_url,
394
- headers: _headers
395
- )
396
- OAuth2.apply(config, _request)
397
- _response = execute_request(_request)
398
-
399
- # Return appropriate response type.
400
- decoded = APIHelper.json_deserialize(_response.raw_body)
401
- _errors = APIHelper.map_response(decoded, ['errors'])
402
- ApiResponse.new(_response, data: decoded, errors: _errors)
403
- end
404
-
405
- # Returns a single `Shift` specified by id.
406
- # @param [String] id Required parameter: UUID for the `Shift` being
407
- # retrieved.
408
- # @return [GetShiftResponse Hash] response from the API call
409
- def get_shift(id:)
410
- # Prepare query url.
411
- _query_builder = config.get_base_uri
412
- _query_builder << '/v2/labor/shifts/{id}'
413
- _query_builder = APIHelper.append_url_with_template_parameters(
414
- _query_builder,
415
- 'id' => id
416
- )
417
- _query_url = APIHelper.clean_url _query_builder
418
-
419
- # Prepare headers.
420
- _headers = {
421
- 'accept' => 'application/json'
422
- }
423
-
424
- # Prepare and execute HttpRequest.
425
- _request = config.http_client.get(
426
- _query_url,
427
- headers: _headers
428
- )
429
- OAuth2.apply(config, _request)
430
- _response = execute_request(_request)
431
-
432
- # Return appropriate response type.
433
- decoded = APIHelper.json_deserialize(_response.raw_body)
434
- _errors = APIHelper.map_response(decoded, ['errors'])
435
- ApiResponse.new(_response, data: decoded, errors: _errors)
436
- end
437
-
438
- # Updates an existing `Shift`.
439
- # When adding a `Break` to a `Shift`, any earlier `Breaks` in the `Shift`
440
- # have
441
- # the `end_at` property set to a valid RFC-3339 datetime string.
442
- # When closing a `Shift`, all `Break` instances in the shift must be
443
- # complete with `end_at`
444
- # set on each `Break`.
445
- # @param [String] id Required parameter: ID of the object being updated.
446
- # @param [UpdateShiftRequest] body Required parameter: An object containing
447
- # the fields to POST for the request. See the corresponding object
448
- # definition for field details.
449
- # @return [UpdateShiftResponse Hash] response from the API call
450
- def update_shift(id:,
451
- body:)
452
- # Prepare query url.
453
- _query_builder = config.get_base_uri
454
- _query_builder << '/v2/labor/shifts/{id}'
455
- _query_builder = APIHelper.append_url_with_template_parameters(
456
- _query_builder,
457
- 'id' => id
458
- )
459
- _query_url = APIHelper.clean_url _query_builder
460
-
461
- # Prepare headers.
462
- _headers = {
463
- 'accept' => 'application/json',
464
- 'content-type' => 'application/json; charset=utf-8'
465
- }
466
-
467
- # Prepare and execute HttpRequest.
468
- _request = config.http_client.put(
469
- _query_url,
470
- headers: _headers,
471
- parameters: body.to_json
472
- )
473
- OAuth2.apply(config, _request)
474
- _response = execute_request(_request)
475
-
476
- # Return appropriate response type.
477
- decoded = APIHelper.json_deserialize(_response.raw_body)
478
- _errors = APIHelper.map_response(decoded, ['errors'])
479
- ApiResponse.new(_response, data: decoded, errors: _errors)
480
- end
481
-
482
- # Returns a list of `WorkweekConfig` instances for a business.
483
- # @param [Integer] limit Optional parameter: Maximum number of Workweek
484
- # Configs to return per page.
485
- # @param [String] cursor Optional parameter: Pointer to the next page of
486
- # Workweek Config results to fetch.
487
- # @return [ListWorkweekConfigsResponse Hash] response from the API call
488
- def list_workweek_configs(limit: nil,
489
- cursor: nil)
490
- # Prepare query url.
491
- _query_builder = config.get_base_uri
492
- _query_builder << '/v2/labor/workweek-configs'
493
- _query_builder = APIHelper.append_url_with_query_parameters(
494
- _query_builder,
495
- 'limit' => limit,
496
- 'cursor' => cursor
497
- )
498
- _query_url = APIHelper.clean_url _query_builder
499
-
500
- # Prepare headers.
501
- _headers = {
502
- 'accept' => 'application/json'
503
- }
504
-
505
- # Prepare and execute HttpRequest.
506
- _request = config.http_client.get(
507
- _query_url,
508
- headers: _headers
509
- )
510
- OAuth2.apply(config, _request)
511
- _response = execute_request(_request)
512
-
513
- # Return appropriate response type.
514
- decoded = APIHelper.json_deserialize(_response.raw_body)
515
- _errors = APIHelper.map_response(decoded, ['errors'])
516
- ApiResponse.new(_response, data: decoded, errors: _errors)
517
- end
518
-
519
- # Updates a `WorkweekConfig`.
520
- # @param [String] id Required parameter: UUID for the `WorkweekConfig`
521
- # object being updated.
522
- # @param [UpdateWorkweekConfigRequest] body Required parameter: An object
523
- # containing the fields to POST for the request. See the corresponding
524
- # object definition for field details.
525
- # @return [UpdateWorkweekConfigResponse Hash] response from the API call
526
- def update_workweek_config(id:,
527
- body:)
528
- # Prepare query url.
529
- _query_builder = config.get_base_uri
530
- _query_builder << '/v2/labor/workweek-configs/{id}'
531
- _query_builder = APIHelper.append_url_with_template_parameters(
532
- _query_builder,
533
- 'id' => id
534
- )
535
- _query_url = APIHelper.clean_url _query_builder
536
-
537
- # Prepare headers.
538
- _headers = {
539
- 'accept' => 'application/json',
540
- 'content-type' => 'application/json; charset=utf-8'
541
- }
542
-
543
- # Prepare and execute HttpRequest.
544
- _request = config.http_client.put(
545
- _query_url,
546
- headers: _headers,
547
- parameters: body.to_json
548
- )
549
- OAuth2.apply(config, _request)
550
- _response = execute_request(_request)
551
-
552
- # Return appropriate response type.
553
- decoded = APIHelper.json_deserialize(_response.raw_body)
554
- _errors = APIHelper.map_response(decoded, ['errors'])
555
- ApiResponse.new(_response, data: decoded, errors: _errors)
556
- end
557
- end
558
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # LaborApi
8
+ class LaborApi < BaseApi
9
+ def initialize(config, http_call_back: nil)
10
+ super(config, http_call_back: http_call_back)
11
+ end
12
+
13
+ # Returns a paginated list of `BreakType` instances for a business.
14
+ # @param [String] location_id Optional parameter: Filter Break Types
15
+ # returned to only those that are associated with the specified location.
16
+ # @param [Integer] limit Optional parameter: Maximum number of Break Types
17
+ # to return per page. Can range between 1 and 200. The default is the
18
+ # maximum at 200.
19
+ # @param [String] cursor Optional parameter: Pointer to the next page of
20
+ # Break Type results to fetch.
21
+ # @return [ListBreakTypesResponse Hash] response from the API call
22
+ def list_break_types(location_id: nil,
23
+ limit: nil,
24
+ cursor: nil)
25
+ # Prepare query url.
26
+ _query_builder = config.get_base_uri
27
+ _query_builder << '/v2/labor/break-types'
28
+ _query_builder = APIHelper.append_url_with_query_parameters(
29
+ _query_builder,
30
+ 'location_id' => location_id,
31
+ 'limit' => limit,
32
+ 'cursor' => cursor
33
+ )
34
+ _query_url = APIHelper.clean_url _query_builder
35
+
36
+ # Prepare headers.
37
+ _headers = {
38
+ 'accept' => 'application/json'
39
+ }
40
+
41
+ # Prepare and execute HttpRequest.
42
+ _request = config.http_client.get(
43
+ _query_url,
44
+ headers: _headers
45
+ )
46
+ OAuth2.apply(config, _request)
47
+ _response = execute_request(_request)
48
+
49
+ # Return appropriate response type.
50
+ decoded = APIHelper.json_deserialize(_response.raw_body)
51
+ _errors = APIHelper.map_response(decoded, ['errors'])
52
+ ApiResponse.new(_response, data: decoded, errors: _errors)
53
+ end
54
+
55
+ # Creates a new `BreakType`.
56
+ # A `BreakType` is a template for creating `Break` objects.
57
+ # You must provide the following values in your request to this
58
+ # endpoint:
59
+ # - `location_id`
60
+ # - `break_name`
61
+ # - `expected_duration`
62
+ # - `is_paid`
63
+ # You can only have 3 `BreakType` instances per location. If you attempt to
64
+ # add a 4th
65
+ # `BreakType` for a location, an `INVALID_REQUEST_ERROR` "Exceeded limit of
66
+ # 3 breaks per location."
67
+ # is returned.
68
+ # @param [CreateBreakTypeRequest] body Required parameter: An object
69
+ # containing the fields to POST for the request. See the corresponding
70
+ # object definition for field details.
71
+ # @return [CreateBreakTypeResponse Hash] response from the API call
72
+ def create_break_type(body:)
73
+ # Prepare query url.
74
+ _query_builder = config.get_base_uri
75
+ _query_builder << '/v2/labor/break-types'
76
+ _query_url = APIHelper.clean_url _query_builder
77
+
78
+ # Prepare headers.
79
+ _headers = {
80
+ 'accept' => 'application/json',
81
+ 'content-type' => 'application/json; charset=utf-8'
82
+ }
83
+
84
+ # Prepare and execute HttpRequest.
85
+ _request = config.http_client.post(
86
+ _query_url,
87
+ headers: _headers,
88
+ parameters: body.to_json
89
+ )
90
+ OAuth2.apply(config, _request)
91
+ _response = execute_request(_request)
92
+
93
+ # Return appropriate response type.
94
+ decoded = APIHelper.json_deserialize(_response.raw_body)
95
+ _errors = APIHelper.map_response(decoded, ['errors'])
96
+ ApiResponse.new(_response, data: decoded, errors: _errors)
97
+ end
98
+
99
+ # Deletes an existing `BreakType`.
100
+ # A `BreakType` can be deleted even if it is referenced from a `Shift`.
101
+ # @param [String] id Required parameter: UUID for the `BreakType` being
102
+ # deleted.
103
+ # @return [DeleteBreakTypeResponse Hash] response from the API call
104
+ def delete_break_type(id:)
105
+ # Prepare query url.
106
+ _query_builder = config.get_base_uri
107
+ _query_builder << '/v2/labor/break-types/{id}'
108
+ _query_builder = APIHelper.append_url_with_template_parameters(
109
+ _query_builder,
110
+ 'id' => id
111
+ )
112
+ _query_url = APIHelper.clean_url _query_builder
113
+
114
+ # Prepare headers.
115
+ _headers = {
116
+ 'accept' => 'application/json'
117
+ }
118
+
119
+ # Prepare and execute HttpRequest.
120
+ _request = config.http_client.delete(
121
+ _query_url,
122
+ headers: _headers
123
+ )
124
+ OAuth2.apply(config, _request)
125
+ _response = execute_request(_request)
126
+
127
+ # Return appropriate response type.
128
+ decoded = APIHelper.json_deserialize(_response.raw_body)
129
+ _errors = APIHelper.map_response(decoded, ['errors'])
130
+ ApiResponse.new(_response, data: decoded, errors: _errors)
131
+ end
132
+
133
+ # Returns a single `BreakType` specified by id.
134
+ # @param [String] id Required parameter: UUID for the `BreakType` being
135
+ # retrieved.
136
+ # @return [GetBreakTypeResponse Hash] response from the API call
137
+ def get_break_type(id:)
138
+ # Prepare query url.
139
+ _query_builder = config.get_base_uri
140
+ _query_builder << '/v2/labor/break-types/{id}'
141
+ _query_builder = APIHelper.append_url_with_template_parameters(
142
+ _query_builder,
143
+ 'id' => id
144
+ )
145
+ _query_url = APIHelper.clean_url _query_builder
146
+
147
+ # Prepare headers.
148
+ _headers = {
149
+ 'accept' => 'application/json'
150
+ }
151
+
152
+ # Prepare and execute HttpRequest.
153
+ _request = config.http_client.get(
154
+ _query_url,
155
+ headers: _headers
156
+ )
157
+ OAuth2.apply(config, _request)
158
+ _response = execute_request(_request)
159
+
160
+ # Return appropriate response type.
161
+ decoded = APIHelper.json_deserialize(_response.raw_body)
162
+ _errors = APIHelper.map_response(decoded, ['errors'])
163
+ ApiResponse.new(_response, data: decoded, errors: _errors)
164
+ end
165
+
166
+ # Updates an existing `BreakType`.
167
+ # @param [String] id Required parameter: UUID for the `BreakType` being
168
+ # updated.
169
+ # @param [UpdateBreakTypeRequest] body Required parameter: An object
170
+ # containing the fields to POST for the request. See the corresponding
171
+ # object definition for field details.
172
+ # @return [UpdateBreakTypeResponse Hash] response from the API call
173
+ def update_break_type(id:,
174
+ body:)
175
+ # Prepare query url.
176
+ _query_builder = config.get_base_uri
177
+ _query_builder << '/v2/labor/break-types/{id}'
178
+ _query_builder = APIHelper.append_url_with_template_parameters(
179
+ _query_builder,
180
+ 'id' => id
181
+ )
182
+ _query_url = APIHelper.clean_url _query_builder
183
+
184
+ # Prepare headers.
185
+ _headers = {
186
+ 'accept' => 'application/json',
187
+ 'content-type' => 'application/json; charset=utf-8'
188
+ }
189
+
190
+ # Prepare and execute HttpRequest.
191
+ _request = config.http_client.put(
192
+ _query_url,
193
+ headers: _headers,
194
+ parameters: body.to_json
195
+ )
196
+ OAuth2.apply(config, _request)
197
+ _response = execute_request(_request)
198
+
199
+ # Return appropriate response type.
200
+ decoded = APIHelper.json_deserialize(_response.raw_body)
201
+ _errors = APIHelper.map_response(decoded, ['errors'])
202
+ ApiResponse.new(_response, data: decoded, errors: _errors)
203
+ end
204
+
205
+ # Returns a paginated list of `EmployeeWage` instances for a business.
206
+ # @param [String] employee_id Optional parameter: Filter wages returned to
207
+ # only those that are associated with the specified employee.
208
+ # @param [Integer] limit Optional parameter: Maximum number of Employee
209
+ # Wages to return per page. Can range between 1 and 200. The default is the
210
+ # maximum at 200.
211
+ # @param [String] cursor Optional parameter: Pointer to the next page of
212
+ # Employee Wage results to fetch.
213
+ # @return [ListEmployeeWagesResponse Hash] response from the API call
214
+ def list_employee_wages(employee_id: nil,
215
+ limit: nil,
216
+ cursor: nil)
217
+ # Prepare query url.
218
+ _query_builder = config.get_base_uri
219
+ _query_builder << '/v2/labor/employee-wages'
220
+ _query_builder = APIHelper.append_url_with_query_parameters(
221
+ _query_builder,
222
+ 'employee_id' => employee_id,
223
+ 'limit' => limit,
224
+ 'cursor' => cursor
225
+ )
226
+ _query_url = APIHelper.clean_url _query_builder
227
+
228
+ # Prepare headers.
229
+ _headers = {
230
+ 'accept' => 'application/json'
231
+ }
232
+
233
+ # Prepare and execute HttpRequest.
234
+ _request = config.http_client.get(
235
+ _query_url,
236
+ headers: _headers
237
+ )
238
+ OAuth2.apply(config, _request)
239
+ _response = execute_request(_request)
240
+
241
+ # Return appropriate response type.
242
+ decoded = APIHelper.json_deserialize(_response.raw_body)
243
+ _errors = APIHelper.map_response(decoded, ['errors'])
244
+ ApiResponse.new(_response, data: decoded, errors: _errors)
245
+ end
246
+
247
+ # Returns a single `EmployeeWage` specified by id.
248
+ # @param [String] id Required parameter: UUID for the `EmployeeWage` being
249
+ # retrieved.
250
+ # @return [GetEmployeeWageResponse Hash] response from the API call
251
+ def get_employee_wage(id:)
252
+ # Prepare query url.
253
+ _query_builder = config.get_base_uri
254
+ _query_builder << '/v2/labor/employee-wages/{id}'
255
+ _query_builder = APIHelper.append_url_with_template_parameters(
256
+ _query_builder,
257
+ 'id' => id
258
+ )
259
+ _query_url = APIHelper.clean_url _query_builder
260
+
261
+ # Prepare headers.
262
+ _headers = {
263
+ 'accept' => 'application/json'
264
+ }
265
+
266
+ # Prepare and execute HttpRequest.
267
+ _request = config.http_client.get(
268
+ _query_url,
269
+ headers: _headers
270
+ )
271
+ OAuth2.apply(config, _request)
272
+ _response = execute_request(_request)
273
+
274
+ # Return appropriate response type.
275
+ decoded = APIHelper.json_deserialize(_response.raw_body)
276
+ _errors = APIHelper.map_response(decoded, ['errors'])
277
+ ApiResponse.new(_response, data: decoded, errors: _errors)
278
+ end
279
+
280
+ # Creates a new `Shift`.
281
+ # A `Shift` represents a complete work day for a single employee.
282
+ # You must provide the following values in your request to this
283
+ # endpoint:
284
+ # - `location_id`
285
+ # - `employee_id`
286
+ # - `start_at`
287
+ # An attempt to create a new `Shift` can result in a `BAD_REQUEST` error
288
+ # when:
289
+ # - The `status` of the new `Shift` is `OPEN` and the employee has another
290
+ # shift with an `OPEN` status.
291
+ # - The `start_at` date is in the future
292
+ # - the `start_at` or `end_at` overlaps another shift for the same employee
293
+ # - If `Break`s are set in the request, a break `start_at`
294
+ # must not be before the `Shift.start_at`. A break `end_at` must not be
295
+ # after
296
+ # the `Shift.end_at`
297
+ # @param [CreateShiftRequest] body Required parameter: An object containing
298
+ # the fields to POST for the request. See the corresponding object
299
+ # definition for field details.
300
+ # @return [CreateShiftResponse Hash] response from the API call
301
+ def create_shift(body:)
302
+ # Prepare query url.
303
+ _query_builder = config.get_base_uri
304
+ _query_builder << '/v2/labor/shifts'
305
+ _query_url = APIHelper.clean_url _query_builder
306
+
307
+ # Prepare headers.
308
+ _headers = {
309
+ 'accept' => 'application/json',
310
+ 'content-type' => 'application/json; charset=utf-8'
311
+ }
312
+
313
+ # Prepare and execute HttpRequest.
314
+ _request = config.http_client.post(
315
+ _query_url,
316
+ headers: _headers,
317
+ parameters: body.to_json
318
+ )
319
+ OAuth2.apply(config, _request)
320
+ _response = execute_request(_request)
321
+
322
+ # Return appropriate response type.
323
+ decoded = APIHelper.json_deserialize(_response.raw_body)
324
+ _errors = APIHelper.map_response(decoded, ['errors'])
325
+ ApiResponse.new(_response, data: decoded, errors: _errors)
326
+ end
327
+
328
+ # Returns a paginated list of `Shift` records for a business.
329
+ # The list to be returned can be filtered by:
330
+ # - Location IDs **and**
331
+ # - employee IDs **and**
332
+ # - shift status (`OPEN`, `CLOSED`) **and**
333
+ # - shift start **and**
334
+ # - shift end **and**
335
+ # - work day details
336
+ # The list can be sorted by:
337
+ # - `start_at`
338
+ # - `end_at`
339
+ # - `created_at`
340
+ # - `updated_at`
341
+ # @param [SearchShiftsRequest] body Required parameter: An object containing
342
+ # the fields to POST for the request. See the corresponding object
343
+ # definition for field details.
344
+ # @return [SearchShiftsResponse Hash] response from the API call
345
+ def search_shifts(body:)
346
+ # Prepare query url.
347
+ _query_builder = config.get_base_uri
348
+ _query_builder << '/v2/labor/shifts/search'
349
+ _query_url = APIHelper.clean_url _query_builder
350
+
351
+ # Prepare headers.
352
+ _headers = {
353
+ 'accept' => 'application/json',
354
+ 'content-type' => 'application/json; charset=utf-8'
355
+ }
356
+
357
+ # Prepare and execute HttpRequest.
358
+ _request = config.http_client.post(
359
+ _query_url,
360
+ headers: _headers,
361
+ parameters: body.to_json
362
+ )
363
+ OAuth2.apply(config, _request)
364
+ _response = execute_request(_request)
365
+
366
+ # Return appropriate response type.
367
+ decoded = APIHelper.json_deserialize(_response.raw_body)
368
+ _errors = APIHelper.map_response(decoded, ['errors'])
369
+ ApiResponse.new(_response, data: decoded, errors: _errors)
370
+ end
371
+
372
+ # Deletes a `Shift`.
373
+ # @param [String] id Required parameter: UUID for the `Shift` being
374
+ # deleted.
375
+ # @return [DeleteShiftResponse Hash] response from the API call
376
+ def delete_shift(id:)
377
+ # Prepare query url.
378
+ _query_builder = config.get_base_uri
379
+ _query_builder << '/v2/labor/shifts/{id}'
380
+ _query_builder = APIHelper.append_url_with_template_parameters(
381
+ _query_builder,
382
+ 'id' => id
383
+ )
384
+ _query_url = APIHelper.clean_url _query_builder
385
+
386
+ # Prepare headers.
387
+ _headers = {
388
+ 'accept' => 'application/json'
389
+ }
390
+
391
+ # Prepare and execute HttpRequest.
392
+ _request = config.http_client.delete(
393
+ _query_url,
394
+ headers: _headers
395
+ )
396
+ OAuth2.apply(config, _request)
397
+ _response = execute_request(_request)
398
+
399
+ # Return appropriate response type.
400
+ decoded = APIHelper.json_deserialize(_response.raw_body)
401
+ _errors = APIHelper.map_response(decoded, ['errors'])
402
+ ApiResponse.new(_response, data: decoded, errors: _errors)
403
+ end
404
+
405
+ # Returns a single `Shift` specified by id.
406
+ # @param [String] id Required parameter: UUID for the `Shift` being
407
+ # retrieved.
408
+ # @return [GetShiftResponse Hash] response from the API call
409
+ def get_shift(id:)
410
+ # Prepare query url.
411
+ _query_builder = config.get_base_uri
412
+ _query_builder << '/v2/labor/shifts/{id}'
413
+ _query_builder = APIHelper.append_url_with_template_parameters(
414
+ _query_builder,
415
+ 'id' => id
416
+ )
417
+ _query_url = APIHelper.clean_url _query_builder
418
+
419
+ # Prepare headers.
420
+ _headers = {
421
+ 'accept' => 'application/json'
422
+ }
423
+
424
+ # Prepare and execute HttpRequest.
425
+ _request = config.http_client.get(
426
+ _query_url,
427
+ headers: _headers
428
+ )
429
+ OAuth2.apply(config, _request)
430
+ _response = execute_request(_request)
431
+
432
+ # Return appropriate response type.
433
+ decoded = APIHelper.json_deserialize(_response.raw_body)
434
+ _errors = APIHelper.map_response(decoded, ['errors'])
435
+ ApiResponse.new(_response, data: decoded, errors: _errors)
436
+ end
437
+
438
+ # Updates an existing `Shift`.
439
+ # When adding a `Break` to a `Shift`, any earlier `Breaks` in the `Shift`
440
+ # have
441
+ # the `end_at` property set to a valid RFC-3339 datetime string.
442
+ # When closing a `Shift`, all `Break` instances in the shift must be
443
+ # complete with `end_at`
444
+ # set on each `Break`.
445
+ # @param [String] id Required parameter: ID of the object being updated.
446
+ # @param [UpdateShiftRequest] body Required parameter: An object containing
447
+ # the fields to POST for the request. See the corresponding object
448
+ # definition for field details.
449
+ # @return [UpdateShiftResponse Hash] response from the API call
450
+ def update_shift(id:,
451
+ body:)
452
+ # Prepare query url.
453
+ _query_builder = config.get_base_uri
454
+ _query_builder << '/v2/labor/shifts/{id}'
455
+ _query_builder = APIHelper.append_url_with_template_parameters(
456
+ _query_builder,
457
+ 'id' => id
458
+ )
459
+ _query_url = APIHelper.clean_url _query_builder
460
+
461
+ # Prepare headers.
462
+ _headers = {
463
+ 'accept' => 'application/json',
464
+ 'content-type' => 'application/json; charset=utf-8'
465
+ }
466
+
467
+ # Prepare and execute HttpRequest.
468
+ _request = config.http_client.put(
469
+ _query_url,
470
+ headers: _headers,
471
+ parameters: body.to_json
472
+ )
473
+ OAuth2.apply(config, _request)
474
+ _response = execute_request(_request)
475
+
476
+ # Return appropriate response type.
477
+ decoded = APIHelper.json_deserialize(_response.raw_body)
478
+ _errors = APIHelper.map_response(decoded, ['errors'])
479
+ ApiResponse.new(_response, data: decoded, errors: _errors)
480
+ end
481
+
482
+ # Returns a list of `WorkweekConfig` instances for a business.
483
+ # @param [Integer] limit Optional parameter: Maximum number of Workweek
484
+ # Configs to return per page.
485
+ # @param [String] cursor Optional parameter: Pointer to the next page of
486
+ # Workweek Config results to fetch.
487
+ # @return [ListWorkweekConfigsResponse Hash] response from the API call
488
+ def list_workweek_configs(limit: nil,
489
+ cursor: nil)
490
+ # Prepare query url.
491
+ _query_builder = config.get_base_uri
492
+ _query_builder << '/v2/labor/workweek-configs'
493
+ _query_builder = APIHelper.append_url_with_query_parameters(
494
+ _query_builder,
495
+ 'limit' => limit,
496
+ 'cursor' => cursor
497
+ )
498
+ _query_url = APIHelper.clean_url _query_builder
499
+
500
+ # Prepare headers.
501
+ _headers = {
502
+ 'accept' => 'application/json'
503
+ }
504
+
505
+ # Prepare and execute HttpRequest.
506
+ _request = config.http_client.get(
507
+ _query_url,
508
+ headers: _headers
509
+ )
510
+ OAuth2.apply(config, _request)
511
+ _response = execute_request(_request)
512
+
513
+ # Return appropriate response type.
514
+ decoded = APIHelper.json_deserialize(_response.raw_body)
515
+ _errors = APIHelper.map_response(decoded, ['errors'])
516
+ ApiResponse.new(_response, data: decoded, errors: _errors)
517
+ end
518
+
519
+ # Updates a `WorkweekConfig`.
520
+ # @param [String] id Required parameter: UUID for the `WorkweekConfig`
521
+ # object being updated.
522
+ # @param [UpdateWorkweekConfigRequest] body Required parameter: An object
523
+ # containing the fields to POST for the request. See the corresponding
524
+ # object definition for field details.
525
+ # @return [UpdateWorkweekConfigResponse Hash] response from the API call
526
+ def update_workweek_config(id:,
527
+ body:)
528
+ # Prepare query url.
529
+ _query_builder = config.get_base_uri
530
+ _query_builder << '/v2/labor/workweek-configs/{id}'
531
+ _query_builder = APIHelper.append_url_with_template_parameters(
532
+ _query_builder,
533
+ 'id' => id
534
+ )
535
+ _query_url = APIHelper.clean_url _query_builder
536
+
537
+ # Prepare headers.
538
+ _headers = {
539
+ 'accept' => 'application/json',
540
+ 'content-type' => 'application/json; charset=utf-8'
541
+ }
542
+
543
+ # Prepare and execute HttpRequest.
544
+ _request = config.http_client.put(
545
+ _query_url,
546
+ headers: _headers,
547
+ parameters: body.to_json
548
+ )
549
+ OAuth2.apply(config, _request)
550
+ _response = execute_request(_request)
551
+
552
+ # Return appropriate response type.
553
+ decoded = APIHelper.json_deserialize(_response.raw_body)
554
+ _errors = APIHelper.map_response(decoded, ['errors'])
555
+ ApiResponse.new(_response, data: decoded, errors: _errors)
556
+ end
557
+ end
558
+ end