fathom-python 0.0.27__py3-none-any.whl → 0.0.30__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 (112) hide show
  1. fathom_python/__init__.py +17 -0
  2. fathom_python/_hooks/__init__.py +5 -0
  3. fathom_python/_hooks/registration.py +13 -0
  4. fathom_python/_hooks/sdkhooks.py +76 -0
  5. fathom_python/_hooks/types.py +112 -0
  6. fathom_python/_version.py +15 -0
  7. fathom_python/basesdk.py +354 -0
  8. fathom_python/errors/__init__.py +45 -0
  9. fathom_python/errors/apierror.py +38 -0
  10. fathom_python/errors/fathomerror.py +26 -0
  11. fathom_python/errors/no_response_error.py +13 -0
  12. fathom_python/errors/responsevalidationerror.py +25 -0
  13. fathom_python/httpclient.py +126 -0
  14. fathom_python/models/__init__.py +212 -0
  15. fathom_python/models/actionitem.py +33 -0
  16. fathom_python/models/assignee.py +50 -0
  17. fathom_python/models/createwebhookop.py +36 -0
  18. fathom_python/models/crmcompanymatch.py +16 -0
  19. fathom_python/models/crmcontactmatch.py +19 -0
  20. fathom_python/models/crmdealmatch.py +21 -0
  21. fathom_python/models/crmmatches.py +36 -0
  22. fathom_python/models/deletewebhookop.py +18 -0
  23. fathom_python/models/fathomuser.py +50 -0
  24. fathom_python/models/gettokenop.py +74 -0
  25. fathom_python/models/invitee.py +65 -0
  26. fathom_python/models/listmeetingsop.py +175 -0
  27. fathom_python/models/listteammembersop.py +28 -0
  28. fathom_python/models/listteamsop.py +20 -0
  29. fathom_python/models/meeting.py +127 -0
  30. fathom_python/models/meetinglistresponse.py +52 -0
  31. fathom_python/models/meetingsummary.py +49 -0
  32. fathom_python/models/schemetokenrequeststandalone.py +42 -0
  33. fathom_python/models/security.py +52 -0
  34. fathom_python/models/team.py +17 -0
  35. fathom_python/models/teamlistresponse.py +52 -0
  36. fathom_python/models/teammember.py +20 -0
  37. fathom_python/models/teammemberlistresponse.py +52 -0
  38. fathom_python/models/transcriptitem.py +22 -0
  39. fathom_python/models/transcriptitemspeaker.py +17 -0
  40. fathom_python/models/webhook.py +39 -0
  41. fathom_python/py.typed +1 -0
  42. fathom_python/sdk.py +1433 -0
  43. fathom_python/sdkconfiguration.py +48 -0
  44. fathom_python/types/__init__.py +21 -0
  45. fathom_python/types/basemodel.py +39 -0
  46. fathom_python/utils/__init__.py +187 -0
  47. fathom_python/utils/annotations.py +55 -0
  48. fathom_python/utils/datetimes.py +23 -0
  49. fathom_python/utils/enums.py +74 -0
  50. fathom_python/utils/eventstreaming.py +238 -0
  51. fathom_python/utils/forms.py +223 -0
  52. fathom_python/utils/headers.py +136 -0
  53. fathom_python/utils/logger.py +27 -0
  54. fathom_python/utils/metadata.py +118 -0
  55. fathom_python/utils/queryparams.py +205 -0
  56. fathom_python/utils/requestbodies.py +66 -0
  57. fathom_python/utils/retries.py +217 -0
  58. fathom_python/utils/security.py +220 -0
  59. fathom_python/utils/serializers.py +249 -0
  60. fathom_python/utils/unmarshal_json_response.py +24 -0
  61. fathom_python/utils/url.py +155 -0
  62. fathom_python/utils/values.py +137 -0
  63. fathom_python-0.0.30.dist-info/METADATA +657 -0
  64. fathom_python-0.0.30.dist-info/RECORD +65 -0
  65. {fathom_python-0.0.27.dist-info → fathom_python-0.0.30.dist-info}/WHEEL +1 -1
  66. fathom/__init__.py +0 -57
  67. fathom/base_client.py +0 -511
  68. fathom/client.py +0 -25
  69. fathom/core/__init__.py +0 -55
  70. fathom/core/api_error.py +0 -23
  71. fathom/core/client_wrapper.py +0 -55
  72. fathom/core/datetime_utils.py +0 -28
  73. fathom/core/file.py +0 -67
  74. fathom/core/force_multipart.py +0 -16
  75. fathom/core/http_client.py +0 -543
  76. fathom/core/http_response.py +0 -55
  77. fathom/core/jsonable_encoder.py +0 -100
  78. fathom/core/pagination.py +0 -82
  79. fathom/core/pydantic_utilities.py +0 -255
  80. fathom/core/query_encoder.py +0 -58
  81. fathom/core/remove_none_from_dict.py +0 -11
  82. fathom/core/request_options.py +0 -35
  83. fathom/core/serialization.py +0 -276
  84. fathom/environment.py +0 -7
  85. fathom/errors/__init__.py +0 -8
  86. fathom/errors/bad_request_error.py +0 -10
  87. fathom/errors/unauthorized_error.py +0 -10
  88. fathom/py.typed +0 -0
  89. fathom/raw_base_client.py +0 -638
  90. fathom/types/__init__.py +0 -45
  91. fathom/types/action_item.py +0 -33
  92. fathom/types/assignee.py +0 -21
  93. fathom/types/crm_company_match.py +0 -20
  94. fathom/types/crm_contact_match.py +0 -21
  95. fathom/types/crm_deal_match.py +0 -25
  96. fathom/types/crm_matches.py +0 -30
  97. fathom/types/fathom_user.py +0 -21
  98. fathom/types/invitee.py +0 -22
  99. fathom/types/list_meetings_request_meeting_type.py +0 -5
  100. fathom/types/meeting.py +0 -47
  101. fathom/types/meeting_list_response.py +0 -22
  102. fathom/types/meeting_meeting_type.py +0 -5
  103. fathom/types/meeting_summary.py +0 -23
  104. fathom/types/team.py +0 -21
  105. fathom/types/team_list_response.py +0 -22
  106. fathom/types/team_member.py +0 -22
  107. fathom/types/team_member_list_response.py +0 -22
  108. fathom/types/transcript_item.py +0 -25
  109. fathom/types/transcript_item_speaker.py +0 -20
  110. fathom/version.py +0 -3
  111. fathom_python-0.0.27.dist-info/METADATA +0 -151
  112. fathom_python-0.0.27.dist-info/RECORD +0 -48
