Переработан эндпоинт getProfile на использование http клиента
All checks were successful
Build And Push / publish (push) Successful in 1m41s
All checks were successful
Build And Push / publish (push) Successful in 1m41s
This commit is contained in:
28
src/clients/vitacore/api.py
Normal file
28
src/clients/vitacore/api.py
Normal file
@ -0,0 +1,28 @@
|
||||
from logging import getLogger
|
||||
|
||||
from fastapi import status as st
|
||||
from httpx import AsyncClient
|
||||
|
||||
from core.config import settings
|
||||
from shared import exceptions as e
|
||||
|
||||
from . import schema as s
|
||||
|
||||
|
||||
class VITACORE_API(AsyncClient):
|
||||
def __init__(self):
|
||||
self.logger = getLogger(__name__)
|
||||
super().__init__(base_url=settings.VITACORE_BASE_URL)
|
||||
|
||||
async def findBySnils(self, snils: str):
|
||||
return
|
||||
|
||||
async def getProfile(self, patId: str):
|
||||
req = await self.get('/getProfile', params={'patId': patId})
|
||||
|
||||
match req.status_code:
|
||||
case st.HTTP_200_OK:
|
||||
return s.ProfileModel.model_validate(req.json())
|
||||
case _:
|
||||
self.logger.error(req.json())
|
||||
raise e.UnknownException
|
||||
Reference in New Issue
Block a user