mdrs-client-python/mdrsclient/api/laboratories.py

24 lines
730 B
Python
Raw Permalink Normal View History

2023-05-01 20:00:32 +09:00
from typing import Final
from pydantic import TypeAdapter
2023-05-01 20:00:32 +09:00
from mdrsclient.api.base import BaseApi
from mdrsclient.api.utils import token_check
from mdrsclient.models import Laboratories, Laboratory
2023-12-12 20:05:46 +09:00
class LaboratoriesApi(BaseApi):
ENTRYPOINT: Final[str] = "v3/laboratories/"
2023-05-01 20:00:32 +09:00
def list(self) -> Laboratories:
2023-05-09 19:45:03 +09:00
# print(self.__class__.__name__ + "::" + sys._getframe().f_code.co_name)
2023-05-01 20:00:32 +09:00
url = self.ENTRYPOINT
token_check(self.connection)
2023-05-10 14:46:08 +09:00
response = self.connection.get(url)
2023-05-01 20:00:32 +09:00
self._raise_response_error(response)
2023-05-10 14:46:08 +09:00
ret = Laboratories()
2023-05-01 20:00:32 +09:00
for data in response.json():
ret.append(TypeAdapter(Laboratory).validate_python(data))
ret.sort()
2023-05-01 20:00:32 +09:00
return ret