diff --git a/src/api/base.py b/src/api/base.py new file mode 100644 index 0000000..49d231f --- /dev/null +++ b/src/api/base.py @@ -0,0 +1,32 @@ +import httpx +from abc import ABC, abstractmethod +from typing import Any, Dict, List, Optional + + +class APIClient(ABC): + def __init__(self, base_url: str, token: str): + self.base_url = base_url + self.token = token + self.headers = { + "Authorization": f"Bearer {token}", + "Accept": "application/json", + } + + @abstractmethod + async def get_pull_requests(self, owner: str, repo: str) -> List[Dict[str, Any]]: + pass + + @abstractmethod + async def get_issues(self, owner: str, repo: str) -> List[Dict[str, Any]]: + pass + + @abstractmethod + async def get_workflows(self, owner: str, repo: str) -> List[Dict[str, Any]]: + pass + + async def _request( + self, client: httpx.AsyncClient, method: str, url: str, **kwargs + ) -> httpx.Response: + response = await client.request(method, url, **kwargs) + response.raise_for_status() + return response