23 lines
655 B
Python
23 lines
655 B
Python
from abc import ABC
|
|
from typing import Optional
|
|
|
|
import httpx
|
|
|
|
from .client import BaseClient
|
|
|
|
|
|
class HTTPXClient(BaseClient, ABC):
|
|
async def _method(self, method: str, path: str, data: Optional[dict] = None, params: Optional[dict] = None) -> dict:
|
|
async with httpx.AsyncClient() as client:
|
|
url = self.base_url + path
|
|
headers = self.headers
|
|
request = client.build_request(
|
|
method,
|
|
url,
|
|
json=data,
|
|
params=params,
|
|
headers=headers
|
|
)
|
|
response = await client.send(request)
|
|
return response.json()
|