Skip to content

Commit

Permalink
Get project work packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Oluwafemi Adenuga authored Jan 26, 2024
2 parents 25cd52b + b091236 commit 10fbf67
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions openproject/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import httpx
from openproject.exceptions import APIError, AuthenticationError
from openproject.types import WorkPackage, Project
import json


class Client:
Expand Down Expand Up @@ -86,8 +87,12 @@ def _api_payload_from_kwargs(self, **kwargs: WorkPackage):
data = {api_args: kwargs[args] for args, api_args in items if args in kwargs}
return data

def list(self):
return self.client._send_request("GET", "work_packages")
def list(self, project: int | None):
params = {}
if project:
filters = [{"project": {"operator": "=", "values": project}}]
params = {"filters": json.dumps(filters)}
return self.client._send_request("GET", "work_packages", params=params)

def view(self, id: int):
return self.client._send_request("GET", f"work_packages/{id}")
Expand Down

0 comments on commit 10fbf67

Please sign in to comment.