Skip to content

Commit

Permalink
Request options support, Python version upgrade, and serialized enum …
Browse files Browse the repository at this point in the history
…support (#77)

Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
Co-authored-by: Armando Belardo <[email protected]>
  • Loading branch information
fern-api[bot] and armandobelardo authored Feb 15, 2024
1 parent ca3049f commit 18e8e7b
Show file tree
Hide file tree
Showing 184 changed files with 24,328 additions and 7,674 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ jobs:
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
- name: Bootstrap poetry
run: |
curl --location --show-error --silent --output poetry.py https://install.python-poetry.org \
&& echo '66db5477a597b6176202ef77792076057ce50d2c5a2d2d2978c63e1f144d7b95' poetry.py | sha256sum -c \
&& python poetry.py -y --version 1.5.1 \
&& rm poetry.py
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: poetry install
- name: Compile
Expand All @@ -42,13 +39,10 @@ jobs:
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
- name: Bootstrap poetry
run: |
curl --location --show-error --silent --output poetry.py https://install.python-poetry.org \
&& echo '66db5477a597b6176202ef77792076057ce50d2c5a2d2d2978c63e1f144d7b95' poetry.py | sha256sum -c \
&& python poetry.py -y --version 1.5.1 \
&& rm poetry.py
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: poetry install
- name: Test
Expand All @@ -70,13 +64,10 @@ jobs:
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
- name: Bootstrap poetry
run: |
curl --location --show-error --silent --output poetry.py https://install.python-poetry.org \
&& echo '66db5477a597b6176202ef77792076057ce50d2c5a2d2d2978c63e1f144d7b95' poetry.py | sha256sum -c \
&& python poetry.py -y --version 1.5.1 \
&& rm poetry.py
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: poetry install
- name: Publish to pypi
Expand Down
430 changes: 158 additions & 272 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "MergePythonClient"
version = "1.0.5"
version = "1.0.6"
description = ""
readme = "README.md"
authors = []
Expand All @@ -9,12 +9,13 @@ packages = [
]

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"
httpx = ">=0.21.2"
pydantic = ">= 1.9.2, < 2.5.0"
pydantic = ">= 1.9.2"
typing_extensions = ">= 4.0.0"

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

[build-system]
Expand Down
2 changes: 2 additions & 0 deletions src/merge/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
from .datetime_utils import serialize_datetime
from .jsonable_encoder import jsonable_encoder
from .remove_none_from_dict import remove_none_from_dict
from .request_options import RequestOptions

__all__ = [
"ApiError",
"AsyncClientWrapper",
"BaseClientWrapper",
"RequestOptions",
"SyncClientWrapper",
"jsonable_encoder",
"remove_none_from_dict",
Expand Down
2 changes: 1 addition & 1 deletion src/merge/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "MergePythonClient",
"X-Fern-SDK-Version": "1.0.5",
"X-Fern-SDK-Version": "1.0.6",
}
if self._account_token is not None:
headers["X-Account-Token"] = self._account_token
Expand Down
29 changes: 29 additions & 0 deletions src/merge/core/request_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file was auto-generated by Fern from our API Definition.

import typing

try:
from typing import NotRequired # type: ignore
except ImportError:
from typing_extensions import NotRequired # type: ignore


class RequestOptions(typing.TypedDict):
"""
Additional options for request-specific configuration when calling APIs via the SDK.
This is used primarily as an optional final parameter for service functions.
Attributes:
- timeout_in_seconds: int. The number of seconds to await an API call before timing out.
- additional_headers: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's header dict
- additional_query_parameters: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's query parameters dict
- additional_body_parameters: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's body parameters dict
"""

timeout_in_seconds: NotRequired[int]
additional_headers: NotRequired[typing.Dict[str, typing.Any]]
additional_query_parameters: NotRequired[typing.Dict[str, typing.Any]]
additional_body_parameters: NotRequired[typing.Dict[str, typing.Any]]
44 changes: 38 additions & 6 deletions src/merge/resources/accounting/resources/account_details/client.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# This file was auto-generated by Fern from our API Definition.

import typing
import urllib.parse
from json.decoder import JSONDecodeError

from .....core.api_error import ApiError
from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .....core.jsonable_encoder import jsonable_encoder
from .....core.remove_none_from_dict import remove_none_from_dict
from .....core.request_options import RequestOptions
from ...types.account_details import AccountDetails

try:
Expand All @@ -17,10 +21,12 @@ class AccountDetailsClient:
def __init__(self, *, client_wrapper: SyncClientWrapper):
self._client_wrapper = client_wrapper

def retrieve(self) -> AccountDetails:
def retrieve(self, *, request_options: typing.Optional[RequestOptions] = None) -> AccountDetails:
"""
Get details for a linked account.
Parameters:
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from merge.client import Merge
Expand All @@ -33,8 +39,20 @@ def retrieve(self) -> AccountDetails:
_response = self._client_wrapper.httpx_client.request(
"GET",
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/accounting/v1/account-details"),
headers=self._client_wrapper.get_headers(),
timeout=60,
params=jsonable_encoder(
request_options.get("additional_query_parameters") if request_options is not None else None
),
headers=jsonable_encoder(
remove_none_from_dict(
{
**self._client_wrapper.get_headers(),
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
}
)
),
timeout=request_options.get("timeout_in_seconds")
if request_options is not None and request_options.get("timeout_in_seconds") is not None
else 60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(AccountDetails, _response.json()) # type: ignore
Expand All @@ -49,10 +67,12 @@ class AsyncAccountDetailsClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
self._client_wrapper = client_wrapper

async def retrieve(self) -> AccountDetails:
async def retrieve(self, *, request_options: typing.Optional[RequestOptions] = None) -> AccountDetails:
"""
Get details for a linked account.
Parameters:
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from merge.client import AsyncMerge
Expand All @@ -65,8 +85,20 @@ async def retrieve(self) -> AccountDetails:
_response = await self._client_wrapper.httpx_client.request(
"GET",
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/accounting/v1/account-details"),
headers=self._client_wrapper.get_headers(),
timeout=60,
params=jsonable_encoder(
request_options.get("additional_query_parameters") if request_options is not None else None
),
headers=jsonable_encoder(
remove_none_from_dict(
{
**self._client_wrapper.get_headers(),
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
}
)
),
timeout=request_options.get("timeout_in_seconds")
if request_options is not None and request_options.get("timeout_in_seconds") is not None
else 60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(AccountDetails, _response.json()) # type: ignore
Expand Down
66 changes: 60 additions & 6 deletions src/merge/resources/accounting/resources/account_token/client.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# This file was auto-generated by Fern from our API Definition.

import typing
import urllib.parse
from json.decoder import JSONDecodeError

from .....core.api_error import ApiError
from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .....core.jsonable_encoder import jsonable_encoder
from .....core.remove_none_from_dict import remove_none_from_dict
from .....core.request_options import RequestOptions
from ...types.account_token import AccountToken

try:
Expand All @@ -17,20 +21,44 @@ class AccountTokenClient:
def __init__(self, *, client_wrapper: SyncClientWrapper):
self._client_wrapper = client_wrapper

def retrieve(self, public_token: str) -> AccountToken:
def retrieve(self, public_token: str, *, request_options: typing.Optional[RequestOptions] = None) -> AccountToken:
"""
Returns the account token for the end user with the provided public token.
Parameters:
- public_token: str.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from merge.client import Merge
client = Merge(
account_token="YOUR_ACCOUNT_TOKEN",
api_key="YOUR_API_KEY",
)
client.accounting.account_token.retrieve(
public_token="string",
)
"""
_response = self._client_wrapper.httpx_client.request(
"GET",
urllib.parse.urljoin(
f"{self._client_wrapper.get_base_url()}/", f"api/accounting/v1/account-token/{public_token}"
),
headers=self._client_wrapper.get_headers(),
timeout=60,
params=jsonable_encoder(
request_options.get("additional_query_parameters") if request_options is not None else None
),
headers=jsonable_encoder(
remove_none_from_dict(
{
**self._client_wrapper.get_headers(),
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
}
)
),
timeout=request_options.get("timeout_in_seconds")
if request_options is not None and request_options.get("timeout_in_seconds") is not None
else 60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(AccountToken, _response.json()) # type: ignore
Expand All @@ -45,20 +73,46 @@ class AsyncAccountTokenClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
self._client_wrapper = client_wrapper

async def retrieve(self, public_token: str) -> AccountToken:
async def retrieve(
self, public_token: str, *, request_options: typing.Optional[RequestOptions] = None
) -> AccountToken:
"""
Returns the account token for the end user with the provided public token.
Parameters:
- public_token: str.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from merge.client import AsyncMerge
client = AsyncMerge(
account_token="YOUR_ACCOUNT_TOKEN",
api_key="YOUR_API_KEY",
)
await client.accounting.account_token.retrieve(
public_token="string",
)
"""
_response = await self._client_wrapper.httpx_client.request(
"GET",
urllib.parse.urljoin(
f"{self._client_wrapper.get_base_url()}/", f"api/accounting/v1/account-token/{public_token}"
),
headers=self._client_wrapper.get_headers(),
timeout=60,
params=jsonable_encoder(
request_options.get("additional_query_parameters") if request_options is not None else None
),
headers=jsonable_encoder(
remove_none_from_dict(
{
**self._client_wrapper.get_headers(),
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
}
)
),
timeout=request_options.get("timeout_in_seconds")
if request_options is not None and request_options.get("timeout_in_seconds") is not None
else 60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(AccountToken, _response.json()) # type: ignore
Expand Down
Loading

0 comments on commit 18e8e7b

Please sign in to comment.