-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrinet.py
More file actions
27 lines (21 loc) · 896 Bytes
/
trinet.py
File metadata and controls
27 lines (21 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /usr/bin/env python3
import requests
import sys
EMPLOYEE_ID = ""
COMPANY_ID = ""
AUTH_COOKIE = ""
def getPaycheckList():
cookies = dict(TriNetAuthCookie=AUTH_COOKIE)
return requests.get(f"https://trinet.hrpassport.com/api-money/v1/payroll/{COMPANY_ID}/{EMPLOYEE_ID}/paychecks", cookies=cookies).json()["data"]["checkSummaries"]
def downloadPaycheck(paycheck, outdir="./paychecks"):
url = f"https://trinet.hrpassport.com/api-money/v1/payroll/{COMPANY_ID}/{EMPLOYEE_ID}/paycheck-details-pdf/{paycheck['id']}"
cookies = dict(TriNetAuthCookie=AUTH_COOKIE)
r = requests.get(url, cookies=cookies)
with open(f"{outdir}/{paycheck['id']}.pdf", "wb") as out:
out.write(r.content)
def main():
for check in getPaycheckList():
print(f"{check['checkDt']} - {check['netPay']}")
downloadPaycheck(check)
if __name__ == "__main__":
sys.exit(main())