Class: Square::LaborApi
Overview
LaborApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#create_break_type(body:) ⇒ CreateBreakTypeResponse Hash
Creates a new ‘BreakType`.
-
#create_shift(body:) ⇒ CreateShiftResponse Hash
Creates a new ‘Shift`.
-
#delete_break_type(id:) ⇒ DeleteBreakTypeResponse Hash
Deletes an existing ‘BreakType`.
-
#delete_shift(id:) ⇒ DeleteShiftResponse Hash
Deletes a ‘Shift`.
-
#get_break_type(id:) ⇒ GetBreakTypeResponse Hash
Returns a single ‘BreakType` specified by `id`.
-
#get_employee_wage(id:) ⇒ GetEmployeeWageResponse Hash
Returns a single ‘EmployeeWage` specified by `id`.
-
#get_shift(id:) ⇒ GetShiftResponse Hash
Returns a single ‘Shift` specified by `id`.
-
#get_team_member_wage(id:) ⇒ GetTeamMemberWageResponse Hash
Returns a single ‘TeamMemberWage` specified by `id `.
-
#list_break_types(location_id: nil, limit: nil, cursor: nil) ⇒ ListBreakTypesResponse Hash
Returns a paginated list of ‘BreakType` instances for a business.
-
#list_employee_wages(employee_id: nil, limit: nil, cursor: nil) ⇒ ListEmployeeWagesResponse Hash
Returns a paginated list of ‘EmployeeWage` instances for a business.
-
#list_team_member_wages(team_member_id: nil, limit: nil, cursor: nil) ⇒ ListTeamMemberWagesResponse Hash
Returns a paginated list of ‘TeamMemberWage` instances for a business.
-
#list_workweek_configs(limit: nil, cursor: nil) ⇒ ListWorkweekConfigsResponse Hash
Returns a list of ‘WorkweekConfig` instances for a business.
-
#search_shifts(body:) ⇒ SearchShiftsResponse Hash
Returns a paginated list of ‘Shift` records for a business.
-
#update_break_type(id:, body:) ⇒ UpdateBreakTypeResponse Hash
Updates an existing ‘BreakType`.
-
#update_shift(id:, body:) ⇒ UpdateShiftResponse Hash
Updates an existing ‘Shift`.
-
#update_workweek_config(id:, body:) ⇒ UpdateWorkweekConfigResponse Hash
Updates a ‘WorkweekConfig`.
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:) ⇒ CreateBreakTypeResponse Hash
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.
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:) ⇒ CreateShiftResponse Hash
Creates a new ‘Shift`. A `Shift` represents a complete workday for a single employee. You must provide the following values in your request to this endpoint:
-
‘location_id`
-
‘employee_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 employee 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
employee.
-
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.
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/square/api/labor_api.rb', line 206 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:) ⇒ DeleteBreakTypeResponse Hash
Deletes an existing ‘BreakType`. A `BreakType` can be deleted even if it is referenced from a `Shift`. deleted.
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:) ⇒ DeleteShiftResponse Hash
Deletes a ‘Shift`. deleted.
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/square/api/labor_api.rb', line 261 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:) ⇒ GetBreakTypeResponse Hash
Returns a single ‘BreakType` specified by `id`. retrieved.
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:) ⇒ GetEmployeeWageResponse Hash
Returns a single ‘EmployeeWage` specified by `id`. being retrieved.
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:) ⇒ GetShiftResponse Hash
Returns a single ‘Shift` specified by `id`. retrieved.
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/square/api/labor_api.rb', line 281 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:) ⇒ GetTeamMemberWageResponse Hash
Returns a single ‘TeamMemberWage` specified by `id `. being retrieved.
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/square/api/labor_api.rb', line 362 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) ⇒ ListBreakTypesResponse Hash
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
-
The default is 200.
‘BreakType` results to fetch.
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) ⇒ ListEmployeeWagesResponse Hash
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.
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) ⇒ ListTeamMemberWagesResponse Hash
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.
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/square/api/labor_api.rb', line 339 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) ⇒ ListWorkweekConfigsResponse Hash
Returns a list of ‘WorkweekConfig` instances for a business. `WorkweekConfigs` results to return per page. `WorkweekConfig` results to fetch.
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/square/api/labor_api.rb', line 384 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:) ⇒ SearchShiftsResponse Hash
Returns a paginated list of ‘Shift` records for a business. The list to be returned can be filtered by:
-
Location IDs.
-
Employee IDs.
-
Shift status (‘OPEN` and `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.
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/square/api/labor_api.rb', line 240 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:) ⇒ UpdateBreakTypeResponse Hash
Updates an existing ‘BreakType`. updated. containing the fields to POST for the request. See the corresponding object definition for field details.
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:) ⇒ UpdateShiftResponse Hash
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.
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/square/api/labor_api.rb', line 310 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:) ⇒ UpdateWorkweekConfigResponse Hash
Updates a ‘WorkweekConfig`. object being updated. containing the fields to POST for the request. See the corresponding object definition for field details.
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/square/api/labor_api.rb', line 408 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 |