Class: Square::LaborApi

Inherits:
BaseApi show all
Defined in:
lib/square/api/labor_api.rb

Overview

LaborApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

Instance Method Details

#create_break_type(body:) ⇒ ApiResponse

Creates a new ‘BreakType`. A `BreakType` is a template for creating `Break` objects. You must provide the following values in your request to this endpoint:

  • ‘location_id`

  • ‘break_name`

  • ‘expected_duration`

  • ‘is_paid`

You can only have three ‘BreakType` instances per location. If you attempt to add a fourth `BreakType` for a location, an `INVALID_REQUEST_ERROR` “Exceeded limit of 3 breaks per location.” is returned. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (CreateBreakTypeRequest)

    Required parameter: An object

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/square/api/labor_api.rb', line 50

def create_break_type(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/labor/break-types',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#create_shift(body:) ⇒ ApiResponse

Creates a new ‘Shift`. A `Shift` represents a complete workday for a single team member. You must provide the following values in your request to this endpoint:

  • ‘location_id`

  • ‘team_member_id`

  • ‘start_at`

An attempt to create a new ‘Shift` can result in a `BAD_REQUEST` error when:

  • The ‘status` of the new `Shift` is `OPEN` and the team member has

another shift with an ‘OPEN` status.

  • The ‘start_at` date is in the future.

  • The ‘start_at` or `end_at` date overlaps another shift for the same team

member.

  • The ‘Break` instances are set in the request and a break `start_at`

is before the ‘Shift.start_at`, a break `end_at` is after the `Shift.end_at`, or both. the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (CreateShiftRequest)

    Required parameter: An object containing

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/square/api/labor_api.rb', line 207

def create_shift(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/labor/shifts',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#delete_break_type(id:) ⇒ ApiResponse

Deletes an existing ‘BreakType`. A `BreakType` can be deleted even if it is referenced from a `Shift`. deleted.

Parameters:

  • id (String)

    Required parameter: The UUID for the ‘BreakType` being

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/square/api/labor_api.rb', line 72

def delete_break_type(id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/v2/labor/break-types/{id}',
                                 'default')
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#delete_shift(id:) ⇒ ApiResponse

Deletes a ‘Shift`. deleted.

Parameters:

  • id (String)

    Required parameter: The UUID for the ‘Shift` being

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/square/api/labor_api.rb', line 262

def delete_shift(id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/v2/labor/shifts/{id}',
                                 'default')
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#get_break_type(id:) ⇒ ApiResponse

Returns a single ‘BreakType` specified by `id`. retrieved.

Parameters:

  • id (String)

    Required parameter: The UUID for the ‘BreakType` being

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/square/api/labor_api.rb', line 92

def get_break_type(id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/labor/break-types/{id}',
                                 'default')
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#get_employee_wage(id:) ⇒ ApiResponse

Returns a single ‘EmployeeWage` specified by `id`. being retrieved.

Parameters:

  • id (String)

    Required parameter: The UUID for the ‘EmployeeWage`

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/square/api/labor_api.rb', line 168

def get_employee_wage(id:)
  warn 'Endpoint get_employee_wage in LaborApi is deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/labor/employee-wages/{id}',
                                 'default')
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#get_shift(id:) ⇒ ApiResponse

Returns a single ‘Shift` specified by `id`. retrieved.

Parameters:

  • id (String)

    Required parameter: The UUID for the ‘Shift` being

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/square/api/labor_api.rb', line 282

def get_shift(id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/labor/shifts/{id}',
                                 'default')
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#get_team_member_wage(id:) ⇒ ApiResponse

Returns a single ‘TeamMemberWage` specified by `id`. being retrieved.

Parameters:

  • id (String)

    Required parameter: The UUID for the ‘TeamMemberWage`

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/square/api/labor_api.rb', line 363

def get_team_member_wage(id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/labor/team-member-wages/{id}',
                                 'default')
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#list_break_types(location_id: nil, limit: nil, cursor: nil) ⇒ ApiResponse

Returns a paginated list of ‘BreakType` instances for a business. `BreakType` results to only those that are associated with the specified location. `BreakType` results to return per page. The number can range between 1 and

  1. The default is 200.

‘BreakType` results to fetch.

Parameters:

  • location_id (String) (defaults to: nil)

    Optional parameter: Filter the returned

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of

  • cursor (String) (defaults to: nil)

    Optional parameter: A pointer to the next page of

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/square/api/labor_api.rb', line 14

def list_break_types(location_id: nil,
                     limit: nil,
                     cursor: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/labor/break-types',
                                 'default')
               .query_param(new_parameter(location_id, key: 'location_id'))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#list_employee_wages(employee_id: nil, limit: nil, cursor: nil) ⇒ ApiResponse

Returns a paginated list of ‘EmployeeWage` instances for a business. to only those that are associated with the specified employee. `EmployeeWage` results to return per page. The number can range between 1 and 200. The default is 200. `EmployeeWage` results to fetch.

Parameters:

  • employee_id (String) (defaults to: nil)

    Optional parameter: Filter the returned wages

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of

  • cursor (String) (defaults to: nil)

    Optional parameter: A pointer to the next page of

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/square/api/labor_api.rb', line 144

def list_employee_wages(employee_id: nil,
                        limit: nil,
                        cursor: nil)
  warn 'Endpoint list_employee_wages in LaborApi is deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/labor/employee-wages',
                                 'default')
               .query_param(new_parameter(employee_id, key: 'employee_id'))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#list_team_member_wages(team_member_id: nil, limit: nil, cursor: nil) ⇒ ApiResponse

