murf 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. murf/__init__.py +49 -0
  2. murf/auth/__init__.py +2 -0
  3. murf/auth/client.py +175 -0
  4. murf/base_client.py +144 -0
  5. murf/client.py +118 -0
  6. murf/core/__init__.py +47 -0
  7. murf/core/api_error.py +15 -0
  8. murf/core/client_wrapper.py +65 -0
  9. murf/core/datetime_utils.py +28 -0
  10. murf/core/file.py +67 -0
  11. murf/core/http_client.py +499 -0
  12. murf/core/jsonable_encoder.py +101 -0
  13. murf/core/pydantic_utilities.py +296 -0
  14. murf/core/query_encoder.py +58 -0
  15. murf/core/remove_none_from_dict.py +11 -0
  16. murf/core/request_options.py +35 -0
  17. murf/core/serialization.py +272 -0
  18. murf/environment.py +7 -0
  19. murf/errors/__init__.py +17 -0
  20. murf/errors/bad_request_error.py +9 -0
  21. murf/errors/forbidden_error.py +9 -0
  22. murf/errors/internal_server_error.py +9 -0
  23. murf/errors/payment_required_error.py +9 -0
  24. murf/errors/service_unavailable_error.py +9 -0
  25. murf/errors/unauthorized_error.py +9 -0
  26. murf/py.typed +0 -0
  27. murf/text_to_speech/__init__.py +5 -0
  28. murf/text_to_speech/client.py +592 -0
  29. murf/text_to_speech/types/__init__.py +5 -0
  30. murf/text_to_speech/types/generate_speech_request_model_version.py +5 -0
  31. murf/types/__init__.py +21 -0
  32. murf/types/api_voice.py +49 -0
  33. murf/types/api_voice_gender.py +5 -0
  34. murf/types/auth_token_response.py +28 -0
  35. murf/types/generate_speech_response.py +44 -0
  36. murf/types/pronunciation_detail.py +29 -0
  37. murf/types/pronunciation_detail_type.py +5 -0
  38. murf/types/style_details.py +24 -0
  39. murf/types/word_duration.py +30 -0
  40. murf/version.py +3 -0
  41. murf-1.0.0.dist-info/METADATA +169 -0
  42. murf-1.0.0.dist-info/RECORD +43 -0
  43. murf-1.0.0.dist-info/WHEEL +4 -0
