Skip to content

Commit a37b028

Browse files
Added get customers, plans and workload schemes.
1 parent 5f56658 commit a37b028

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ tempo = client.Tempo(
2525
auth_token="<your_tempo_api_key>",
2626
base_url="https://api.tempo.io/core/3")
2727
28-
worklogs = tempo.get_all_worklogs(
29-
date_from="2019-11-10",
30-
date_to="2019-11-11"
28+
worklogs = tempo.get_worklogs(
29+
dateFrom="2019-11-10",
30+
dateTo="2019-11-11"
3131
)
3232
3333
for i in worklogs:

tempoapiclient/client.py

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,32 @@ def get_account_category_types(self):
107107

108108
# Customers
109109

110-
## TBD
110+
def get_customers(self, key=None):
111+
112+
"""
113+
Retrieve all customers or customer with ```key```.
114+
"""
115+
116+
url = "/customers"
117+
if key:
118+
url += f"/{key}"
119+
return self._list(url)
111120

112121

113122
# Plans
114123

115-
## TBD
124+
def get_plans(self, id=None, userId=None):
125+
126+
"""
127+
Retrieve plans or plan with ```id``` or plan for ```userId````.
128+
"""
129+
130+
url = "/plans"
131+
if id:
132+
url += f"/{id}"
133+
elif userId:
134+
url += f"/plans/user/{userId}"
135+
return self._list(url)
116136

117137

118138
# Programs
@@ -129,7 +149,7 @@ def get_account_category_types(self):
129149

130150
def get_teams(self, teamId=None):
131151
"""
132-
Returns ```teams```.
152+
Returns ```teams``` or the details of team ```teamId```.
133153
"""
134154

135155
url = f"/teams"
@@ -140,7 +160,7 @@ def get_teams(self, teamId=None):
140160

141161
def get_team_members(self, teamId):
142162
"""
143-
Returns members for particular ```team```.
163+
Returns members for particular ```teamId```.
144164
"""
145165

146166
url = f"/teams/{teamId}/members"
@@ -193,11 +213,19 @@ def get_periods(self, dateFrom, dateTo):
193213
# Timesheet Approvals
194214

195215
def get_timesheet_approvals_waiting(self):
216+
"""
217+
Retrieve waiting timesheet approvals
218+
"""
219+
196220
url = f"/timesheet-approvals/waiting"
197221
params = { "limit": self.MAX_RESULTS }
198222
return self._list(url, **params)
199223

200224
def get_timesheet_approvals(self, dateFrom=None, dateTo=None, userId=None, teamId=None):
225+
"""
226+
Retrieve timesheet approval between ```dateFrom``` and ```dateTo``` if specified; or for ```userId``` or ```teamId```.
227+
"""
228+
201229
params = {}
202230
if dateFrom:
203231
params["from"] = self._resolve_date(dateFrom).isoformat()
@@ -233,14 +261,13 @@ def get_user_schedule(self, dateFrom, dateTo, userId=None):
233261

234262
def get_work_attributes(self):
235263
"""
236-
Returns worklog attributes inside ```dateFrom``` and ```dateTo```,
237-
for particular ```user```, adding work attributes if ```add_work_attributes```.
264+
Returns worklog attributes.
238265
"""
239266
return { x["key"]: x for x in self._list("/work-attributes") }
240267

241268
def add_worklog_attributes(self, worklogs):
242269
"""
243-
Return worklogs with added worklog attributes, destroys worklogs.
270+
Update worklog attributes in worklogs.
244271
"""
245272

246273
if not self.work_attributes:
@@ -262,7 +289,11 @@ def add_worklog_attributes(self, worklogs):
262289

263290
# Workload Schemes
264291

265-
## TBD
292+
def get_workload_schemes(self, id=None):
293+
url = f"/workload-schemes"
294+
if id:
295+
url += f"/{id}"
296+
return self._list(url)
266297

267298
# Holiday Schemes
268299

0 commit comments

Comments
 (0)