From 6934fd777ff4ba584d4aa982fb221c6ef7129cd8 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 25 Apr 2023 02:25:05 +0000 Subject: [PATCH] Release 0.0.1 --- .github/workflows/ci.yml | 45 +++++++ .gitignore | 4 + pyproject.toml | 23 ++++ src/metriport/__init__.py | 23 ++++ src/metriport/client.py | 25 ++++ src/metriport/core/__init__.py | 8 ++ src/metriport/core/api_error.py | 15 +++ src/metriport/core/datetime_utils.py | 28 ++++ src/metriport/core/jsonable_encoder.py | 94 +++++++++++++ .../core/remove_none_from_headers.py | 11 ++ src/metriport/py.typed | 0 src/metriport/resources/__init__.py | 23 ++++ src/metriport/resources/document/__init__.py | 21 +++ src/metriport/resources/document/client.py | 123 ++++++++++++++++++ .../resources/document/types/__init__.py | 19 +++ .../document/types/codeable_concept.py | 26 ++++ .../resources/document/types/coding.py | 26 ++++ .../resources/document/types/document.py | 34 +++++ .../types/download_document_response.py | 24 ++++ .../document/types/get_documents_response.py | 28 ++++ .../resources/document/types/query_status.py | 17 +++ .../types/trigger_documents_query_response.py | 26 ++++ 22 files changed, 643 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 pyproject.toml create mode 100644 src/metriport/__init__.py create mode 100644 src/metriport/client.py create mode 100644 src/metriport/core/__init__.py create mode 100644 src/metriport/core/api_error.py create mode 100644 src/metriport/core/datetime_utils.py create mode 100644 src/metriport/core/jsonable_encoder.py create mode 100644 src/metriport/core/remove_none_from_headers.py create mode 100644 src/metriport/py.typed create mode 100644 src/metriport/resources/__init__.py create mode 100644 src/metriport/resources/document/__init__.py create mode 100644 src/metriport/resources/document/client.py create mode 100644 src/metriport/resources/document/types/__init__.py create mode 100644 src/metriport/resources/document/types/codeable_concept.py create mode 100644 src/metriport/resources/document/types/coding.py create mode 100644 src/metriport/resources/document/types/document.py create mode 100644 src/metriport/resources/document/types/download_document_response.py create mode 100644 src/metriport/resources/document/types/get_documents_response.py create mode 100644 src/metriport/resources/document/types/query_status.py create mode 100644 src/metriport/resources/document/types/trigger_documents_query_response.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b2c1727 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: ci + +on: [push] +jobs: + compile: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: 3.7 + - name: Bootstrap poetry + run: | + curl -sSL https://install.python-poetry.org | python - -y + - name: Install dependencies + run: poetry install + - name: Compile + run: poetry run mypy . + + publish: + needs: [ compile ] + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: 3.7 + - name: Bootstrap poetry + run: | + curl -sSL https://install.python-poetry.org | python - -y + - name: Install dependencies + run: poetry install + - name: Publish to pypi + run: | + poetry config repositories.remote https://upload.pypi.org/legacy/ + poetry --no-interaction -v publish --build --repository remote --username "$PYPI_USERNAME" --password "$PYPI_PASSWORD" + env: + PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..42cb863 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +dist/ +.mypy_cache/ +__pycache__/ +poetry.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f4082dd --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,23 @@ + +[tool.poetry] +name = "fern-metriport" +version = "0.0.1" +description = "" +authors = [] +packages = [ + { include = "metriport", from = "src"} +] + +[tool.poetry.dependencies] +python = "^3.7" +pydantic = "^1.9.2" +types-backports = "0.1.3" +backports-cached_property = "1.0.2" +httpx = "0.23.3" + +[tool.poetry.dev-dependencies] +mypy = "0.971" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/src/metriport/__init__.py b/src/metriport/__init__.py new file mode 100644 index 0000000..7320a45 --- /dev/null +++ b/src/metriport/__init__.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +from .resources import ( + CodeableConcept, + Coding, + Document, + DownloadDocumentResponse, + GetDocumentsResponse, + QueryStatus, + TriggerDocumentsQueryResponse, + document, +) + +__all__ = [ + "CodeableConcept", + "Coding", + "Document", + "DownloadDocumentResponse", + "GetDocumentsResponse", + "QueryStatus", + "TriggerDocumentsQueryResponse", + "document", +] diff --git a/src/metriport/client.py b/src/metriport/client.py new file mode 100644 index 0000000..be44f2a --- /dev/null +++ b/src/metriport/client.py @@ -0,0 +1,25 @@ +# This file was auto-generated by Fern from our API Definition. + +from backports.cached_property import cached_property + +from .resources.document.client import AsyncDocumentClient, DocumentClient + + +class MetriportApi: + def __init__(self, *, environment: str, api_key: str): + self._environment = environment + self.api_key = api_key + + @cached_property + def document(self) -> DocumentClient: + return DocumentClient(environment=self._environment, api_key=self.api_key) + + +class AsyncMetriportApi: + def __init__(self, *, environment: str, api_key: str): + self._environment = environment + self.api_key = api_key + + @cached_property + def document(self) -> AsyncDocumentClient: + return AsyncDocumentClient(environment=self._environment, api_key=self.api_key) diff --git a/src/metriport/core/__init__.py b/src/metriport/core/__init__.py new file mode 100644 index 0000000..b213a1a --- /dev/null +++ b/src/metriport/core/__init__.py @@ -0,0 +1,8 @@ +# This file was auto-generated by Fern from our API Definition. + +from .api_error import ApiError +from .datetime_utils import serialize_datetime +from .jsonable_encoder import jsonable_encoder +from .remove_none_from_headers import remove_none_from_headers + +__all__ = ["ApiError", "jsonable_encoder", "remove_none_from_headers", "serialize_datetime"] diff --git a/src/metriport/core/api_error.py b/src/metriport/core/api_error.py new file mode 100644 index 0000000..2e9fc54 --- /dev/null +++ b/src/metriport/core/api_error.py @@ -0,0 +1,15 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + + +class ApiError(Exception): + status_code: typing.Optional[int] + body: typing.Any + + def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None): + self.status_code = status_code + self.body = body + + def __str__(self) -> str: + return f"status_code: {self.status_code}, body: {self.body}" diff --git a/src/metriport/core/datetime_utils.py b/src/metriport/core/datetime_utils.py new file mode 100644 index 0000000..7c9864a --- /dev/null +++ b/src/metriport/core/datetime_utils.py @@ -0,0 +1,28 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt + + +def serialize_datetime(v: dt.datetime) -> str: + """ + Serialize a datetime including timezone info. + + Uses the timezone info provided if present, otherwise uses the current runtime's timezone info. + + UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00. + """ + + def _serialize_zoned_datetime(v: dt.datetime) -> str: + if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None): + # UTC is a special case where we use "Z" at the end instead of "+00:00" + return v.isoformat().replace("+00:00", "Z") + else: + # Delegate to the typical +/- offset format + return v.isoformat() + + if v.tzinfo is not None: + return _serialize_zoned_datetime(v) + else: + local_tz = dt.datetime.now().astimezone().tzinfo + localized_dt = v.replace(tzinfo=local_tz) + return _serialize_zoned_datetime(localized_dt) diff --git a/src/metriport/core/jsonable_encoder.py b/src/metriport/core/jsonable_encoder.py new file mode 100644 index 0000000..ed5a43e --- /dev/null +++ b/src/metriport/core/jsonable_encoder.py @@ -0,0 +1,94 @@ +# This file was auto-generated by Fern from our API Definition. + +""" +jsonable_encoder converts a Python object to a JSON-friendly dict +(e.g. datetimes to strings, Pydantic models to dicts). + +Taken from FastAPI, and made a bit simpler +https://github.com/tiangolo/fastapi/blob/master/fastapi/encoders.py +""" + +import dataclasses +from collections import defaultdict +from enum import Enum +from pathlib import PurePath +from types import GeneratorType +from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union + +from pydantic import BaseModel +from pydantic.json import ENCODERS_BY_TYPE + +SetIntStr = Set[Union[int, str]] +DictIntStrAny = Dict[Union[int, str], Any] + + +def generate_encoders_by_class_tuples( + type_encoder_map: Dict[Any, Callable[[Any], Any]] +) -> Dict[Callable[[Any], Any], Tuple[Any, ...]]: + encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict(tuple) + for type_, encoder in type_encoder_map.items(): + encoders_by_class_tuples[encoder] += (type_,) + return encoders_by_class_tuples + + +encoders_by_class_tuples = generate_encoders_by_class_tuples(ENCODERS_BY_TYPE) + + +def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any: + custom_encoder = custom_encoder or {} + if custom_encoder: + if type(obj) in custom_encoder: + return custom_encoder[type(obj)](obj) + else: + for encoder_type, encoder_instance in custom_encoder.items(): + if isinstance(obj, encoder_type): + return encoder_instance(obj) + if isinstance(obj, BaseModel): + encoder = getattr(obj.__config__, "json_encoders", {}) + if custom_encoder: + encoder.update(custom_encoder) + obj_dict = obj.dict(by_alias=True) + if "__root__" in obj_dict: + obj_dict = obj_dict["__root__"] + return jsonable_encoder(obj_dict, custom_encoder=encoder) + if dataclasses.is_dataclass(obj): + obj_dict = dataclasses.asdict(obj) + return jsonable_encoder(obj_dict, custom_encoder=custom_encoder) + if isinstance(obj, Enum): + return obj.value + if isinstance(obj, PurePath): + return str(obj) + if isinstance(obj, (str, int, float, type(None))): + return obj + if isinstance(obj, dict): + encoded_dict = {} + allowed_keys = set(obj.keys()) + for key, value in obj.items(): + if key in allowed_keys: + encoded_key = jsonable_encoder(key, custom_encoder=custom_encoder) + encoded_value = jsonable_encoder(value, custom_encoder=custom_encoder) + encoded_dict[encoded_key] = encoded_value + return encoded_dict + if isinstance(obj, (list, set, frozenset, GeneratorType, tuple)): + encoded_list = [] + for item in obj: + encoded_list.append(jsonable_encoder(item, custom_encoder=custom_encoder)) + return encoded_list + + if type(obj) in ENCODERS_BY_TYPE: + return ENCODERS_BY_TYPE[type(obj)](obj) + for encoder, classes_tuple in encoders_by_class_tuples.items(): + if isinstance(obj, classes_tuple): + return encoder(obj) + + try: + data = dict(obj) + except Exception as e: + errors: List[Exception] = [] + errors.append(e) + try: + data = vars(obj) + except Exception as e: + errors.append(e) + raise ValueError(errors) from e + return jsonable_encoder(data, custom_encoder=custom_encoder) diff --git a/src/metriport/core/remove_none_from_headers.py b/src/metriport/core/remove_none_from_headers.py new file mode 100644 index 0000000..21a44ca --- /dev/null +++ b/src/metriport/core/remove_none_from_headers.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +from typing import Dict, Optional + + +def remove_none_from_headers(headers: Dict[str, Optional[str]]) -> Dict[str, str]: + new_headers: Dict[str, str] = {} + for header_key, header_value in headers.items(): + if header_value is not None: + new_headers[header_key] = header_value + return new_headers diff --git a/src/metriport/py.typed b/src/metriport/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/src/metriport/resources/__init__.py b/src/metriport/resources/__init__.py new file mode 100644 index 0000000..66ce54b --- /dev/null +++ b/src/metriport/resources/__init__.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +from . import document +from .document import ( + CodeableConcept, + Coding, + Document, + DownloadDocumentResponse, + GetDocumentsResponse, + QueryStatus, + TriggerDocumentsQueryResponse, +) + +__all__ = [ + "CodeableConcept", + "Coding", + "Document", + "DownloadDocumentResponse", + "GetDocumentsResponse", + "QueryStatus", + "TriggerDocumentsQueryResponse", + "document", +] diff --git a/src/metriport/resources/document/__init__.py b/src/metriport/resources/document/__init__.py new file mode 100644 index 0000000..3f07208 --- /dev/null +++ b/src/metriport/resources/document/__init__.py @@ -0,0 +1,21 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import ( + CodeableConcept, + Coding, + Document, + DownloadDocumentResponse, + GetDocumentsResponse, + QueryStatus, + TriggerDocumentsQueryResponse, +) + +__all__ = [ + "CodeableConcept", + "Coding", + "Document", + "DownloadDocumentResponse", + "GetDocumentsResponse", + "QueryStatus", + "TriggerDocumentsQueryResponse", +] diff --git a/src/metriport/resources/document/client.py b/src/metriport/resources/document/client.py new file mode 100644 index 0000000..d864dbf --- /dev/null +++ b/src/metriport/resources/document/client.py @@ -0,0 +1,123 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +import urllib.parse +from json.decoder import JSONDecodeError + +import httpx +import pydantic + +from ...core.api_error import ApiError +from ...core.remove_none_from_headers import remove_none_from_headers +from .types.download_document_response import DownloadDocumentResponse +from .types.get_documents_response import GetDocumentsResponse +from .types.trigger_documents_query_response import TriggerDocumentsQueryResponse + + +class DocumentClient: + def __init__(self, *, environment: str, api_key: str): + self._environment = environment + self.api_key = api_key + + def get( + self, *, patient_id: str, facility_id: str, force_query: typing.Optional[str] = None + ) -> GetDocumentsResponse: + _response = httpx.request( + "GET", + urllib.parse.urljoin(f"{self._environment}/", "medical/v1/document"), + params={"patientId": patient_id, "facilityId": facility_id, "forceQuery": force_query}, + headers=remove_none_from_headers({"X-API-Key": self.api_key}), + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(GetDocumentsResponse, _response.json()) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def trigger_query(self, *, patient_id: str, facility_id: str) -> TriggerDocumentsQueryResponse: + _response = httpx.request( + "POST", + urllib.parse.urljoin(f"{self._environment}/", "medical/v1/document/query"), + params={"patientId": patient_id, "facilityId": facility_id}, + headers=remove_none_from_headers({"X-API-Key": self.api_key}), + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(TriggerDocumentsQueryResponse, _response.json()) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def download(self, *, file_name: str) -> DownloadDocumentResponse: + _response = httpx.request( + "POST", + urllib.parse.urljoin(f"{self._environment}/", "medical/v1/document/downloadUrl"), + params={"fileName": file_name}, + headers=remove_none_from_headers({"X-API-Key": self.api_key}), + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(DownloadDocumentResponse, _response.json()) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + +class AsyncDocumentClient: + def __init__(self, *, environment: str, api_key: str): + self._environment = environment + self.api_key = api_key + + async def get( + self, *, patient_id: str, facility_id: str, force_query: typing.Optional[str] = None + ) -> GetDocumentsResponse: + async with httpx.AsyncClient() as _client: + _response = await _client.request( + "GET", + urllib.parse.urljoin(f"{self._environment}/", "medical/v1/document"), + params={"patientId": patient_id, "facilityId": facility_id, "forceQuery": force_query}, + headers=remove_none_from_headers({"X-API-Key": self.api_key}), + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(GetDocumentsResponse, _response.json()) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def trigger_query(self, *, patient_id: str, facility_id: str) -> TriggerDocumentsQueryResponse: + async with httpx.AsyncClient() as _client: + _response = await _client.request( + "POST", + urllib.parse.urljoin(f"{self._environment}/", "medical/v1/document/query"), + params={"patientId": patient_id, "facilityId": facility_id}, + headers=remove_none_from_headers({"X-API-Key": self.api_key}), + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(TriggerDocumentsQueryResponse, _response.json()) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def download(self, *, file_name: str) -> DownloadDocumentResponse: + async with httpx.AsyncClient() as _client: + _response = await _client.request( + "POST", + urllib.parse.urljoin(f"{self._environment}/", "medical/v1/document/downloadUrl"), + params={"fileName": file_name}, + headers=remove_none_from_headers({"X-API-Key": self.api_key}), + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(DownloadDocumentResponse, _response.json()) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/metriport/resources/document/types/__init__.py b/src/metriport/resources/document/types/__init__.py new file mode 100644 index 0000000..87b9118 --- /dev/null +++ b/src/metriport/resources/document/types/__init__.py @@ -0,0 +1,19 @@ +# This file was auto-generated by Fern from our API Definition. + +from .codeable_concept import CodeableConcept +from .coding import Coding +from .document import Document +from .download_document_response import DownloadDocumentResponse +from .get_documents_response import GetDocumentsResponse +from .query_status import QueryStatus +from .trigger_documents_query_response import TriggerDocumentsQueryResponse + +__all__ = [ + "CodeableConcept", + "Coding", + "Document", + "DownloadDocumentResponse", + "GetDocumentsResponse", + "QueryStatus", + "TriggerDocumentsQueryResponse", +] diff --git a/src/metriport/resources/document/types/codeable_concept.py b/src/metriport/resources/document/types/codeable_concept.py new file mode 100644 index 0000000..0849fa4 --- /dev/null +++ b/src/metriport/resources/document/types/codeable_concept.py @@ -0,0 +1,26 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic + +from ....core.datetime_utils import serialize_datetime +from .coding import Coding + + +class CodeableConcept(pydantic.BaseModel): + coding: typing.Optional[typing.List[Coding]] + text: typing.Optional[str] + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().dict(**kwargs_with_defaults) + + class Config: + frozen = True + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/metriport/resources/document/types/coding.py b/src/metriport/resources/document/types/coding.py new file mode 100644 index 0000000..963d795 --- /dev/null +++ b/src/metriport/resources/document/types/coding.py @@ -0,0 +1,26 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic + +from ....core.datetime_utils import serialize_datetime + + +class Coding(pydantic.BaseModel): + system: typing.Optional[str] + code: typing.Optional[str] + display: typing.Optional[str] + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().dict(**kwargs_with_defaults) + + class Config: + frozen = True + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/metriport/resources/document/types/document.py b/src/metriport/resources/document/types/document.py new file mode 100644 index 0000000..971ad1e --- /dev/null +++ b/src/metriport/resources/document/types/document.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic + +from ....core.datetime_utils import serialize_datetime +from .codeable_concept import CodeableConcept + + +class Document(pydantic.BaseModel): + id: str + file_name: str = pydantic.Field(alias="fileName") + location: str + description: typing.Optional[str] + status: typing.Optional[str] + indexed: typing.Optional[dt.datetime] + mime_type: typing.Optional[str] = pydantic.Field(alias="mimeType") + size: typing.Optional[int] = pydantic.Field(description=("size of document in bytes\n")) + type: typing.Optional[CodeableConcept] + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().dict(**kwargs_with_defaults) + + class Config: + frozen = True + allow_population_by_field_name = True + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/metriport/resources/document/types/download_document_response.py b/src/metriport/resources/document/types/download_document_response.py new file mode 100644 index 0000000..be344f4 --- /dev/null +++ b/src/metriport/resources/document/types/download_document_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic + +from ....core.datetime_utils import serialize_datetime + + +class DownloadDocumentResponse(pydantic.BaseModel): + url: str + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().dict(**kwargs_with_defaults) + + class Config: + frozen = True + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/metriport/resources/document/types/get_documents_response.py b/src/metriport/resources/document/types/get_documents_response.py new file mode 100644 index 0000000..a5bf708 --- /dev/null +++ b/src/metriport/resources/document/types/get_documents_response.py @@ -0,0 +1,28 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic + +from ....core.datetime_utils import serialize_datetime +from .document import Document +from .query_status import QueryStatus + + +class GetDocumentsResponse(pydantic.BaseModel): + query_status: QueryStatus = pydantic.Field(alias="queryStatus") + documents: typing.List[Document] + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().dict(**kwargs_with_defaults) + + class Config: + frozen = True + allow_population_by_field_name = True + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/metriport/resources/document/types/query_status.py b/src/metriport/resources/document/types/query_status.py new file mode 100644 index 0000000..1ef6cad --- /dev/null +++ b/src/metriport/resources/document/types/query_status.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class QueryStatus(str, enum.Enum): + PROCESSING = "processing" + COMPLETED = "completed" + + def visit(self, processing: typing.Callable[[], T_Result], completed: typing.Callable[[], T_Result]) -> T_Result: + if self is QueryStatus.PROCESSING: + return processing() + if self is QueryStatus.COMPLETED: + return completed() diff --git a/src/metriport/resources/document/types/trigger_documents_query_response.py b/src/metriport/resources/document/types/trigger_documents_query_response.py new file mode 100644 index 0000000..1bfc6e3 --- /dev/null +++ b/src/metriport/resources/document/types/trigger_documents_query_response.py @@ -0,0 +1,26 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic + +from ....core.datetime_utils import serialize_datetime +from .query_status import QueryStatus + + +class TriggerDocumentsQueryResponse(pydantic.BaseModel): + query_status: QueryStatus = pydantic.Field(alias="queryStatus") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().dict(**kwargs_with_defaults) + + class Config: + frozen = True + allow_population_by_field_name = True + json_encoders = {dt.datetime: serialize_datetime}