Skip to content

Latest commit

 

History

History
751 lines (527 loc) · 18.2 KB

labor.md

File metadata and controls

751 lines (527 loc) · 18.2 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(location_id: nil,
                     limit: nil,
                     cursor: nil)

Parameters

Parameter Type Tags Description
location_id String Query, Optional Filter the returned BreakType results to only those that are associated with the
specified location.
limit Integer 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 String Query, Optional A pointer to the next page of BreakType results to fetch.

Response Type

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

Example Usage

result = labor_api.list_break_types

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

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(body:)

Parameters

Parameter Type Tags Description
body Create Break Type Request Hash 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 data property in this instance returns the response data which is of type Create Break Type Response Hash.

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: body)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

Delete Break Type

Deletes an existing BreakType.

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

def delete_break_type(id:)

Parameters

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

Response Type

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

Example Usage

id = 'id0'


result = labor_api.delete_break_type(id: id)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

Get Break Type

Returns a single BreakType specified by id.

def get_break_type(id:)

Parameters

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

Response Type

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

Example Usage

id = 'id0'


result = labor_api.get_break_type(id: id)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

Update Break Type

Updates an existing BreakType.

def update_break_type(id:,
                      body:)

Parameters

Parameter Type Tags Description
id String Template, Required The UUID for the BreakType being updated.
body Update Break Type Request Hash 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 data property in this instance returns the response data which is of type Update Break Type Response Hash.

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: id,
  body: body
)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

List Employee Wages

This endpoint is deprecated.

Returns a paginated list of EmployeeWage instances for a business.

def list_employee_wages(employee_id: nil,
                        limit: nil,
                        cursor: nil)

Parameters

Parameter Type Tags Description
employee_id String Query, Optional Filter the returned wages to only those that are associated with the specified employee.
limit Integer 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 String Query, Optional A pointer to the next page of EmployeeWage results to fetch.

Response Type

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

Example Usage

result = labor_api.list_employee_wages

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

Get Employee Wage

This endpoint is deprecated.

Returns a single EmployeeWage specified by id.

def get_employee_wage(id:)

Parameters

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

Response Type

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

Example Usage

id = 'id0'


result = labor_api.get_employee_wage(id: id)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

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(body:)

Parameters

Parameter Type Tags Description
body Create Shift Request Hash 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 data property in this instance returns the response data which is of type Create Shift Response Hash.

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: body)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

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(body:)

Parameters

Parameter Type Tags Description
body Search Shifts Request Hash 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 data property in this instance returns the response data which is of type Search Shifts Response Hash.

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: body)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

Delete Shift

Deletes a Shift.

def delete_shift(id:)

Parameters

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

Response Type

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

Example Usage

id = 'id0'


result = labor_api.delete_shift(id: id)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

Get Shift

Returns a single Shift specified by id.

def get_shift(id:)

Parameters

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

Response Type

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

Example Usage

id = 'id0'


result = labor_api.get_shift(id: id)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

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(id:,
                 body:)

Parameters

Parameter Type Tags Description
id String Template, Required The ID of the object being updated.
body Update Shift Request Hash 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 data property in this instance returns the response data which is of type Update Shift Response Hash.

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: id,
  body: body
)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

List Team Member Wages

Returns a paginated list of TeamMemberWage instances for a business.

def list_team_member_wages(team_member_id: nil,
                           limit: nil,
                           cursor: nil)

Parameters

Parameter Type Tags Description
team_member_id String Query, Optional Filter the returned wages to only those that are associated with the
specified team member.
limit Integer 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 String Query, Optional A pointer to the next page of EmployeeWage results to fetch.

Response Type

This method returns a \ApiResponse instance. The data property in this instance returns the response data which is of type List Team Member Wages Response Hash.

Example Usage

result = labor_api.list_team_member_wages

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

Get Team Member Wage

Returns a single TeamMemberWage specified by id.

def get_team_member_wage(id:)

Parameters

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

Response Type

This method returns a \ApiResponse instance. The data property in this instance returns the response data which is of type Get Team Member Wage Response Hash.

Example Usage

id = 'id0'


result = labor_api.get_team_member_wage(id: id)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

List Workweek Configs

Returns a list of WorkweekConfig instances for a business.

def list_workweek_configs(limit: nil,
                          cursor: nil)

Parameters

Parameter Type Tags Description
limit Integer Query, Optional The maximum number of WorkweekConfigs results to return per page.
cursor String Query, Optional A pointer to the next page of WorkweekConfig results to fetch.

Response Type

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

Example Usage

result = labor_api.list_workweek_configs

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

Update Workweek Config

Updates a WorkweekConfig.

def update_workweek_config(id:,
                           body:)

Parameters

Parameter Type Tags Description
id String Template, Required The UUID for the WorkweekConfig object being updated.
body Update Workweek Config Request Hash 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 data property in this instance returns the response data which is of type Update Workweek Config Response Hash.

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: id,
  body: body
)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end