Skip to content

Commit

Permalink
Release 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Aug 28, 2023
1 parent f89daae commit 0484716
Show file tree
Hide file tree
Showing 124 changed files with 5,306 additions and 307 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: ci
on: [push]
jobs:
compile:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand All @@ -13,17 +13,32 @@ jobs:
python-version: 3.7
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: poetry install
- name: Compile
run: poetry run mypy .
test:
runs-on: ubuntu-20.04
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 --version 1.5.1
- name: Install dependencies
run: poetry install
- name: Test
run: poetry run pytest .

publish:
needs: [ compile ]
needs: [compile, test]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand All @@ -33,7 +48,7 @@ jobs:
python-version: 3.7
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: poetry install
- name: Publish to pypi
Expand All @@ -42,4 +57,4 @@ jobs:
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 }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@

[tool.poetry]
name = "fern-metriport"
version = "0.0.4"
version = "0.1.2"
description = ""
readme = "README.md"
authors = []
packages = [
{ include = "metriport", from = "src"}
]

[tool.poetry.dependencies]
python = "^3.7"
httpx = "0.23.3"
httpx = ">=0.21.2"
pydantic = "^1.9.2"
types-backports = "0.1.3"
backports-cached_property = "1.0.2"

[tool.poetry.dev-dependencies]
mypy = "0.971"
pytest = "^7.4.0"

[build-system]
requires = ["poetry-core"]
Expand Down
25 changes: 3 additions & 22 deletions src/metriport/__init__.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
# This file was auto-generated by Fern from our API Definition.

from .environment import MercoaEnvironment
from .resources import (
CodeableConcept,
Coding,
Document,
DownloadDocumentResponse,
GetDocumentsResponse,
QueryStatus,
TriggerDocumentsQueryResponse,
document,
)
from .resources import Address, UsState, commons, devices, medical
from .environment import MetriportEnvironment

__all__ = [
"CodeableConcept",
"Coding",
"Document",
"DownloadDocumentResponse",
"GetDocumentsResponse",
"MercoaEnvironment",
"QueryStatus",
"TriggerDocumentsQueryResponse",
"document",
]
__all__ = ["Address", "MetriportEnvironment", "UsState", "commons", "devices", "medical"]
77 changes: 53 additions & 24 deletions src/metriport/client.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
# This file was auto-generated by Fern from our API Definition.

from backports.cached_property import cached_property

from .environment import MercoaEnvironment
from .resources.document.client import AsyncDocumentClient, DocumentClient


class Mercoa:
def __init__(self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCTION, 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 AsyncMercoa:
def __init__(self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCTION, 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)
import typing

import httpx

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


class Metriport:
def __init__(
self,
*,
base_url: typing.Optional[str] = None,
environment: MetriportEnvironment = MetriportEnvironment.PRODUCTION,
api_key: str,
timeout: typing.Optional[float] = 60
):
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),
)
self.devices = DevicesClient(client_wrapper=self._client_wrapper)
self.medical = MedicalClient(client_wrapper=self._client_wrapper)


class AsyncMetriport:
def __init__(
self,
*,
base_url: typing.Optional[str] = None,
environment: MetriportEnvironment = MetriportEnvironment.PRODUCTION,
api_key: str,
timeout: typing.Optional[float] = 60
):
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),
)
self.devices = AsyncDevicesClient(client_wrapper=self._client_wrapper)
self.medical = AsyncMedicalClient(client_wrapper=self._client_wrapper)


def _get_base_url(*, base_url: typing.Optional[str] = None, environment: MetriportEnvironment) -> str:
if base_url is not None:
return base_url
elif environment is not None:
return environment.value
else:
raise Exception("Please pass in either base_url or environment to construct the client")
13 changes: 11 additions & 2 deletions src/metriport/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# This file was auto-generated by Fern from our API Definition.

from .api_error import ApiError
from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
from .datetime_utils import serialize_datetime
from .jsonable_encoder import jsonable_encoder
from .remove_none_from_headers import remove_none_from_headers
from .remove_none_from_dict import remove_none_from_dict

