Skip to content

Commit

Permalink
Release 0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed May 26, 2024
1 parent ef1ba61 commit 0de06fb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pip install --upgrade fileforge
from fileforge.client import Fileforge

client = Fileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
```
<!-- End Usage -->
Expand All @@ -33,7 +33,7 @@ client = Fileforge(
from fileforge.client import AsyncFileforge

client = AsyncFileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
```
<!-- End Async Usage -->
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fileforge"
version = "0.1.3"
version = "0.1.4"
description = ""
readme = "README.md"
authors = []
Expand Down
41 changes: 25 additions & 16 deletions src/fileforge/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file was auto-generated by Fern from our API Definition.

import os
import typing
import urllib.parse
from json.decoder import JSONDecodeError
Expand Down Expand Up @@ -46,7 +47,7 @@ class Fileforge:
api_key : str
header : typing.Optional[str]
timeout : typing.Optional[float]
The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
Expand All @@ -61,7 +62,7 @@ class Fileforge:
from fileforge.client import Fileforge
client = Fileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
"""

Expand All @@ -70,15 +71,19 @@ def __init__(
*,
base_url: typing.Optional[str] = None,
environment: FileforgeEnvironment = FileforgeEnvironment.DEFAULT,
api_key: str,
header: typing.Optional[str] = os.getenv("FILEFORGE_API_KEY"),
timeout: typing.Optional[float] = None,
follow_redirects: typing.Optional[bool] = True,
httpx_client: typing.Optional[httpx.Client] = None,
):
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
if header is None:
raise ApiError(
body="The client must be instantiated be either passing in header or setting FILEFORGE_API_KEY"
)
self._client_wrapper = SyncClientWrapper(
base_url=_get_base_url(base_url=base_url, environment=environment),
api_key=api_key,
header=header,
httpx_client=httpx_client
if httpx_client is not None
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
Expand All @@ -103,7 +108,7 @@ def retrieve_server_status(self, *, request_options: typing.Optional[RequestOpti
from fileforge.client import Fileforge
client = Fileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
client.retrieve_server_status()
"""
Expand Down Expand Up @@ -206,7 +211,7 @@ def convert_docx(
from fileforge.client import Fileforge
client = Fileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
client.convert_docx()
"""
Expand Down Expand Up @@ -287,7 +292,7 @@ def generate(
from fileforge.client import Fileforge
client = Fileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
client.generate()
"""
Expand Down Expand Up @@ -367,7 +372,7 @@ def merge(
from fileforge.client import Fileforge
client = Fileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
client.merge()
"""
Expand Down Expand Up @@ -436,7 +441,7 @@ class AsyncFileforge:
api_key : str
header : typing.Optional[str]
timeout : typing.Optional[float]
The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
Expand All @@ -451,7 +456,7 @@ class AsyncFileforge:
from fileforge.client import AsyncFileforge
client = AsyncFileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
"""

Expand All @@ -460,15 +465,19 @@ def __init__(
*,
base_url: typing.Optional[str] = None,
environment: FileforgeEnvironment = FileforgeEnvironment.DEFAULT,
api_key: str,
header: typing.Optional[str] = os.getenv("FILEFORGE_API_KEY"),
timeout: typing.Optional[float] = None,
follow_redirects: typing.Optional[bool] = True,
httpx_client: typing.Optional[httpx.AsyncClient] = None,
):
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
if header is None:
raise ApiError(
body="The client must be instantiated be either passing in header or setting FILEFORGE_API_KEY"
)
self._client_wrapper = AsyncClientWrapper(
base_url=_get_base_url(base_url=base_url, environment=environment),
api_key=api_key,
header=header,
httpx_client=httpx_client
if httpx_client is not None
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
Expand All @@ -493,7 +502,7 @@ async def retrieve_server_status(self, *, request_options: typing.Optional[Reque
from fileforge.client import AsyncFileforge
client = AsyncFileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
await client.retrieve_server_status()
"""
Expand Down Expand Up @@ -596,7 +605,7 @@ async def convert_docx(
from fileforge.client import AsyncFileforge
client = AsyncFileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
await client.convert_docx()
"""
Expand Down Expand Up @@ -677,7 +686,7 @@ async def generate(
from fileforge.client import AsyncFileforge
client = AsyncFileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
await client.generate()
"""
Expand Down Expand Up @@ -757,7 +766,7 @@ async def merge(
from fileforge.client import AsyncFileforge
client = AsyncFileforge(
api_key="YOUR_API_KEY",
header="YOUR_HEADER",
)
await client.merge()
"""
Expand Down
16 changes: 8 additions & 8 deletions src/fileforge/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@


class BaseClientWrapper:
def __init__(self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None):
self.api_key = api_key
def __init__(self, *, header: str, base_url: str, timeout: typing.Optional[float] = None):
self.header = header
self._base_url = base_url
self._timeout = timeout

def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "fileforge",
"X-Fern-SDK-Version": "0.1.3",
"X-Fern-SDK-Version": "0.1.4",
}
headers["X-API-Key"] = self.api_key
headers["X-API-Key"] = self.header
return headers

def get_base_url(self) -> str:
Expand All @@ -31,15 +31,15 @@ def get_timeout(self) -> typing.Optional[float]:

class SyncClientWrapper(BaseClientWrapper):
def __init__(
self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client
self, *, header: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client
):
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
super().__init__(header=header, base_url=base_url, timeout=timeout)
self.httpx_client = HttpClient(httpx_client=httpx_client)


class AsyncClientWrapper(BaseClientWrapper):
def __init__(
self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient
self, *, header: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient
):
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
super().__init__(header=header, base_url=base_url, timeout=timeout)
self.httpx_client = AsyncHttpClient(httpx_client=httpx_client)

0 comments on commit 0de06fb

Please sign in to comment.