@@ -0,0 +1,17 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from ._version import (
4
+ __title__,
5
+ __version__,
6
+ __openapi_doc_version__,
7
+ __gen_version__,
8
+ __user_agent__,
9
+ )
10
+ from .sdk import *
11
+ from .sdkconfiguration import *
12
+
13
+
14
+ VERSION: str = __version__
15
+ OPENAPI_DOC_VERSION = __openapi_doc_version__
16
+ SPEAKEASY_GENERATOR_VERSION = __gen_version__
17
+ USER_AGENT = __user_agent__
@@ -0,0 +1,5 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .sdkhooks import *
4
+ from .types import *
5
+ from .registration import *
@@ -0,0 +1,13 @@
1
+ from .types import Hooks
2
+
3
+
4
+ # This file is only ever generated once on the first generation and then is free to be modified.
5
+ # Any hooks you wish to add should be registered in the init_hooks function. Feel free to define them
6
+ # in this file or in separate files in the hooks folder.
7
+
8
+
9
+ def init_hooks(hooks: Hooks):
10
+ # pylint: disable=unused-argument
11
+ """Add hooks by calling hooks.register{sdk_init/before_request/after_success/after_error}Hook
12
+ with an instance of a hook that implements that specific Hook interface
13
+ Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance"""
@@ -0,0 +1,76 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ import httpx
4
+ from .types import (
5
+ SDKInitHook,
6
+ BeforeRequestContext,
7
+ BeforeRequestHook,
8
+ AfterSuccessContext,
9
+ AfterSuccessHook,
10
+ AfterErrorContext,
11
+ AfterErrorHook,
12
+ Hooks,
13
+ )
14
+ from .registration import init_hooks
15
+ from typing import List, Optional, Tuple
16
+ from fathom_python.sdkconfiguration import SDKConfiguration
17
+
18
+
19
+ class SDKHooks(Hooks):
20
+ def __init__(self) -> None:
21
+ self.sdk_init_hooks: List[SDKInitHook] = []
22
+ self.before_request_hooks: List[BeforeRequestHook] = []
23
+ self.after_success_hooks: List[AfterSuccessHook] = []
24
+ self.after_error_hooks: List[AfterErrorHook] = []
25
+ init_hooks(self)
26
+
27
+ def register_sdk_init_hook(self, hook: SDKInitHook) -> None:
28
+ self.sdk_init_hooks.append(hook)
29
+
30
+ def register_before_request_hook(self, hook: BeforeRequestHook) -> None:
31
+ self.before_request_hooks.append(hook)
32
+
33
+ def register_after_success_hook(self, hook: AfterSuccessHook) -> None:
34
+ self.after_success_hooks.append(hook)
35
+
36
+ def register_after_error_hook(self, hook: AfterErrorHook) -> None:
37
+ self.after_error_hooks.append(hook)
38
+
39
+ def sdk_init(self, config: SDKConfiguration) -> SDKConfiguration:
40
+ for hook in self.sdk_init_hooks:
41
+ config = hook.sdk_init(config)
42
+ return config
43
+
44
+ def before_request(
45
+ self, hook_ctx: BeforeRequestContext, request: httpx.Request
46
+ ) -> httpx.Request:
47
+ for hook in self.before_request_hooks:
48
+ out = hook.before_request(hook_ctx, request)
49
+ if isinstance(out, Exception):
50
+ raise out
51
+ request = out
52
+
53
+ return request
54
+
55
+ def after_success(
56
+ self, hook_ctx: AfterSuccessContext, response: httpx.Response
57
+ ) -> httpx.Response:
58
+ for hook in self.after_success_hooks:
59
+ out = hook.after_success(hook_ctx, response)
60
+ if isinstance(out, Exception):
61
+ raise out
62
+ response = out
63
+ return response
64
+
65
+ def after_error(
66
+ self,
67
+ hook_ctx: AfterErrorContext,
68
+ response: Optional[httpx.Response],
69
+ error: Optional[Exception],
70
+ ) -> Tuple[Optional[httpx.Response], Optional[Exception]]:
71
+ for hook in self.after_error_hooks:
72
+ result = hook.after_error(hook_ctx, response, error)
73
+ if isinstance(result, Exception):
74
+ raise result
75
+ response, error = result
76
+ return response, error
@@ -0,0 +1,112 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from abc import ABC, abstractmethod
4
+ from fathom_python.sdkconfiguration import SDKConfiguration
5
+ import httpx
6
+ from typing import Any, Callable, List, Optional, Tuple, Union
7
+
8
+
9
+ class HookContext:
10
+ config: SDKConfiguration
11
+ base_url: str
12
+ operation_id: str
13
+ oauth2_scopes: Optional[List[str]] = None
14
+ security_source: Optional[Union[Any, Callable[[], Any]]] = None
15
+
16
+ def __init__(
17
+ self,
18
+ config: SDKConfiguration,
19
+ base_url: str,
20
+ operation_id: str,
21
+ oauth2_scopes: Optional[List[str]],
22
+ security_source: Optional[Union[Any, Callable[[], Any]]],
23
+ ):
24
+ self.config = config
25
+ self.base_url = base_url
26
+ self.operation_id = operation_id
27
+ self.oauth2_scopes = oauth2_scopes
28
+ self.security_source = security_source
29
+
30
+
31
+ class BeforeRequestContext(HookContext):
32
+ def __init__(self, hook_ctx: HookContext):
33
+ super().__init__(
34
+ hook_ctx.config,
35
+ hook_ctx.base_url,
36
+ hook_ctx.operation_id,
37
+ hook_ctx.oauth2_scopes,
38
+ hook_ctx.security_source,
39
+ )
40
+
41
+
42
+ class AfterSuccessContext(HookContext):
43
+ def __init__(self, hook_ctx: HookContext):
44
+ super().__init__(
45
+ hook_ctx.config,
46
+ hook_ctx.base_url,
47
+ hook_ctx.operation_id,
48
+ hook_ctx.oauth2_scopes,
49
+ hook_ctx.security_source,
50
+ )
51
+
52
+
53
+ class AfterErrorContext(HookContext):
54
+ def __init__(self, hook_ctx: HookContext):
55
+ super().__init__(
56
+ hook_ctx.config,
57
+ hook_ctx.base_url,
58
+ hook_ctx.operation_id,
59
+ hook_ctx.oauth2_scopes,
60
+ hook_ctx.security_source,
61
+ )
62
+
63
+
64
+ class SDKInitHook(ABC):
65
+ @abstractmethod
66
+ def sdk_init(self, config: SDKConfiguration) -> SDKConfiguration:
67
+ pass
68
+
69
+
70
+ class BeforeRequestHook(ABC):
71
+ @abstractmethod
72
+ def before_request(
73
+ self, hook_ctx: BeforeRequestContext, request: httpx.Request
74
+ ) -> Union[httpx.Request, Exception]:
75
+ pass
76
+
77
+
78
+ class AfterSuccessHook(ABC):
79
+ @abstractmethod
80
+ def after_success(
81
+ self, hook_ctx: AfterSuccessContext, response: httpx.Response
82
+ ) -> Union[httpx.Response, Exception]:
83
+ pass
84
+
85
+
86
+ class AfterErrorHook(ABC):
87
+ @abstractmethod
88
+ def after_error(
89
+ self,
90
+ hook_ctx: AfterErrorContext,
91
+ response: Optional[httpx.Response],
92
+ error: Optional[Exception],
93
+ ) -> Union[Tuple[Optional[httpx.Response], Optional[Exception]], Exception]:
94
+ pass
95
+
96
+
97
+ class Hooks(ABC):
98
+ @abstractmethod
99
+ def register_sdk_init_hook(self, hook: SDKInitHook):
100
+ pass
101
+
102
+ @abstractmethod
103
+ def register_before_request_hook(self, hook: BeforeRequestHook):
104
+ pass
105
+
106
+ @abstractmethod
107
+ def register_after_success_hook(self, hook: AfterSuccessHook):
108
+ pass
109
+
110
+ @abstractmethod
111
+ def register_after_error_hook(self, hook: AfterErrorHook):
112
+ pass
@@ -0,0 +1,15 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ import importlib.metadata
4
+
5
+ __title__: str = "fathom-python"
6
+ __version__: str = "0.0.30"
7
+ __openapi_doc_version__: str = "1.0.0"
8
+ __gen_version__: str = "2.669.0"
9
+ __user_agent__: str = "speakeasy-sdk/python 0.0.30 2.669.0 1.0.0 fathom-python"
10
+
11
+ try:
12
+ if __package__ is not None:
13
+ __version__ = importlib.metadata.version(__package__)
14
+ except importlib.metadata.PackageNotFoundError:
15
+ pass
@@ -0,0 +1,354 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .sdkconfiguration import SDKConfiguration
4
+ from fathom_python import errors, models, utils
5
+ from fathom_python._hooks import (
6
+ AfterErrorContext,
7
+ AfterSuccessContext,
8
+ BeforeRequestContext,
9
+ )
10
+ from fathom_python.utils import RetryConfig, SerializedRequestBody, get_body_content
11
+ import httpx
12
+ from typing import Callable, List, Mapping, Optional, Tuple
13
+ from urllib.parse import parse_qs, urlparse
14
+
15
+
16
+ class BaseSDK:
17
+ sdk_configuration: SDKConfiguration
18
+
19
+ def __init__(self, sdk_config: SDKConfiguration) -> None:
20
+ self.sdk_configuration = sdk_config
21
+
22
+ def _get_url(self, base_url, url_variables):
23
+ sdk_url, sdk_variables = self.sdk_configuration.get_server_details()
24
+
25
+ if base_url is None:
26
+ base_url = sdk_url
27
+
28
+ if url_variables is None:
29
+ url_variables = sdk_variables
30
+
31
+ return utils.template_url(base_url, url_variables)
32
+
33
+ def _build_request_async(
34
+ self,
35
+ method,
36
+ path,
37
+ base_url,
38
+ url_variables,
39
+ request,
40
+ request_body_required,
41
+ request_has_path_params,
42
+ request_has_query_params,
43
+ user_agent_header,
44
+ accept_header_value,
45
+ _globals=None,
46
+ security=None,
47
+ timeout_ms: Optional[int] = None,
48
+ get_serialized_body: Optional[
49
+ Callable[[], Optional[SerializedRequestBody]]
50
+ ] = None,
51
+ url_override: Optional[str] = None,
52
+ http_headers: Optional[Mapping[str, str]] = None,
53
+ ) -> httpx.Request:
54
+ client = self.sdk_configuration.async_client
55
+ return self._build_request_with_client(
56
+ client,
57
+ method,
58
+ path,
59
+ base_url,
60
+ url_variables,
61
+ request,
62
+ request_body_required,
63
+ request_has_path_params,
64
+ request_has_query_params,
65
+ user_agent_header,
66
+ accept_header_value,
67
+ _globals,
68
+ security,
69
+ timeout_ms,
70
+ get_serialized_body,
71
+ url_override,
72
+ http_headers,
73
+ )
74
+
75
+ def _build_request(
76
+ self,
77
+ method,
78
+ path,
79
+ base_url,
80
+ url_variables,
81
+ request,
82
+ request_body_required,
83
+ request_has_path_params,
84
+ request_has_query_params,
85
+ user_agent_header,
86
+ accept_header_value,
87
+ _globals=None,
88
+ security=None,
89
+ timeout_ms: Optional[int] = None,
90
+ get_serialized_body: Optional[
91
+ Callable[[], Optional[SerializedRequestBody]]
92
+ ] = None,
93
+ url_override: Optional[str] = None,
94
+ http_headers: Optional[Mapping[str, str]] = None,
95
+ ) -> httpx.Request:
96
+ client = self.sdk_configuration.client
97
+ return self._build_request_with_client(
98
+ client,
99
+ method,
100
+ path,
101
+ base_url,
102
+ url_variables,
103
+ request,
104
+ request_body_required,
105
+ request_has_path_params,
106
+ request_has_query_params,
107
+ user_agent_header,
108
+ accept_header_value,
109
+ _globals,
110
+ security,
111
+ timeout_ms,
112
+ get_serialized_body,
113
+ url_override,
114
+ http_headers,
115
+ )
116
+
117
+ def _build_request_with_client(
118
+ self,
119
+ client,
120
+ method,
121
+ path,
122
+ base_url,
123
+ url_variables,
124
+ request,
125
+ request_body_required,
126
+ request_has_path_params,
127
+ request_has_query_params,
128
+ user_agent_header,
129
+ accept_header_value,
130
+ _globals=None,
131
+ security=None,
132
+ timeout_ms: Optional[int] = None,
133
+ get_serialized_body: Optional[
134
+ Callable[[], Optional[SerializedRequestBody]]
135
+ ] = None,
136
+ url_override: Optional[str] = None,
137
+ http_headers: Optional[Mapping[str, str]] = None,
138
+ ) -> httpx.Request:
139
+ query_params = {}
140
+
141
+ url = url_override
142
+ if url is None:
143
+ url = utils.generate_url(
144
+ self._get_url(base_url, url_variables),
145
+ path,
146
+ request if request_has_path_params else None,
147
+ _globals if request_has_path_params else None,
148
+ )
149
+
150
+ query_params = utils.get_query_params(
151
+ request if request_has_query_params else None,
152
+ _globals if request_has_query_params else None,
153
+ )
154
+ else:
155
+ # Pick up the query parameter from the override so they can be
156
+ # preserved when building the request later on (necessary as of
157
+ # httpx 0.28).
158
+ parsed_override = urlparse(str(url_override))
159
+ query_params = parse_qs(parsed_override.query, keep_blank_values=True)
160
+
161
+ headers = utils.get_headers(request, _globals)
162
+ headers["Accept"] = accept_header_value
163
+ headers[user_agent_header] = self.sdk_configuration.user_agent
164
+
165
+ if security is not None:
166
+ if callable(security):
167
+ security = security()
168
+ security = utils.get_security_from_env(security, models.Security)
169
+ if security is not None:
170
+ security_headers, security_query_params = utils.get_security(security)
171
+ headers = {**headers, **security_headers}
172
+ query_params = {**query_params, **security_query_params}
173
+
174
+ serialized_request_body = SerializedRequestBody()
175
+ if get_serialized_body is not None:
176
+ rb = get_serialized_body()
177
+ if request_body_required and rb is None:
178
+ raise ValueError("request body is required")
179
+
180
+ if rb is not None:
181
+ serialized_request_body = rb
182
+
183
+ if (
184
+ serialized_request_body.media_type is not None
185
+ and serialized_request_body.media_type
186
+ not in (
187
+ "multipart/form-data",
188
+ "multipart/mixed",
189
+ )
190
+ ):
191
+ headers["content-type"] = serialized_request_body.media_type
192
+
193
+ if http_headers is not None:
194
+ for header, value in http_headers.items():
195
+ headers[header] = value
196
+
197
+ timeout = timeout_ms / 1000 if timeout_ms is not None else None
198
+
199
+ return client.build_request(
200
+ method,
201
+ url,
202
+ params=query_params,
203
+ content=serialized_request_body.content,
204
+ data=serialized_request_body.data,
205
+ files=serialized_request_body.files,
206
+ headers=headers,
207
+ timeout=timeout,
208
+ )
209
+
210
+ def do_request(
211
+ self,
212
+ hook_ctx,
213
+ request,
214
+ error_status_codes,
215
+ stream=False,
216
+ retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
217
+ ) -> httpx.Response:
218
+ client = self.sdk_configuration.client
219
+ logger = self.sdk_configuration.debug_logger
220
+
221
+ hooks = self.sdk_configuration.__dict__["_hooks"]
222
+
223
+ def do():
224
+ http_res = None
225
+ try:
226
+ req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
227
+ logger.debug(
228
+ "Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
229
+ req.method,
230
+ req.url,
231
+ req.headers,
232
+ get_body_content(req),
233
+ )
234
+
235
+ if client is None:
236
+ raise ValueError("client is required")
237
+
238
+ http_res = client.send(req, stream=stream)
239
+ except Exception as e:
240
+ _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e)
241
+ if e is not None:
242
+ logger.debug("Request Exception", exc_info=True)
243
+ raise e
244
+
245
+ if http_res is None:
246
+ logger.debug("Raising no response SDK error")
247
+ raise errors.NoResponseError("No response received")
248
+
249
+ logger.debug(
250
+ "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
251
+ http_res.status_code,
252
+ http_res.url,
253
+ http_res.headers,
254
+ "<streaming response>" if stream else http_res.text,
255
+ )
256
+
257
+ if utils.match_status_codes(error_status_codes, http_res.status_code):
258
+ result, err = hooks.after_error(
259
+ AfterErrorContext(hook_ctx), http_res, None
260
+ )
261
+ if err is not None:
262
+ logger.debug("Request Exception", exc_info=True)
263
+ raise err
264
+ if result is not None:
265
+ http_res = result
266
+ else:
267
+ logger.debug("Raising unexpected SDK error")
268
+ raise errors.APIError("Unexpected error occurred", http_res)
269
+
270
+ return http_res
271
+
272
+ if retry_config is not None:
273
+ http_res = utils.retry(do, utils.Retries(retry_config[0], retry_config[1]))
274
+ else:
275
+ http_res = do()
276
+
277
+ if not utils.match_status_codes(error_status_codes, http_res.status_code):
278
+ http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res)
279
+
280
+ return http_res
281
+
282
+ async def do_request_async(
283
+ self,
284
+ hook_ctx,
285
+ request,
286
+ error_status_codes,
287
+ stream=False,
288
+ retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
289
+ ) -> httpx.Response:
290
+ client = self.sdk_configuration.async_client
291
+ logger = self.sdk_configuration.debug_logger
292
+
293
+ hooks = self.sdk_configuration.__dict__["_hooks"]
294
+
295
+ async def do():
296
+ http_res = None
297
+ try:
298
+ req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
299
+ logger.debug(
300
+ "Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
301
+ req.method,
302
+ req.url,
303
+ req.headers,
304
+ get_body_content(req),
305
+ )
306
+
307
+ if client is None:
308
+ raise ValueError("client is required")
309
+
310
+ http_res = await client.send(req, stream=stream)
311
+ except Exception as e:
312
+ _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e)
313
+ if e is not None:
314
+ logger.debug("Request Exception", exc_info=True)
315
+ raise e
316
+
317
+ if http_res is None:
318
+ logger.debug("Raising no response SDK error")
319
+ raise errors.NoResponseError("No response received")
320
+
321
+ logger.debug(
322
+ "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
323
+ http_res.status_code,
324
+ http_res.url,
325
+ http_res.headers,
326
+ "<streaming response>" if stream else http_res.text,
327
+ )
328
+
329
+ if utils.match_status_codes(error_status_codes, http_res.status_code):
330
+ result, err = hooks.after_error(
331
+ AfterErrorContext(hook_ctx), http_res, None
332
+ )
333
+ if err is not None:
334
+ logger.debug("Request Exception", exc_info=True)
335
+ raise err
336
+ if result is not None:
337
+ http_res = result
338
+ else:
339
+ logger.debug("Raising unexpected SDK error")
340
+ raise errors.APIError("Unexpected error occurred", http_res)
341
+
342
+ return http_res
343
+
344
+ if retry_config is not None:
345
+ http_res = await utils.retry_async(
346
+ do, utils.Retries(retry_config[0], retry_config[1])
347
+ )
348
+ else:
349
+ http_res = await do()
350
+
351
+ if not utils.match_status_codes(error_status_codes, http_res.status_code):
352
+ http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res)
353
+
354
+ return http_res
@@ -0,0 +1,45 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from typing import TYPE_CHECKING
4
+ from importlib import import_module
5
+
6
+ if TYPE_CHECKING:
7
+ from .apierror import APIError
8
+ from .fathomerror import FathomError
9
+ from .no_response_error import NoResponseError
10
+ from .responsevalidationerror import ResponseValidationError
11
+
12
+ __all__ = ["APIError", "FathomError", "NoResponseError", "ResponseValidationError"]
13
+
14
+ _dynamic_imports: dict[str, str] = {
15
+ "APIError": ".apierror",
16
+ "FathomError": ".fathomerror",
17
+ "NoResponseError": ".no_response_error",
18
+ "ResponseValidationError": ".responsevalidationerror",
19
+ }
20
+
21
+
22
+ def __getattr__(attr_name: str) -> object:
23
+ module_name = _dynamic_imports.get(attr_name)
24
+ if module_name is None:
25
+ raise AttributeError(
26
+ f"No {attr_name} found in _dynamic_imports for module name -> {__name__} "
27
+ )
28
+
29
+ try:
30
+ module = import_module(module_name, __package__)
31
+ result = getattr(module, attr_name)
32
+ return result
33
+ except ImportError as e:
34
+ raise ImportError(
35
+ f"Failed to import {attr_name} from {module_name}: {e}"
36
+ ) from e
37
+ except AttributeError as e:
38
+ raise AttributeError(
39
+ f"Failed to get {attr_name} from {module_name}: {e}"
40
+ ) from e
41
+
42
+
43
+ def __dir__():
44
+ lazy_attrs = list(_dynamic_imports.keys())
45
+ return sorted(lazy_attrs)
@@ -0,0 +1,38 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ import httpx
4
+ from typing import Optional
5
+
6
+ from fathom_python.errors import FathomError
7
+
8
+ MAX_MESSAGE_LEN = 10_000
9
+
10
+
11
+ class APIError(FathomError):
12
+ """The fallback error class if no more specific error class is matched."""
13
+
14
+ def __init__(
15
+ self, message: str, raw_response: httpx.Response, body: Optional[str] = None
16
+ ):
17
+ body_display = body or raw_response.text or '""'
18
+
19
+ if message:
20
+ message += ": "
21
+ message += f"Status {raw_response.status_code}"
22
+
23
+ headers = raw_response.headers
24
+ content_type = headers.get("content-type", '""')
25
+ if content_type != "application/json":
26
+ if " " in content_type:
27
+ content_type = f'"{content_type}"'
28
+ message += f" Content-Type {content_type}"
29
+
30
+ if len(body_display) > MAX_MESSAGE_LEN:
31
+ truncated = body_display[:MAX_MESSAGE_LEN]
32
+ remaining = len(body_display) - MAX_MESSAGE_LEN
33
+ body_display = f"{truncated}...and {remaining} more chars"
34
+
35
+ message += f". Body: {body_display}"
36
+ message = message.strip()
37
+
38
+ super().__init__(message, raw_response, body)