__all__ = ["ApiError", "jsonable_encoder", "remove_none_from_headers", "serialize_datetime"]
__all__ = [
"ApiError",
"AsyncClientWrapper",
"BaseClientWrapper",
"SyncClientWrapper",
"jsonable_encoder",
"remove_none_from_dict",
"serialize_datetime",
]
35 changes: 35 additions & 0 deletions src/metriport/core/client_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This file was auto-generated by Fern from our API Definition.

import typing

import httpx


class BaseClientWrapper:
def __init__(self, *, api_key: str, base_url: str):
self.api_key = api_key
self._base_url = base_url

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.2",
}
headers["X-API-Key"] = self.api_key
return headers

def get_base_url(self) -> str:
return self._base_url


class SyncClientWrapper(BaseClientWrapper):
def __init__(self, *, api_key: str, base_url: str, httpx_client: httpx.Client):
super().__init__(api_key=api_key, base_url=base_url)
self.httpx_client = httpx_client


class AsyncClientWrapper(BaseClientWrapper):
def __init__(self, *, api_key: str, base_url: str, httpx_client: httpx.AsyncClient):
super().__init__(api_key=api_key, base_url=base_url)
self.httpx_client = httpx_client
7 changes: 7 additions & 0 deletions src/metriport/core/jsonable_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

import dataclasses
import datetime as dt
from collections import defaultdict
from enum import Enum
from pathlib import PurePath
Expand All @@ -18,6 +19,8 @@
from pydantic import BaseModel
from pydantic.json import ENCODERS_BY_TYPE

from .datetime_utils import serialize_datetime

SetIntStr = Set[Union[int, str]]
DictIntStrAny = Dict[Union[int, str], Any]

Expand Down Expand Up @@ -60,6 +63,10 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any]
return str(obj)
if isinstance(obj, (str, int, float, type(None))):
return obj
if isinstance(obj, dt.date):
return str(obj)
if isinstance(obj, dt.datetime):
return serialize_datetime(obj)
if isinstance(obj, dict):
encoded_dict = {}
allowed_keys = set(obj.keys())
Expand Down
11 changes: 11 additions & 0 deletions src/metriport/core/remove_none_from_dict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file was auto-generated by Fern from our API Definition.

from typing import Any, Dict, Optional


def remove_none_from_dict(original: Dict[str, Optional[Any]]) -> Dict[str, Any]:
new: Dict[str, Any] = {}
for key, value in original.items():
if value is not None:
new[key] = value
return new
11 changes: 0 additions & 11 deletions src/metriport/core/remove_none_from_headers.py

This file was deleted.

5 changes: 2 additions & 3 deletions src/metriport/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
import enum


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

from . import document
from .document import (
CodeableConcept,
Coding,
Document,
DownloadDocumentResponse,
GetDocumentsResponse,
QueryStatus,
TriggerDocumentsQueryResponse,
)
from . import commons, devices, medical
from .commons import Address, UsState

__all__ = [
"CodeableConcept",
"Coding",
"Document",
"DownloadDocumentResponse",
"GetDocumentsResponse",
"QueryStatus",
"TriggerDocumentsQueryResponse",
"document",
]
__all__ = ["Address", "UsState", "commons", "devices", "medical"]
5 changes: 5 additions & 0 deletions src/metriport/resources/commons/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file was auto-generated by Fern from our API Definition.

from .types import Address, UsState

__all__ = ["Address", "UsState"]
6 changes: 6 additions & 0 deletions src/metriport/resources/commons/types/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file was auto-generated by Fern from our API Definition.

from .address import Address
from .us_state import UsState

__all__ = ["Address", "UsState"]
34 changes: 34 additions & 0 deletions src/metriport/resources/commons/types/address.py
Original file line number Diff line number Diff line change
@@ -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 .us_state import UsState


class Address(pydantic.BaseModel):
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”")

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
smart_union = True
allow_population_by_field_name = True
json_encoders = {dt.datetime: serialize_datetime}
Loading

0 comments on commit 0484716

Please sign in to comment.