tsheets-sdk

1.0.0 • Public • Published

TSheets Javascript SDK

NPM version NPM downloads Build Status Dependency Status Code Coverage Code Climate License Code Style

Simple client for full access to TSheets REST API.

Authentication

Set the environment variable TSHEETS_TOKEN to a TSheets access token.

Usage

ES6

// Top level import
import TSheets from 'tsheets-sdk'
// or destructured
import { reports, timesheets, groups, jobcodes } from 'tsheets-sdk'

API

Reports

reports.getPayrollReport(params)

Retrieves a payroll report, with filters to narrow down the results.

Example

import { reports } from 'tsheets-sdk'
reports().getPayrollReport()
  .then(report => console.log('report:', report))
  .catch(error => console.error('error getting report:', error))

Params

Parameter Description Type Required
start_date YYYY-MM-DD for the starting date. string Yes
end_date YYYY-MM-DD for the end date. string No
user_ids Array of TSheets user IDs to get time for. number[] No
page Page number for timesheets (max 50 per page). number No

reports.getProjectReport(params)

Retrieves a project report, with filters to narrow down the results.

Example

import { reports } from 'tsheets-sdk'
reports().getProjectReport()
  .then(report => console.log('report:', report))
  .catch(error => console.error('error getting report:', error))

Params

Parameter Description Type Required
start_date YYYY-MM-DD for the starting date. string Yes
end_date YYYY-MM-DD for the end date. string No
user_ids Array of TSheets user IDs to get time for. number[] No
page Page number for timesheets (max 50 per page). number No

reports.getCurrentTotalsReport(params)

Retrieves a current totals report, with filters to narrow down the results.

Example

import { reports } from 'tsheets-sdk'
reports().getCurrentTotalsReport()
  .then(report => console.log('report:', report))
  .catch(error => console.error('error getting report:', error))

Params

Parameter Description Type Required
start_date YYYY-MM-DD for the starting date. string Yes
end_date YYYY-MM-DD for the end date. string No
user_ids Array of TSheets user IDs to get time for. number[] No
page Page number for timesheets (max 50 per page). number No

Timesheets

timesheets.get(params)

Gets timesheets for the specified user(s) for the provided time period.

Example

 
import { timesheets } from 'tsheets-sdk'
// Can be imported from top level as well
// import Tsheets from 'tsheets-sdk'
// const { timesheets } = Tsheets
 
timesheets().get()
  .then(report => console.log('timesheets:', timesheets))
  .catch(error => console.error('error getting timesheets:', error))

Params

Parameter Description Type Required
start_date YYYY-MM-DD for the starting date. string Yes
end_date YYYY-MM-DD for the end date. string Yes
user_ids Array of TSheets user IDs to get timesheets for. number[] No
page Page number for timesheets (max 50 per page). number No

Jobcodes

jobcodes.get(params)

Gets jobcodes for the specified user(s) for the provided time period.

Example

import { reports } from 'tsheets-sdk'
jobcodes().get()
  .then(report => console.log('jobcodes:', jobcodes))
  .catch(error => console.error('error getting jobcodes:', error))

Params

Parameter Description Type Required
start_date YYYY-MM-DD for the starting date. string Yes
end_date YYYY-MM-DD for the end date. string Yes
user_ids Array of TSheets user IDs to get jobcodes for. number[] No
page Page number for jobcodes (max 50 per page). number No

Users

users.get(params)

Gets users for the specified filters.

Example

import { reports } from 'tsheets-sdk'
const start_date = '2016-01-01'
users().get({ start_date })
  .then(report => console.log('users:', users))
  .catch(error => console.error('error getting users:', error))

Params

Parameter Description Type Required
start_date YYYY-MM-DD for the starting date. string Yes
end_date YYYY-MM-DD for the end date. string Yes
user_ids Array of TSheets user IDs to get users for. number[] No
page Page number for users (max 50 per page). number No

Groups

groups.get(params)

Gets groups based on filters.

Example

import { reports } from 'tsheets-sdk'
const start_date = '2016-01-01'
groups().get({ start_date })
  .then(report => console.log('groups:', groups))
  .catch(error => console.error('error getting groups:', error))

Params

Parameter Description Type Required
start_date YYYY-MM-DD for the starting date. string Yes
end_date YYYY-MM-DD for the end date. string Yes
user_ids Array of TSheets user IDs to get groups for. number[] No
page Page number for groups (max 50 per page). number No

Contribution

Note: Make sure you set the environment variable TSHEETS_TOKEN as described above or tests will not run.

  1. Install dependencies: npm install
  2. Check/Remove lint using: npm run lint:fix
  3. Run tests using: npm run test
  4. Create a Pull Request with your changes

License

MIT © Scott Prue

Readme

Keywords

Package Sidebar

Install

npm i tsheets-sdk

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

36.1 kB

Total Files

25

Last publish

Collaborators

  • prescottprue