Skip to content

Commit

Permalink
Release 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Apr 25, 2023
1 parent af72b85 commit 6934fd7
Show file tree
Hide file tree
Showing 22 changed files with 643 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
.mypy_cache/
__pycache__/
poetry.toml
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
23 changes: 23 additions & 0 deletions src/metriport/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
25 changes: 25 additions & 0 deletions src/metriport/client.py
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 8 additions & 0 deletions src/metriport/core/__init__.py
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 15 additions & 0 deletions src/metriport/core/api_error.py
Original file line number Diff line number Diff line change
@@ -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}"
28 changes: 28 additions & 0 deletions src/metriport/core/datetime_utils.py
Original file line number Diff line number Diff line change
@@ -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)
94 changes: 94 additions & 0 deletions src/metriport/core/jsonable_encoder.py
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 11 additions & 0 deletions src/metriport/core/remove_none_from_headers.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 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
Empty file added src/metriport/py.typed
Empty file.
23 changes: 23 additions & 0 deletions src/metriport/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
21 changes: 21 additions & 0 deletions src/metriport/resources/document/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
Loading

0 comments on commit 6934fd7

Please sign in to comment.