2023-05-01 20:00:32 +09:00
|
|
|
from typing import Final
|
|
|
|
|
2023-07-19 14:43:16 +09:00
|
|
|
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
|
2023-05-09 13:08:50 +09:00
|
|
|
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():
|
2023-07-19 14:43:16 +09:00
|
|
|
ret.append(TypeAdapter(Laboratory).validate_python(data))
|
2023-06-04 18:53:21 +09:00
|
|
|
ret.sort()
|
2023-05-01 20:00:32 +09:00
|
|
|
return ret
|