Skip to content

Commit

Permalink
[person] add new function: gazu.person.get_department + refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBldy committed Aug 7, 2024
1 parent 26071e4 commit 42dc6e3
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions gazu/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,35 @@ def get_all_month_time_spents(id, date, client=default):
client=client,
)


@cache
def get_department_by_name(name, client=default):
"""
Args:
name (str): department name.
name (str): Department name.
Returns:
dict: department corresponding to given name.
dict: Department corresponding to given name.
"""
return raw.fetch_first(
"departments",
{"name": name},
client=client,
)


@cache
def get_department(id, client=default):
"""
Args:
id (str): An uuid identifying a department.
Returns:
dict: Department corresponding to given id.
"""
return raw.fetch_first("departments", {"id": id}, client=client)


@cache
def get_person(id, relations=False, client=default):
"""
Expand Down Expand Up @@ -196,14 +210,9 @@ def get_organisation(client=default):
return raw.get("auth/authenticated", client=client)["organisation"]


def new_department(
name,
color="",
archived=False,
client=default
):
def new_department(name, color="", archived=False, client=default):
"""
Create a new departement based on given parameters.
Create a new departement based on given parameters.
Args:
name (str): the name of the departement.
Expand All @@ -216,15 +225,12 @@ def new_department(
if department is None:
department = raw.post(
"data/departments",
{
"name": name,
"color": color,
"archived": archived
},
{"name": name, "color": color, "archived": archived},
client=client,
)
return department


def new_person(
first_name,
last_name,
Expand Down

0 comments on commit 42dc6e3

Please sign in to comment.