from typing import Any from httpx import AsyncClient, Response def make_auth_headers(access_token: str | None) -> dict[str, Any]: return {} if access_token is None else {"Authorization": f"Bearer {access_token}"} 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: return await self._client.get( "/profile", headers=make_auth_headers(access_token), ) 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: 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=make_auth_headers(access_token), ) async def create_resume( self, access_token: str, position: str, about_me: str, key_skills: list[str], experience_type: str, ) -> Response: return await self._client.post( "/resume", json={ "position": position, "about_me": about_me, "key_skills": key_skills, "experience_type": experience_type, }, headers=make_auth_headers(access_token), ) async def get_resume(self, access_token: str, resume_id: str) -> Response: return await self._client.get( f"/resume/{resume_id}", headers=make_auth_headers(access_token), )