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

23 lines
693 B
Python
Raw Normal View History

2023-05-01 20:00:32 +09:00
from typing import Final
from pydantic import parse_obj_as
from mdrsclient.api.base import BaseApi
from mdrsclient.api.utils import token_check
from mdrsclient.models import Laboratories, Laboratory
class LaboratoryApi(BaseApi):
ENTRYPOINT: Final[str] = "v2/laboratory/"
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(parse_obj_as(Laboratory, data))
return ret