用于以编程方式获取数据并将数据提交给Intertec TimePro的实用程序(timesheets.com.au)
timepro-timesheet的Python项目详细描述
Intertec TimePro实用程序
说明
以编程方式获取时间表数据并将其提交给Intertec TimePro(timesheets.com.au)
安装
安装时使用pip
:
pip install timepro-timesheet
用法
命令行
获取数据
安装后,可以使用cli将时间表数据获取为json。
$ timepro get -c CUST -u john.doe -p password123 {"2018-08-04": [{"customer_code": "EXAMPLE", "customer_description": "Example Company Pty Ltd", "project_code": "EX-123", "project_psid": "EX-123{:}1", "project_description": "EXAMPLE - EX-123 - SOW000 - Important Business Stuff - PO 123", "task_id": null, "task_description": null, "hours": 8}]}
您可以通过指定--start
和--end
的日期,或者使用--this-week
、--this-month
、--last-week
或--last-month
标志筛选时间表期间。默认情况下,将返回当前周的时间表条目。
发布数据
可以通过读取json文件提交数据。
$ timepro post -c CUST -u john.doe -p password123 -f timesheet_entries.json
或
$ cat timesheet_entries.json | timepro post -c CUST -u john.doe -p password123
Python
fromtimepro_timesheet.apiimportTimesheetAPI# Log into timesheets.com.au via the TimesheetAPI classapi=TimesheetAPI()api.login(customer_id='CUST',username='john.doe',password='password123')# Get timesheet (defaults to current month)timesheet=api.get_timesheet()# Get timesheet for a given datetimesheet=api.get_timesheet(start_date=date(2018,6,1),end_date=date(2018,6,25))# Output timesheettimesheet.json()timesheet.row_entries()timesheet.date_entries()