Skip to content

Latest commit

 

History

History
739 lines (527 loc) · 19 KB

labor.md

File metadata and controls

739 lines (527 loc) · 19 KB

Labor

labor_api = client.labor

Class Name

LaborApi

Methods

List Break Types

Returns a paginated list of BreakType instances for a business.

def list_break_types(self,
                    location_id=None,
                    limit=None,
                    cursor=None)

Parameters

Parameter Type Tags Description
location_id str Query, Optional Filter the returned BreakType results to only those that are associated with the
specified location.
limit int Query, Optional The maximum number of BreakType results to return per page. The number can range between 1
and 200. The default is 200.
cursor str Query, Optional A pointer to the next page of BreakType results to fetch.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type List Break Types Response.

Example Usage

result = labor_api.list_break_types()

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Create Break Type

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)

Parameters

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.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Create Break Type Response.

Example Usage

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)

Delete Break Type

Deletes an existing BreakType.

A BreakType can be deleted even if it is referenced from a Shift.

def delete_break_type(self,
                     id)

Parameters

Parameter Type Tags Description
id str Template, Required The UUID for the BreakType being deleted.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Delete Break Type Response.

Example Usage

id = 'id0'

result = labor_api.delete_break_type(id)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Get Break Type

Returns a single BreakType specified by id.

def get_break_type(self,
                  id)

Parameters

Parameter Type Tags Description
id str Template, Required The UUID for the BreakType being retrieved.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Get Break Type Response.

Example Usage

id = 'id0'

result = labor_api.get_break_type(id)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Update Break Type

Updates an existing BreakType.

def update_break_type(self,
                     id,
                     body)

Parameters

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.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Update Break Type Response.

Example Usage

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)

List Employee Wages

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)

Parameters

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 between
1 and 200. The default is 200.
cursor str Query, Optional A pointer to the next page of EmployeeWage results to fetch.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type List Employee Wages Response.

Example Usage

result = labor_api.list_employee_wages()

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Get Employee Wage

This endpoint is deprecated.

Returns a single EmployeeWage specified by id.

def get_employee_wage(self,
                     id)

Parameters

Parameter Type Tags Description
id str Template, Required The UUID for the EmployeeWage being retrieved.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Get Employee Wage Response.

Example Usage

id = 'id0'

result = labor_api.get_employee_wage(id)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Create Shift

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.
def create_shift(self,
                body)

Parameters

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.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Create Shift Response.

Example Usage

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)

Search Shifts

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
def search_shifts(self,
                 body)

Parameters

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.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Search Shifts Response.

Example Usage

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)

Delete Shift

Deletes a Shift.

def delete_shift(self,
                id)

Parameters

Parameter Type Tags Description
id str Template, Required The UUID for the Shift being deleted.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Delete Shift Response.

Example Usage

id = 'id0'

result = labor_api.delete_shift(id)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Get Shift

Returns a single Shift specified by id.

def get_shift(self,
             id)

Parameters

Parameter Type Tags Description
id str Template, Required The UUID for the Shift being retrieved.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Get Shift Response.

Example Usage

id = 'id0'

result = labor_api.get_shift(id)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Update Shift

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)

Parameters

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.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Update Shift Response.

Example Usage

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)

List Team Member Wages

Returns a paginated list of TeamMemberWage instances for a business.

def list_team_member_wages(self,
                          team_member_id=None,
                          limit=None,
                          cursor=None)

Parameters

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 between
1 and 200. The default is 200.
cursor str Query, Optional A pointer to the next page of EmployeeWage results to fetch.

Response Type

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.

Example Usage

result = labor_api.list_team_member_wages()

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Get Team Member Wage

Returns a single TeamMemberWage specified by id.

def get_team_member_wage(self,
                        id)

Parameters

Parameter Type Tags Description
id str Template, Required The UUID for the TeamMemberWage being retrieved.

Response Type

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.

Example Usage

id = 'id0'

result = labor_api.get_team_member_wage(id)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

List Workweek Configs

Returns a list of WorkweekConfig instances for a business.

def list_workweek_configs(self,
                         limit=None,
                         cursor=None)

Parameters

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.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type List Workweek Configs Response.

Example Usage

result = labor_api.list_workweek_configs()

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Update Workweek Config

Updates a WorkweekConfig.

def update_workweek_config(self,
                          id,
                          body)

Parameters

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.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Update Workweek Config Response.

Example Usage

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)