Skip to content

Commit

Permalink
feat(updating): merging master into branch
Browse files Browse the repository at this point in the history
Refs: #1212
  • Loading branch information
jonahkaye committed Feb 13, 2024
2 parents 464061f + 90c0d7f commit f99b2cd
Show file tree
Hide file tree
Showing 206 changed files with 7,173 additions and 2,974 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

# Metriport Python Library

[![pypi](https://img.shields.io/pypi/v/metriport.svg)](https://pypi.python.org/pypi/metriport)
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern)
[![pypi](https://img.shields.io/pypi/v/fern-metriport.svg)](https://pypi.python.org/pypi/fern-metriport)
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://buildwithfern.com/?utm_source=metriport/metriport-python/readme)

## Documentation

Expand Down
519 changes: 519 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fern-metriport"
version = "0.1.8"
name = "metriport"
version = "8.0.0"
description = ""
readme = "README.md"
authors = []
Expand All @@ -11,7 +11,7 @@ packages = [
[tool.poetry.dependencies]
python = "^3.7"
httpx = ">=0.21.2"
pydantic = "^1.9.2"
pydantic = ">= 1.9.2, < 2.5.0"

[tool.poetry.dev-dependencies]
mypy = "0.971"
Expand Down
4 changes: 2 additions & 2 deletions src/metriport/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file was auto-generated by Fern from our API Definition.

from .resources import Address, UsState, commons, devices, medical
from .resources import Address, UsState, commons, fhir, medical
from .environment import MetriportEnvironment

__all__ = ["Address", "MetriportEnvironment", "UsState", "commons", "devices", "medical"]
__all__ = ["Address", "MetriportEnvironment", "UsState", "commons", "fhir", "medical"]
13 changes: 6 additions & 7 deletions src/metriport/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .environment import MetriportEnvironment
from .resources.devices.client import AsyncDevicesClient, DevicesClient
from .resources.medical.client import AsyncMedicalClient, MedicalClient


Expand All @@ -17,14 +16,14 @@ def __init__(
base_url: typing.Optional[str] = None,
environment: MetriportEnvironment = MetriportEnvironment.PRODUCTION,
api_key: str,
timeout: typing.Optional[float] = 60
timeout: typing.Optional[float] = 60,
httpx_client: typing.Optional[httpx.Client] = None
):
self._client_wrapper = SyncClientWrapper(
base_url=_get_base_url(base_url=base_url, environment=environment),
api_key=api_key,
httpx_client=httpx.Client(timeout=timeout),
httpx_client=httpx.Client(timeout=timeout) if httpx_client is None else httpx_client,
)
self.devices = DevicesClient(client_wrapper=self._client_wrapper)
self.medical = MedicalClient(client_wrapper=self._client_wrapper)


Expand All @@ -35,14 +34,14 @@ def __init__(
base_url: typing.Optional[str] = None,
environment: MetriportEnvironment = MetriportEnvironment.PRODUCTION,
api_key: str,
timeout: typing.Optional[float] = 60
timeout: typing.Optional[float] = 60,
httpx_client: typing.Optional[httpx.AsyncClient] = None
):
self._client_wrapper = AsyncClientWrapper(
base_url=_get_base_url(base_url=base_url, environment=environment),
api_key=api_key,
httpx_client=httpx.AsyncClient(timeout=timeout),
httpx_client=httpx.AsyncClient(timeout=timeout) if httpx_client is None else httpx_client,
)
self.devices = AsyncDevicesClient(client_wrapper=self._client_wrapper)
self.medical = AsyncMedicalClient(client_wrapper=self._client_wrapper)


Expand Down
4 changes: 2 additions & 2 deletions src/metriport/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def __init__(self, *, api_key: str, base_url: str):
def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "fern-metriport",
"X-Fern-SDK-Version": "0.1.8",
"X-Fern-SDK-Name": "metriport",
"X-Fern-SDK-Version": "8.0.0",
}
headers["X-API-Key"] = self.api_key
return headers
Expand Down
14 changes: 8 additions & 6 deletions src/metriport/core/jsonable_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
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
try:
import pydantic.v1 as pydantic # type: ignore
except ImportError:
import pydantic # type: ignore

from .datetime_utils import serialize_datetime

Expand All @@ -34,7 +36,7 @@ def generate_encoders_by_class_tuples(
return encoders_by_class_tuples


encoders_by_class_tuples = generate_encoders_by_class_tuples(ENCODERS_BY_TYPE)
encoders_by_class_tuples = generate_encoders_by_class_tuples(pydantic.json.ENCODERS_BY_TYPE)


def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any:
Expand All @@ -46,7 +48,7 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any]
for encoder_type, encoder_instance in custom_encoder.items():
if isinstance(obj, encoder_type):
return encoder_instance(obj)
if isinstance(obj, BaseModel):
if isinstance(obj, pydantic.BaseModel):
encoder = getattr(obj.__config__, "json_encoders", {})
if custom_encoder:
encoder.update(custom_encoder)
Expand Down Expand Up @@ -82,8 +84,8 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any]
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)
if type(obj) in pydantic.json.ENCODERS_BY_TYPE:
return pydantic.json.ENCODERS_BY_TYPE[type(obj)](obj)
for encoder, classes_tuple in encoders_by_class_tuples.items():
if isinstance(obj, classes_tuple):
return encoder(obj)
Expand Down
2 changes: 1 addition & 1 deletion src/metriport/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@


class MetriportEnvironment(enum.Enum):
PRODUCTION = "https://api.metriport.com/medical/v1"
PRODUCTION = "https://api.metriport.com"
4 changes: 2 additions & 2 deletions src/metriport/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file was auto-generated by Fern from our API Definition.

from . import commons, devices, medical
from . import commons, fhir, medical
from .commons import Address, UsState

__all__ = ["Address", "UsState", "commons", "devices", "medical"]
__all__ = ["Address", "UsState", "commons", "fhir", "medical"]
22 changes: 19 additions & 3 deletions src/metriport/resources/commons/types/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,37 @@
import datetime as dt
import typing

import pydantic

from ....core.datetime_utils import serialize_datetime
from .us_state import UsState

try:
import pydantic.v1 as pydantic # type: ignore
except ImportError:
import pydantic # type: ignore


class Address(pydantic.BaseModel):
"""
from metriport import Address, UsState
Address(
address_line_1="2261 Market Street",
address_line_2="#4818",
city="San Francisco",
state=UsState.CA,
zip="94114",
country="USA",
)
"""

address_line_1: str = pydantic.Field(alias="addressLine1", description="The address.")
address_line_2: typing.Optional[str] = pydantic.Field(
alias="addressLine2", description="The address details, for example `#4451`"
)
city: str = pydantic.Field(description="The city.")
state: UsState = pydantic.Field(description="The 2 letter state acronym, for example `CA`")
zip: str = pydantic.Field(description="Zip must be a string consisting of 5 numbers.")
country: str = pydantic.Field(description="Defaults to “USA”")
country: typing.Optional[str] = pydantic.Field(description="Defaults to “USA”")

def json(self, **kwargs: typing.Any) -> str:
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
Expand Down
99 changes: 0 additions & 99 deletions src/metriport/resources/devices/__init__.py

This file was deleted.

Loading

0 comments on commit f99b2cd

Please sign in to comment.