Returns a paginated list of ‘TeamMemberWage` instances for a business. wages to only those that are associated with the specified team member. `TeamMemberWage` results to return per page. The number can range between 1 and 200. The default is 200. `EmployeeWage` results to fetch.

Parameters:

  • team_member_id (String) (defaults to: nil)

    Optional parameter: Filter the returned

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of

  • cursor (String) (defaults to: nil)

    Optional parameter: A pointer to the next page of

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/square/api/labor_api.rb', line 340

def list_team_member_wages(team_member_id: nil,
                           limit: nil,
                           cursor: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/labor/team-member-wages',
                                 'default')
               .query_param(new_parameter(team_member_id, key: 'team_member_id'))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#list_workweek_configs(limit: nil, cursor: nil) ⇒ ApiResponse

Returns a list of ‘WorkweekConfig` instances for a business. `WorkweekConfigs` results to return per page. `WorkweekConfig` results to fetch.

Parameters:

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of

  • cursor (String) (defaults to: nil)

    Optional parameter: A pointer to the next page of

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/square/api/labor_api.rb', line 385

def list_workweek_configs(limit: nil,
                          cursor: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/labor/workweek-configs',
                                 'default')
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#search_shifts(body:) ⇒ ApiResponse

Returns a paginated list of ‘Shift` records for a business. The list to be returned can be filtered by:

  • Location IDs

  • Team member IDs

  • Shift status (‘OPEN` or `CLOSED`)

  • Shift start

  • Shift end

  • Workday details

The list can be sorted by:

  • ‘START_AT`

  • ‘END_AT`

  • ‘CREATED_AT`

  • ‘UPDATED_AT`

the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (SearchShiftsRequest)

    Required parameter: An object containing

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/square/api/labor_api.rb', line 241

def search_shifts(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/labor/shifts/search',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#update_break_type(id:, body:) ⇒ ApiResponse

Updates an existing ‘BreakType`. updated. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • id (String)

    Required parameter: The UUID for the ‘BreakType` being

  • body (UpdateBreakTypeRequest)

    Required parameter: An object

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/square/api/labor_api.rb', line 115

def update_break_type(id:,
                      body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/v2/labor/break-types/{id}',
                                 'default')
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#update_shift(id:, body:) ⇒ ApiResponse

Updates an existing ‘Shift`. When adding a `Break` to a `Shift`, any earlier `Break` instances in the `Shift` have the `end_at` property set to a valid RFC-3339 datetime string. When closing a `Shift`, all `Break` instances in the `Shift` must be complete with `end_at` set on each `Break`. updated. the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • id (String)

    Required parameter: The ID of the object being

  • body (UpdateShiftRequest)

    Required parameter: An object containing

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/square/api/labor_api.rb', line 311

def update_shift(id:,
                 body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/v2/labor/shifts/{id}',
                                 'default')
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#update_workweek_config(id:, body:) ⇒ ApiResponse

Updates a ‘WorkweekConfig`. object being updated. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • id (String)

    Required parameter: The UUID for the ‘WorkweekConfig`

  • body (UpdateWorkweekConfigRequest)

    Required parameter: An object

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/square/api/labor_api.rb', line 409

def update_workweek_config(id:,
                           body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/v2/labor/workweek-configs/{id}',
                                 'default')
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end