You've already forked RekomenciBackend
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
from httpx import AsyncClient, Response
|
|
|
|
|
|
class TestApiGateway:
|
|
def __init__(self, client: AsyncClient) -> None:
|
|
self._client = client
|
|
|
|
async def sign_up_email(self, email: str, password: str) -> Response:
|
|
return await self._client.post(
|
|
"/auth/sign_up/email",
|
|
json={"email": email, "password": password},
|
|
)
|
|
|
|
async def sign_in_email(self, email: str, password: str) -> Response:
|
|
return await self._client.post(
|
|
"/auth/sign_in/email",
|
|
json={"email": email, "password": password},
|
|
)
|
|
|
|
async def get_profile(self, access_token: str | None) -> Response:
|
|
headers = {} if access_token is None else {"Authorization": f"Bearer {access_token}"}
|
|
|
|
return await self._client.get(
|
|
"/profile",
|
|
headers=headers,
|
|
)
|
|
|
|
async def patch_profile(
|
|
self,
|
|
access_token: str | None = None,
|
|
display_name: str | None = None,
|
|
first_name: str | None = None,
|
|
last_name: str | None = None,
|
|
avatar_url: str | None = None,
|
|
phone: str | None = None,
|
|
) -> Response:
|
|
headers = {} if access_token is None else {"Authorization": f"Bearer {access_token}"}
|
|
|
|
return await self._client.patch(
|
|
"/profile",
|
|
json={
|
|
key: value
|
|
for key, value in {
|
|
"display_name": display_name,
|
|
"first_name": first_name,
|
|
"last_name": last_name,
|
|
"avatar_url": avatar_url,
|
|
"phone": phone,
|
|
}.items()
|
|
if value is not None
|
|
},
|
|
headers=headers,
|
|
)
|