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

24 lines
691 B
Python
Raw Normal View History

2023-05-01 20:00:32 +09:00
import sys
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:
print(self.__class__.__name__ + "::" + sys._getframe().f_code.co_name)
url = self.ENTRYPOINT
token_check(self.session)
response = self._get(url)
self._raise_response_error(response)
ret = Laboratories([])
for data in response.json():
ret.append(parse_obj_as(Laboratory, data))
return ret