murf/__init__.py ADDED
@@ -0,0 +1,49 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .types import (
4
+ ApiVoice,
5
+ ApiVoiceGender,
6
+ AuthTokenResponse,
7
+ GenerateSpeechResponse,
8
+ PronunciationDetail,
9
+ PronunciationDetailType,
10
+ StyleDetails,
11
+ WordDuration,
12
+ )
13
+ from .errors import (
14
+ BadRequestError,
15
+ ForbiddenError,
16
+ InternalServerError,
17
+ PaymentRequiredError,
18
+ ServiceUnavailableError,
19
+ UnauthorizedError,
20
+ )
21
+ from . import auth, text_to_speech
22
+ from .client import AsyncMurf, Murf
23
+ from .environment import MurfEnvironment
24
+ from .text_to_speech import GenerateSpeechRequestModelVersion
25
+ from .version import __version__
26
+
27
+ __all__ = [
28
+ "ApiVoice",
29
+ "ApiVoiceGender",
30
+ "AsyncMurf",
31
+ "AuthTokenResponse",
32
+ "BadRequestError",
33
+ "ForbiddenError",
34
+ "GenerateSpeechRequestModelVersion",
35
+ "GenerateSpeechResponse",
36
+ "InternalServerError",
37
+ "Murf",
38
+ "MurfEnvironment",
39
+ "PaymentRequiredError",
40
+ "PronunciationDetail",
41
+ "PronunciationDetailType",
42
+ "ServiceUnavailableError",
43
+ "StyleDetails",
44
+ "UnauthorizedError",
45
+ "WordDuration",
46
+ "__version__",
47
+ "auth",
48
+ "text_to_speech",
49
+ ]
murf/auth/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
murf/auth/client.py ADDED
@@ -0,0 +1,175 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.client_wrapper import SyncClientWrapper
4
+ import typing
5
+ from ..core.request_options import RequestOptions
6
+ from ..types.auth_token_response import AuthTokenResponse
7
+ from ..core.pydantic_utilities import parse_obj_as
8
+ from ..errors.bad_request_error import BadRequestError
9
+ from ..errors.unauthorized_error import UnauthorizedError
10
+ from ..errors.service_unavailable_error import ServiceUnavailableError
11
+ from json.decoder import JSONDecodeError
12
+ from ..core.api_error import ApiError
13
+ from ..core.client_wrapper import AsyncClientWrapper
14
+
15
+
16
+ class AuthClient:
17
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
18
+ self._client_wrapper = client_wrapper
19
+
20
+ def generate_token(self, *, request_options: typing.Optional[RequestOptions] = None) -> AuthTokenResponse:
21
+ """
22
+ Generates an auth token for authenticating your requests
23
+
24
+ Parameters
25
+ ----------
26
+ request_options : typing.Optional[RequestOptions]
27
+ Request-specific configuration.
28
+
29
+ Returns
30
+ -------
31
+ AuthTokenResponse
32
+ Ok
33
+
34
+ Examples
35
+ --------
36
+ from murf import Murf
37
+
38
+ client = Murf(
39
+ api_key="YOUR_API_KEY",
40
+ )
41
+ client.auth.generate_token()
42
+ """
43
+ _response = self._client_wrapper.httpx_client.request(
44
+ "v1/auth/token",
45
+ method="GET",
46
+ request_options=request_options,
47
+ )
48
+ try:
49
+ if 200 <= _response.status_code < 300:
50
+ return typing.cast(
51
+ AuthTokenResponse,
52
+ parse_obj_as(
53
+ type_=AuthTokenResponse, # type: ignore
54
+ object_=_response.json(),
55
+ ),
56
+ )
57
+ if _response.status_code == 400:
58
+ raise BadRequestError(
59
+ typing.cast(
60
+ typing.Optional[typing.Any],
61
+ parse_obj_as(
62
+ type_=typing.Optional[typing.Any], # type: ignore
63
+ object_=_response.json(),
64
+ ),
65
+ )
66
+ )
67
+ if _response.status_code == 401:
68
+ raise UnauthorizedError(
69
+ typing.cast(
70
+ typing.Optional[typing.Any],
71
+ parse_obj_as(
72
+ type_=typing.Optional[typing.Any], # type: ignore
73
+ object_=_response.json(),
74
+ ),
75
+ )
76
+ )
77
+ if _response.status_code == 503:
78
+ raise ServiceUnavailableError(
79
+ typing.cast(
80
+ typing.Optional[typing.Any],
81
+ parse_obj_as(
82
+ type_=typing.Optional[typing.Any], # type: ignore
83
+ object_=_response.json(),
84
+ ),
85
+ )
86
+ )
87
+ _response_json = _response.json()
88
+ except JSONDecodeError:
89
+ raise ApiError(status_code=_response.status_code, body=_response.text)
90
+ raise ApiError(status_code=_response.status_code, body=_response_json)
91
+
92
+
93
+ class AsyncAuthClient:
94
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
95
+ self._client_wrapper = client_wrapper
96
+
97
+ async def generate_token(self, *, request_options: typing.Optional[RequestOptions] = None) -> AuthTokenResponse:
98
+ """
99
+ Generates an auth token for authenticating your requests
100
+
101
+ Parameters
102
+ ----------
103
+ request_options : typing.Optional[RequestOptions]
104
+ Request-specific configuration.
105
+
106
+ Returns
107
+ -------
108
+ AuthTokenResponse
109
+ Ok
110
+
111
+ Examples
112
+ --------
113
+ import asyncio
114
+
115
+ from murf import AsyncMurf
116
+
117
+ client = AsyncMurf(
118
+ api_key="YOUR_API_KEY",
119
+ )
120
+
121
+
122
+ async def main() -> None:
123
+ await client.auth.generate_token()
124
+
125
+
126
+ asyncio.run(main())
127
+ """
128
+ _response = await self._client_wrapper.httpx_client.request(
129
+ "v1/auth/token",
130
+ method="GET",
131
+ request_options=request_options,
132
+ )
133
+ try:
134
+ if 200 <= _response.status_code < 300:
135
+ return typing.cast(
136
+ AuthTokenResponse,
137
+ parse_obj_as(
138
+ type_=AuthTokenResponse, # type: ignore
139
+ object_=_response.json(),
140
+ ),
141
+ )
142
+ if _response.status_code == 400:
143
+ raise BadRequestError(
144
+ typing.cast(
145
+ typing.Optional[typing.Any],
146
+ parse_obj_as(
147
+ type_=typing.Optional[typing.Any], # type: ignore
148
+ object_=_response.json(),
149
+ ),
150
+ )
151
+ )
152
+ if _response.status_code == 401:
153
+ raise UnauthorizedError(
154
+ typing.cast(
155
+ typing.Optional[typing.Any],
156
+ parse_obj_as(
157
+ type_=typing.Optional[typing.Any], # type: ignore
158
+ object_=_response.json(),
159
+ ),
160
+ )
161
+ )
162
+ if _response.status_code == 503:
163
+ raise ServiceUnavailableError(
164
+ typing.cast(
165
+ typing.Optional[typing.Any],
166
+ parse_obj_as(
167
+ type_=typing.Optional[typing.Any], # type: ignore
168
+ object_=_response.json(),
169
+ ),
170
+ )
171
+ )
172
+ _response_json = _response.json()
173
+ except JSONDecodeError:
174
+ raise ApiError(status_code=_response.status_code, body=_response.text)
175
+ raise ApiError(status_code=_response.status_code, body=_response_json)
murf/base_client.py ADDED
@@ -0,0 +1,144 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from .environment import MurfEnvironment
5
+ import httpx
6
+ from .core.client_wrapper import SyncClientWrapper
7
+ from .auth.client import AuthClient
8
+ from .text_to_speech.client import TextToSpeechClient
9
+ from .core.client_wrapper import AsyncClientWrapper
10
+ from .auth.client import AsyncAuthClient
11
+ from .text_to_speech.client import AsyncTextToSpeechClient
12
+
13
+
14
+ class BaseClient:
15
+ """
16
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
17
+
18
+ Parameters
19
+ ----------
20
+ base_url : typing.Optional[str]
21
+ The base url to use for requests from the client.
22
+
23
+ environment : MurfEnvironment
24
+ The environment to use for requests from the client. from .environment import MurfEnvironment
25
+
26
+
27
+
28
+ Defaults to MurfEnvironment.DEFAULT
29
+
30
+
31
+
32
+ api_key : typing.Optional[str]
33
+ timeout : typing.Optional[float]
34
+ 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 this default is not enforced.
35
+
36
+ follow_redirects : typing.Optional[bool]
37
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
38
+
39
+ httpx_client : typing.Optional[httpx.Client]
40
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
41
+
42
+ Examples
43
+ --------
44
+ from murf import Murf
45
+
46
+ client = Murf(
47
+ api_key="YOUR_API_KEY",
48
+ )
49
+ """
50
+
51
+ def __init__(
52
+ self,
53
+ *,
54
+ base_url: typing.Optional[str] = None,
55
+ environment: MurfEnvironment = MurfEnvironment.DEFAULT,
56
+ api_key: typing.Optional[str] = None,
57
+ timeout: typing.Optional[float] = None,
58
+ follow_redirects: typing.Optional[bool] = True,
59
+ httpx_client: typing.Optional[httpx.Client] = None,
60
+ ):
61
+ _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
62
+ self._client_wrapper = SyncClientWrapper(
63
+ base_url=_get_base_url(base_url=base_url, environment=environment),
64
+ api_key=api_key,
65
+ httpx_client=httpx_client
66
+ if httpx_client is not None
67
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
68
+ if follow_redirects is not None
69
+ else httpx.Client(timeout=_defaulted_timeout),
70
+ timeout=_defaulted_timeout,
71
+ )
72
+ self.auth = AuthClient(client_wrapper=self._client_wrapper)
73
+ self.text_to_speech = TextToSpeechClient(client_wrapper=self._client_wrapper)
74
+
75
+
76
+ class AsyncBaseClient:
77
+ """
78
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
79
+
80
+ Parameters
81
+ ----------
82
+ base_url : typing.Optional[str]
83
+ The base url to use for requests from the client.
84
+
85
+ environment : MurfEnvironment
86
+ The environment to use for requests from the client. from .environment import MurfEnvironment
87
+
88
+
89
+
90
+ Defaults to MurfEnvironment.DEFAULT
91
+
92
+
93
+
94
+ api_key : typing.Optional[str]
95
+ timeout : typing.Optional[float]
96
+ 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 this default is not enforced.
97
+
98
+ follow_redirects : typing.Optional[bool]
99
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
100
+
101
+ httpx_client : typing.Optional[httpx.AsyncClient]
102
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
103
+
104
+ Examples
105
+ --------
106
+ from murf import AsyncMurf
107
+
108
+ client = AsyncMurf(
109
+ api_key="YOUR_API_KEY",
110
+ )
111
+ """
112
+
113
+ def __init__(
114
+ self,
115
+ *,
116
+ base_url: typing.Optional[str] = None,
117
+ environment: MurfEnvironment = MurfEnvironment.DEFAULT,
118
+ api_key: typing.Optional[str] = None,
119
+ timeout: typing.Optional[float] = None,
120
+ follow_redirects: typing.Optional[bool] = True,
121
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
122
+ ):
123
+ _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
124
+ self._client_wrapper = AsyncClientWrapper(
125
+ base_url=_get_base_url(base_url=base_url, environment=environment),
126
+ api_key=api_key,
127
+ httpx_client=httpx_client
128
+ if httpx_client is not None
129
+ else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
130
+ if follow_redirects is not None
131
+ else httpx.AsyncClient(timeout=_defaulted_timeout),
132
+ timeout=_defaulted_timeout,
133
+ )
134
+ self.auth = AsyncAuthClient(client_wrapper=self._client_wrapper)
135
+ self.text_to_speech = AsyncTextToSpeechClient(client_wrapper=self._client_wrapper)
136
+
137
+
138
+ def _get_base_url(*, base_url: typing.Optional[str] = None, environment: MurfEnvironment) -> str:
139
+ if base_url is not None:
140
+ return base_url
141
+ elif environment is not None:
142
+ return environment.value
143
+ else:
144
+ raise Exception("Please pass in either base_url or environment to construct the client")
murf/client.py ADDED
@@ -0,0 +1,118 @@
1
+ from .base_client import BaseClient, AsyncBaseClient
2
+ from .environment import MurfEnvironment
3
+ import typing
4
+ import os
5
+ import httpx
6
+
7
+ class Murf(BaseClient):
8
+ """
9
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
10
+
11
+ Parameters
12
+ ----------
13
+ base_url : typing.Optional[str]
14
+ The base url to use for requests from the client.
15
+
16
+ environment : MurfEnvironment
17
+ The environment to use for requests from the client. from .environment import MurfEnvironment
18
+
19
+
20
+
21
+ Defaults to MurfEnvironment.DEFAULT
22
+
23
+
24
+
25
+ api_key : typing.Optional[str]
26
+ timeout : typing.Optional[float]
27
+ 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 this default is not enforced.
28
+
29
+ follow_redirects : typing.Optional[bool]
30
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
31
+
32
+ httpx_client : typing.Optional[httpx.Client]
33
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
34
+
35
+ Examples
36
+ --------
37
+ from murf import Murf
38
+
39
+ client = Murf(
40
+ api_key="YOUR_API_KEY",
41
+ )
42
+ """
43
+
44
+ def __init__(
45
+ self,
46
+ *,
47
+ base_url: typing.Optional[str] = None,
48
+ environment: MurfEnvironment = MurfEnvironment.DEFAULT,
49
+ api_key: typing.Optional[str] = os.getenv("MURF_API_KEY"),
50
+ timeout: typing.Optional[float] = 60,
51
+ follow_redirects: typing.Optional[bool] = True,
52
+ httpx_client: typing.Optional[httpx.Client] = None,
53
+ ):
54
+ super().__init__(
55
+ base_url=base_url,
56
+ environment=environment,
57
+ api_key=api_key,
58
+ timeout=timeout,
59
+ follow_redirects=follow_redirects,
60
+ httpx_client=httpx_client
61
+ )
62
+
63
+
64
+ class AsyncMurf(AsyncBaseClient):
65
+ """
66
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
67
+
68
+ Parameters
69
+ ----------
70
+ base_url : typing.Optional[str]
71
+ The base url to use for requests from the client.
72
+
73
+ environment : MurfEnvironment
74
+ The environment to use for requests from the client. from .environment import MurfEnvironment
75
+
76
+
77
+
78
+ Defaults to MurfEnvironment.DEFAULT
79
+
80
+
81
+
82
+ api_key : typing.Optional[str]
83
+ timeout : typing.Optional[float]
84
+ 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 this default is not enforced.
85
+
86
+ follow_redirects : typing.Optional[bool]
87
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
88
+
89
+ httpx_client : typing.Optional[httpx.AsyncClient]
90
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
91
+
92
+ Examples
93
+ --------
94
+ from murf import AsyncMurf
95
+
96
+ client = AsyncMurf(
97
+ api_key="YOUR_API_KEY",
98
+ )
99
+ """
100
+
101
+ def __init__(
102
+ self,
103
+ *,
104
+ base_url: typing.Optional[str] = None,
105
+ environment: MurfEnvironment = MurfEnvironment.DEFAULT,
106
+ api_key: typing.Optional[str] = os.getenv("MURF_API_KEY"),
107
+ timeout: typing.Optional[float] = 60,
108
+ follow_redirects: typing.Optional[bool] = True,
109
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
110
+ ):
111
+ super().__init__(
112
+ base_url=base_url,
113
+ environment=environment,
114
+ api_key=api_key,
115
+ timeout=timeout,
116
+ follow_redirects=follow_redirects,
117
+ httpx_client=httpx_client
118
+ )
murf/core/__init__.py ADDED
@@ -0,0 +1,47 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .api_error import ApiError
4
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
5
+ from .datetime_utils import serialize_datetime
6
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
7
+ from .http_client import AsyncHttpClient, HttpClient
8
+ from .jsonable_encoder import jsonable_encoder
9
+ from .pydantic_utilities import (
10
+ IS_PYDANTIC_V2,
11
+ UniversalBaseModel,
12
+ UniversalRootModel,
13
+ parse_obj_as,
14
+ universal_field_validator,
15
+ universal_root_validator,
16
+ update_forward_refs,
17
+ )
18
+ from .query_encoder import encode_query
19
+ from .remove_none_from_dict import remove_none_from_dict
20
+ from .request_options import RequestOptions
21
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
22
+
23
+ __all__ = [
24
+ "ApiError",
25
+ "AsyncClientWrapper",
26
+ "AsyncHttpClient",
27
+ "BaseClientWrapper",
28
+ "FieldMetadata",
29
+ "File",
30
+ "HttpClient",
31
+ "IS_PYDANTIC_V2",
32
+ "RequestOptions",
33
+ "SyncClientWrapper",
34
+ "UniversalBaseModel",
35
+ "UniversalRootModel",
36
+ "convert_and_respect_annotation_metadata",
37
+ "convert_file_dict_to_httpx_tuples",
38
+ "encode_query",
39
+ "jsonable_encoder",
40
+ "parse_obj_as",
41
+ "remove_none_from_dict",
42
+ "serialize_datetime",
43
+ "universal_field_validator",
44
+ "universal_root_validator",
45
+ "update_forward_refs",
46
+ "with_content_type",
47
+ ]
murf/core/api_error.py ADDED
@@ -0,0 +1,15 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+
6
+ class ApiError(Exception):
7
+ status_code: typing.Optional[int]
8
+ body: typing.Any
9
+
10
+ def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None):
11
+ self.status_code = status_code
12
+ self.body = body
13
+
14
+ def __str__(self) -> str:
15
+ return f"status_code: {self.status_code}, body: {self.body}"
@@ -0,0 +1,65 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ import httpx
5
+ from .http_client import HttpClient
6
+ from .http_client import AsyncHttpClient
7
+
8
+
9
+ class BaseClientWrapper:
10
+ def __init__(self, *, api_key: typing.Optional[str] = None, base_url: str, timeout: typing.Optional[float] = None):
11
+ self._api_key = api_key
12
+ self._base_url = base_url
13
+ self._timeout = timeout
14
+
15
+ def get_headers(self) -> typing.Dict[str, str]:
16
+ headers: typing.Dict[str, str] = {
17
+ "X-Fern-Language": "Python",
18
+ "X-Fern-SDK-Name": "murf",
19
+ "X-Fern-SDK-Version": "1.0.0",
20
+ }
21
+ if self._api_key is not None:
22
+ headers["api-key"] = self._api_key
23
+ return headers
24
+
25
+ def get_base_url(self) -> str:
26
+ return self._base_url
27
+
28
+ def get_timeout(self) -> typing.Optional[float]:
29
+ return self._timeout
30
+
31
+
32
+ class SyncClientWrapper(BaseClientWrapper):
33
+ def __init__(
34
+ self,
35
+ *,
36
+ api_key: typing.Optional[str] = None,
37
+ base_url: str,
38
+ timeout: typing.Optional[float] = None,
39
+ httpx_client: httpx.Client,
40
+ ):
41
+ super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
42
+ self.httpx_client = HttpClient(
43
+ httpx_client=httpx_client,
44
+ base_headers=self.get_headers,
45
+ base_timeout=self.get_timeout,
46
+ base_url=self.get_base_url,
47
+ )
48
+
49
+
50
+ class AsyncClientWrapper(BaseClientWrapper):
51
+ def __init__(
52
+ self,
53
+ *,
54
+ api_key: typing.Optional[str] = None,
55
+ base_url: str,
56
+ timeout: typing.Optional[float] = None,
57
+ httpx_client: httpx.AsyncClient,
58
+ ):
59
+ super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
60
+ self.httpx_client = AsyncHttpClient(
61
+ httpx_client=httpx_client,
62
+ base_headers=self.get_headers,
63
+ base_timeout=self.get_timeout,
64
+ base_url=self.get_base_url,
65
+ )
@@ -0,0 +1,28 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+
5
+
6
+ def serialize_datetime(v: dt.datetime) -> str:
7
+ """
8
+ Serialize a datetime including timezone info.
9
+
10
+ Uses the timezone info provided if present, otherwise uses the current runtime's timezone info.
11
+
12
+ UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00.
13
+ """
14
+
15
+ def _serialize_zoned_datetime(v: dt.datetime) -> str:
16
+ if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None):
17
+ # UTC is a special case where we use "Z" at the end instead of "+00:00"
18
+ return v.isoformat().replace("+00:00", "Z")
19
+ else:
20
+ # Delegate to the typical +/- offset format
21
+ return v.isoformat()
22
+
23
+ if v.tzinfo is not None:
24
+ return _serialize_zoned_datetime(v)
25
+ else:
26
+ local_tz = dt.datetime.now().astimezone().tzinfo
27
+ localized_dt = v.replace(tzinfo=local_tz)
28
+ return _serialize_zoned_datetime(localized_dt)