labor_api = client.labor
LaborApi
- List Break Types
- Create Break Type
- Delete Break Type
- Get Break Type
- Update Break Type
- List Employee Wages
- Get Employee Wage
- Create Shift
- Search Shifts
- Delete Shift
- Get Shift
- Update Shift
- List Team Member Wages
- Get Team Member Wage
- List Workweek Configs
- Update Workweek Config
Returns a paginated list of BreakType
instances for a business.
def list_break_types(self,
location_id=None,
limit=None,
cursor=None)
Parameter | Type | Tags | Description |
---|---|---|---|
location_id |
str |
Query, Optional | Filter the returned BreakType results to only those that are associated with thespecified location. |
limit |
int |
Query, Optional | The maximum number of BreakType results to return per page. The number can range between 1and 200. The default is 200. |
cursor |
str |
Query, Optional | A pointer to the next page of BreakType results to fetch. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type List Break Types Response
.
result = labor_api.list_break_types()
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
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.
def create_break_type(self,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Create Break Type Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Create Break Type Response
.
body = {
'break_type': {
'location_id': 'CGJN03P1D08GF',
'break_name': 'Lunch Break',
'expected_duration': 'PT30M',
'is_paid': True
},
'idempotency_key': 'PAD3NG5KSN2GL'
}
result = labor_api.create_break_type(body)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Deletes an existing BreakType
.
A BreakType
can be deleted even if it is referenced from a Shift
.
def delete_break_type(self,
id)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
str |
Template, Required | The UUID for the BreakType being deleted. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Delete Break Type Response
.
id = 'id0'
result = labor_api.delete_break_type(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Returns a single BreakType
specified by id
.
def get_break_type(self,
id)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
str |
Template, Required | The UUID for the BreakType being retrieved. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Get Break Type Response
.
id = 'id0'
result = labor_api.get_break_type(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Updates an existing BreakType
.
def update_break_type(self,
id,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
str |
Template, Required | The UUID for the BreakType being updated. |
body |
Update Break Type Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Update Break Type Response
.
id = 'id0'
body = {
'break_type': {
'location_id': '26M7H24AZ9N6R',
'break_name': 'Lunch',
'expected_duration': 'PT50M',
'is_paid': True,
'version': 1
}
}
result = labor_api.update_break_type(
id,
body
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
This endpoint is deprecated.
Returns a paginated list of EmployeeWage
instances for a business.
def list_employee_wages(self,
employee_id=None,
limit=None,
cursor=None)
Parameter | Type | Tags | Description |
---|---|---|---|
employee_id |
str |
Query, Optional | Filter the returned wages to only those that are associated with the specified employee. |
limit |
int |
Query, Optional | The maximum number of EmployeeWage results to return per page. The number can range between1 and 200. The default is 200. |
cursor |
str |
Query, Optional | A pointer to the next page of EmployeeWage results to fetch. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type List Employee Wages Response
.
result = labor_api.list_employee_wages()
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
This endpoint is deprecated.
Returns a single EmployeeWage
specified by id
.
def get_employee_wage(self,
id)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
str |
Template, Required | The UUID for the EmployeeWage being retrieved. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Get Employee Wage Response
.
id = 'id0'
result = labor_api.get_employee_wage(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
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 newShift
isOPEN
and the team member has another shift with anOPEN
status. - The
start_at
date is in the future. - The
start_at
orend_at
date overlaps another shift for the same team member. - The
Break
instances are set in the request and a breakstart_at
is before theShift.start_at
, a breakend_at
is after theShift.end_at
, or both.
def create_shift(self,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Create Shift Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Create Shift Response
.
body = {
'shift': {
'location_id': 'PAA1RJZZKXBFG',
'start_at': '2019-01-25T03:11:00-05:00',
'end_at': '2019-01-25T13:11:00-05:00',
'wage': {
'title': 'Barista',
'hourly_rate': {
'amount': 1100,
'currency': 'USD'
},
'tip_eligible': True
},
'breaks': [
{
'start_at': '2019-01-25T06:11:00-05:00',
'break_type_id': 'REGS1EQR1TPZ5',
'name': 'Tea Break',
'expected_duration': 'PT5M',
'is_paid': True,
'end_at': '2019-01-25T06:16:00-05:00'
}
],
'team_member_id': 'ormj0jJJZ5OZIzxrZYJI',
'declared_cash_tip_money': {
'amount': 500,
'currency': 'USD'
}
},
'idempotency_key': 'HIDSNG5KS478L'
}
result = labor_api.create_shift(body)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
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
orCLOSED
) - Shift start
- Shift end
- Workday details
The list can be sorted by:
START_AT
END_AT
CREATED_AT
UPDATED_AT
def search_shifts(self,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Search Shifts Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Search Shifts Response
.
body = {
'query': {
'filter': {
'workday': {
'date_range': {
'start_date': '2019-01-20',
'end_date': '2019-02-03'
},
'match_shifts_by': 'START_AT',
'default_timezone': 'America/Los_Angeles'
}
}
},
'limit': 100
}
result = labor_api.search_shifts(body)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Deletes a Shift
.
def delete_shift(self,
id)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
str |
Template, Required | The UUID for the Shift being deleted. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Delete Shift Response
.
id = 'id0'
result = labor_api.delete_shift(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Returns a single Shift
specified by id
.
def get_shift(self,
id)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
str |
Template, Required | The UUID for the Shift being retrieved. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Get Shift Response
.
id = 'id0'
result = labor_api.get_shift(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
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
.
def update_shift(self,
id,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
str |
Template, Required | The ID of the object being updated. |
body |
Update Shift Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Update Shift Response
.
id = 'id0'
body = {
'shift': {
'location_id': 'PAA1RJZZKXBFG',
'start_at': '2019-01-25T03:11:00-05:00',
'end_at': '2019-01-25T13:11:00-05:00',
'wage': {
'title': 'Bartender',
'hourly_rate': {
'amount': 1500,
'currency': 'USD'
},
'tip_eligible': True
},
'breaks': [
{
'start_at': '2019-01-25T06:11:00-05:00',
'break_type_id': 'REGS1EQR1TPZ5',
'name': 'Tea Break',
'expected_duration': 'PT5M',
'is_paid': True,
'id': 'X7GAQYVVRRG6P',
'end_at': '2019-01-25T06:16:00-05:00'
}
],
'version': 1,
'team_member_id': 'ormj0jJJZ5OZIzxrZYJI',
'declared_cash_tip_money': {
'amount': 500,
'currency': 'USD'
}
}
}
result = labor_api.update_shift(
id,
body
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Returns a paginated list of TeamMemberWage
instances for a business.
def list_team_member_wages(self,
team_member_id=None,
limit=None,
cursor=None)
Parameter | Type | Tags | Description |
---|---|---|---|
team_member_id |
str |
Query, Optional | Filter the returned wages to only those that are associated with the specified team member. |
limit |
int |
Query, Optional | The maximum number of TeamMemberWage results to return per page. The number can range between1 and 200. The default is 200. |
cursor |
str |
Query, Optional | A pointer to the next page of EmployeeWage results to fetch. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type List Team Member Wages Response
.
result = labor_api.list_team_member_wages()
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Returns a single TeamMemberWage
specified by id
.
def get_team_member_wage(self,
id)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
str |
Template, Required | The UUID for the TeamMemberWage being retrieved. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Get Team Member Wage Response
.
id = 'id0'
result = labor_api.get_team_member_wage(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Returns a list of WorkweekConfig
instances for a business.
def list_workweek_configs(self,
limit=None,
cursor=None)
Parameter | Type | Tags | Description |
---|---|---|---|
limit |
int |
Query, Optional | The maximum number of WorkweekConfigs results to return per page. |
cursor |
str |
Query, Optional | A pointer to the next page of WorkweekConfig results to fetch. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type List Workweek Configs Response
.
result = labor_api.list_workweek_configs()
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Updates a WorkweekConfig
.
def update_workweek_config(self,
id,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
str |
Template, Required | The UUID for the WorkweekConfig object being updated. |
body |
Update Workweek Config Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Update Workweek Config Response
.
id = 'id0'
body = {
'workweek_config': {
'start_of_week': 'MON',
'start_of_day_local_time': '10:00',
'version': 10
}
}
result = labor_api.update_workweek_config(
id,
body
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)