informly 0.1.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 (60) hide show
  1. informly/__init__.py +114 -0
  2. informly/_default_clients.py +30 -0
  3. informly/client.py +220 -0
  4. informly/contacts/__init__.py +58 -0
  5. informly/contacts/client.py +582 -0
  6. informly/contacts/raw_client.py +1059 -0
  7. informly/contacts/types/__init__.py +56 -0
  8. informly/contacts/types/create_contact_response.py +13 -0
  9. informly/contacts/types/delete_contact_response.py +13 -0
  10. informly/contacts/types/delete_contacts_response.py +13 -0
  11. informly/contacts/types/delete_contacts_response_data.py +15 -0
  12. informly/contacts/types/get_contact_response.py +13 -0
  13. informly/contacts/types/list_contacts_response.py +15 -0
  14. informly/contacts/types/update_contact_response.py +13 -0
  15. informly/core/__init__.py +125 -0
  16. informly/core/api_error.py +23 -0
  17. informly/core/client_wrapper.py +103 -0
  18. informly/core/datetime_utils.py +70 -0
  19. informly/core/file.py +67 -0
  20. informly/core/force_multipart.py +18 -0
  21. informly/core/http_client.py +840 -0
  22. informly/core/http_response.py +59 -0
  23. informly/core/http_sse/__init__.py +42 -0
  24. informly/core/http_sse/_api.py +112 -0
  25. informly/core/http_sse/_decoders.py +61 -0
  26. informly/core/http_sse/_exceptions.py +7 -0
  27. informly/core/http_sse/_models.py +17 -0
  28. informly/core/jsonable_encoder.py +108 -0
  29. informly/core/logging.py +107 -0
  30. informly/core/parse_error.py +36 -0
  31. informly/core/pydantic_utilities.py +634 -0
  32. informly/core/query_encoder.py +58 -0
  33. informly/core/remove_none_from_dict.py +11 -0
  34. informly/core/request_options.py +35 -0
  35. informly/core/serialization.py +276 -0
  36. informly/environment.py +7 -0
  37. informly/errors/__init__.py +42 -0
  38. informly/errors/bad_request_error.py +11 -0
  39. informly/errors/forbidden_error.py +11 -0
  40. informly/errors/not_found_error.py +11 -0
  41. informly/errors/unauthorized_error.py +11 -0
  42. informly/segments/__init__.py +34 -0
  43. informly/segments/client.py +92 -0
  44. informly/segments/raw_client.py +150 -0
  45. informly/segments/types/__init__.py +34 -0
  46. informly/segments/types/list_segments_response.py +13 -0
  47. informly/types/__init__.py +59 -0
  48. informly/types/contact.py +52 -0
  49. informly/types/contact_contact.py +30 -0
  50. informly/types/contact_segments_item.py +22 -0
  51. informly/types/error_response.py +13 -0
  52. informly/types/error_response_error.py +26 -0
  53. informly/types/error_response_error_details_item.py +20 -0
  54. informly/types/pagination_meta.py +31 -0
  55. informly/types/segment.py +25 -0
  56. informly-0.1.0.dist-info/METADATA +12 -0
  57. informly-0.1.0.dist-info/RECORD +60 -0
  58. informly-0.1.0.dist-info/WHEEL +5 -0
  59. informly-0.1.0.dist-info/licenses/LICENSE +21 -0
  60. informly-0.1.0.dist-info/top_level.txt +1 -0
informly/__init__.py ADDED
@@ -0,0 +1,114 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .types import (
10
+ Contact,
11
+ ContactContact,
12
+ ContactSegmentsItem,
13
+ ErrorResponse,
14
+ ErrorResponseError,
15
+ ErrorResponseErrorDetailsItem,
16
+ PaginationMeta,
17
+ Segment,
18
+ )
19
+ from .errors import BadRequestError, ForbiddenError, NotFoundError, UnauthorizedError
20
+ from . import contacts, segments
21
+ from ._default_clients import DefaultAioHttpClient, DefaultAsyncHttpxClient
22
+ from .client import AsyncInformly, Informly
23
+ from .contacts import (
24
+ CreateContactResponse,
25
+ DeleteContactResponse,
26
+ DeleteContactsResponse,
27
+ DeleteContactsResponseData,
28
+ GetContactResponse,
29
+ ListContactsResponse,
30
+ UpdateContactResponse,
31
+ )
32
+ from .environment import InformlyEnvironment
33
+ from .segments import ListSegmentsResponse
34
+ _dynamic_imports: typing.Dict[str, str] = {
35
+ "AsyncInformly": ".client",
36
+ "BadRequestError": ".errors",
37
+ "Contact": ".types",
38
+ "ContactContact": ".types",
39
+ "ContactSegmentsItem": ".types",
40
+ "CreateContactResponse": ".contacts",
41
+ "DefaultAioHttpClient": "._default_clients",
42
+ "DefaultAsyncHttpxClient": "._default_clients",
43
+ "DeleteContactResponse": ".contacts",
44
+ "DeleteContactsResponse": ".contacts",
45
+ "DeleteContactsResponseData": ".contacts",
46
+ "ErrorResponse": ".types",
47
+ "ErrorResponseError": ".types",
48
+ "ErrorResponseErrorDetailsItem": ".types",
49
+ "ForbiddenError": ".errors",
50
+ "GetContactResponse": ".contacts",
51
+ "Informly": ".client",
52
+ "InformlyEnvironment": ".environment",
53
+ "ListContactsResponse": ".contacts",
54
+ "ListSegmentsResponse": ".segments",
55
+ "NotFoundError": ".errors",
56
+ "PaginationMeta": ".types",
57
+ "Segment": ".types",
58
+ "UnauthorizedError": ".errors",
59
+ "UpdateContactResponse": ".contacts",
60
+ "contacts": ".contacts",
61
+ "segments": ".segments",
62
+ }
63
+
64
+
65
+ def __getattr__(attr_name: str) -> typing.Any:
66
+ module_name = _dynamic_imports.get(attr_name)
67
+ if module_name is None:
68
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
69
+ try:
70
+ module = import_module(module_name, __package__)
71
+ if module_name == f".{attr_name}":
72
+ return module
73
+ else:
74
+ return getattr(module, attr_name)
75
+ except ImportError as e:
76
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
77
+ except AttributeError as e:
78
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
79
+
80
+
81
+ def __dir__():
82
+ lazy_attrs = list(_dynamic_imports.keys())
83
+ return sorted(lazy_attrs)
84
+
85
+
86
+ __all__ = [
87
+ "AsyncInformly",
88
+ "BadRequestError",
89
+ "Contact",
90
+ "ContactContact",
91
+ "ContactSegmentsItem",
92
+ "CreateContactResponse",
93
+ "DefaultAioHttpClient",
94
+ "DefaultAsyncHttpxClient",
95
+ "DeleteContactResponse",
96
+ "DeleteContactsResponse",
97
+ "DeleteContactsResponseData",
98
+ "ErrorResponse",
99
+ "ErrorResponseError",
100
+ "ErrorResponseErrorDetailsItem",
101
+ "ForbiddenError",
102
+ "GetContactResponse",
103
+ "Informly",
104
+ "InformlyEnvironment",
105
+ "ListContactsResponse",
106
+ "ListSegmentsResponse",
107
+ "NotFoundError",
108
+ "PaginationMeta",
109
+ "Segment",
110
+ "UnauthorizedError",
111
+ "UpdateContactResponse",
112
+ "contacts",
113
+ "segments",
114
+ ]
@@ -0,0 +1,30 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+
7
+ SDK_DEFAULT_TIMEOUT = 60
8
+
9
+ try:
10
+ import httpx_aiohttp # type: ignore[import-not-found]
11
+ except ImportError:
12
+
13
+ class DefaultAioHttpClient(httpx.AsyncClient): # type: ignore
14
+ def __init__(self, **kwargs: typing.Any) -> None:
15
+ raise RuntimeError("To use the aiohttp client, install the aiohttp extra: pip install package[aiohttp]")
16
+
17
+ else:
18
+
19
+ class DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
20
+ def __init__(self, **kwargs: typing.Any) -> None:
21
+ kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
22
+ kwargs.setdefault("follow_redirects", True)
23
+ super().__init__(**kwargs)
24
+
25
+
26
+ class DefaultAsyncHttpxClient(httpx.AsyncClient):
27
+ def __init__(self, **kwargs: typing.Any) -> None:
28
+ kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
29
+ kwargs.setdefault("follow_redirects", True)
30
+ super().__init__(**kwargs)
informly/client.py ADDED
@@ -0,0 +1,220 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing
6
+
7
+ import httpx
8
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from .core.logging import LogConfig, Logger
10
+ from .environment import InformlyEnvironment
11
+
12
+ if typing.TYPE_CHECKING:
13
+ from .contacts.client import AsyncContactsClient, ContactsClient
14
+ from .segments.client import AsyncSegmentsClient, SegmentsClient
15
+
16
+
17
+ class Informly:
18
+ """
19
+ 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.
20
+
21
+ Parameters
22
+ ----------
23
+ base_url : typing.Optional[str]
24
+ The base url to use for requests from the client.
25
+
26
+ environment : InformlyEnvironment
27
+ The environment to use for requests from the client. from .environment import InformlyEnvironment
28
+
29
+
30
+
31
+ Defaults to InformlyEnvironment.DEFAULT
32
+
33
+
34
+
35
+ token : typing.Union[str, typing.Callable[[], str]]
36
+ headers : typing.Optional[typing.Dict[str, str]]
37
+ Additional headers to send with every request.
38
+
39
+ timeout : typing.Optional[float]
40
+ The timeout to be used, in seconds, for requests. By default the timeout is 30 seconds, unless a custom httpx client is used, in which case this default is not enforced.
41
+
42
+ follow_redirects : typing.Optional[bool]
43
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
44
+
45
+ httpx_client : typing.Optional[httpx.Client]
46
+ 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.
47
+
48
+ logging : typing.Optional[typing.Union[LogConfig, Logger]]
49
+ Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
50
+
51
+ Examples
52
+ --------
53
+ from informly-sdk import Informly
54
+
55
+ client = Informly(token="YOUR_TOKEN", )
56
+ """
57
+
58
+ def __init__(
59
+ self,
60
+ *,
61
+ base_url: typing.Optional[str] = None,
62
+ environment: InformlyEnvironment = InformlyEnvironment.DEFAULT,
63
+ token: typing.Union[str, typing.Callable[[], str]],
64
+ headers: typing.Optional[typing.Dict[str, str]] = None,
65
+ timeout: typing.Optional[float] = None,
66
+ follow_redirects: typing.Optional[bool] = True,
67
+ httpx_client: typing.Optional[httpx.Client] = None,
68
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
69
+ ):
70
+ _defaulted_timeout = (
71
+ timeout if timeout is not None else 30 if httpx_client is None else httpx_client.timeout.read
72
+ )
73
+ self._client_wrapper = SyncClientWrapper(
74
+ base_url=_get_base_url(base_url=base_url, environment=environment),
75
+ token=token,
76
+ headers=headers,
77
+ httpx_client=httpx_client
78
+ if httpx_client is not None
79
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
80
+ if follow_redirects is not None
81
+ else httpx.Client(timeout=_defaulted_timeout),
82
+ timeout=_defaulted_timeout,
83
+ logging=logging,
84
+ )
85
+ self._contacts: typing.Optional[ContactsClient] = None
86
+ self._segments: typing.Optional[SegmentsClient] = None
87
+
88
+ @property
89
+ def contacts(self):
90
+ if self._contacts is None:
91
+ from .contacts.client import ContactsClient # noqa: E402
92
+
93
+ self._contacts = ContactsClient(client_wrapper=self._client_wrapper)
94
+ return self._contacts
95
+
96
+ @property
97
+ def segments(self):
98
+ if self._segments is None:
99
+ from .segments.client import SegmentsClient # noqa: E402
100
+
101
+ self._segments = SegmentsClient(client_wrapper=self._client_wrapper)
102
+ return self._segments
103
+
104
+
105
+ def _make_default_async_client(
106
+ timeout: typing.Optional[float],
107
+ follow_redirects: typing.Optional[bool],
108
+ ) -> httpx.AsyncClient:
109
+ try:
110
+ import httpx_aiohttp # type: ignore[import-not-found]
111
+ except ImportError:
112
+ pass
113
+ else:
114
+ if follow_redirects is not None:
115
+ return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout, follow_redirects=follow_redirects)
116
+ return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout)
117
+
118
+ if follow_redirects is not None:
119
+ return httpx.AsyncClient(timeout=timeout, follow_redirects=follow_redirects)
120
+ return httpx.AsyncClient(timeout=timeout)
121
+
122
+
123
+ class AsyncInformly:
124
+ """
125
+ 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.
126
+
127
+ Parameters
128
+ ----------
129
+ base_url : typing.Optional[str]
130
+ The base url to use for requests from the client.
131
+
132
+ environment : InformlyEnvironment
133
+ The environment to use for requests from the client. from .environment import InformlyEnvironment
134
+
135
+
136
+
137
+ Defaults to InformlyEnvironment.DEFAULT
138
+
139
+
140
+
141
+ token : typing.Union[str, typing.Callable[[], str]]
142
+ headers : typing.Optional[typing.Dict[str, str]]
143
+ Additional headers to send with every request.
144
+
145
+ async_token : typing.Optional[typing.Callable[[], typing.Awaitable[str]]]
146
+ An async callable that returns a bearer token. Use this when token acquisition involves async I/O (e.g., refreshing tokens via an async HTTP client). When provided, this is used instead of the synchronous token for async requests.
147
+
148
+ timeout : typing.Optional[float]
149
+ The timeout to be used, in seconds, for requests. By default the timeout is 30 seconds, unless a custom httpx client is used, in which case this default is not enforced.
150
+
151
+ follow_redirects : typing.Optional[bool]
152
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
153
+
154
+ httpx_client : typing.Optional[httpx.AsyncClient]
155
+ 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.
156
+
157
+ logging : typing.Optional[typing.Union[LogConfig, Logger]]
158
+ Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
159
+
160
+ Examples
161
+ --------
162
+ from informly-sdk import AsyncInformly
163
+
164
+ client = AsyncInformly(token="YOUR_TOKEN", )
165
+ """
166
+
167
+ def __init__(
168
+ self,
169
+ *,
170
+ base_url: typing.Optional[str] = None,
171
+ environment: InformlyEnvironment = InformlyEnvironment.DEFAULT,
172
+ token: typing.Union[str, typing.Callable[[], str]],
173
+ headers: typing.Optional[typing.Dict[str, str]] = None,
174
+ async_token: typing.Optional[typing.Callable[[], typing.Awaitable[str]]] = None,
175
+ timeout: typing.Optional[float] = None,
176
+ follow_redirects: typing.Optional[bool] = True,
177
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
178
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
179
+ ):
180
+ _defaulted_timeout = (
181
+ timeout if timeout is not None else 30 if httpx_client is None else httpx_client.timeout.read
182
+ )
183
+ self._client_wrapper = AsyncClientWrapper(
184
+ base_url=_get_base_url(base_url=base_url, environment=environment),
185
+ token=token,
186
+ headers=headers,
187
+ async_token=async_token,
188
+ httpx_client=httpx_client
189
+ if httpx_client is not None
190
+ else _make_default_async_client(timeout=_defaulted_timeout, follow_redirects=follow_redirects),
191
+ timeout=_defaulted_timeout,
192
+ logging=logging,
193
+ )
194
+ self._contacts: typing.Optional[AsyncContactsClient] = None
195
+ self._segments: typing.Optional[AsyncSegmentsClient] = None
196
+
197
+ @property
198
+ def contacts(self):
199
+ if self._contacts is None:
200
+ from .contacts.client import AsyncContactsClient # noqa: E402
201
+
202
+ self._contacts = AsyncContactsClient(client_wrapper=self._client_wrapper)
203
+ return self._contacts
204
+
205
+ @property
206
+ def segments(self):
207
+ if self._segments is None:
208
+ from .segments.client import AsyncSegmentsClient # noqa: E402
209
+
210
+ self._segments = AsyncSegmentsClient(client_wrapper=self._client_wrapper)
211
+ return self._segments
212
+
213
+
214
+ def _get_base_url(*, base_url: typing.Optional[str] = None, environment: InformlyEnvironment) -> str:
215
+ if base_url is not None:
216
+ return base_url
217
+ elif environment is not None:
218
+ return environment.value
219
+ else:
220
+ raise Exception("Please pass in either base_url or environment to construct the client")
@@ -0,0 +1,58 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .types import (
10
+ CreateContactResponse,
11
+ DeleteContactResponse,
12
+ DeleteContactsResponse,
13
+ DeleteContactsResponseData,
14
+ GetContactResponse,
15
+ ListContactsResponse,
16
+ UpdateContactResponse,
17
+ )
18
+ _dynamic_imports: typing.Dict[str, str] = {
19
+ "CreateContactResponse": ".types",
20
+ "DeleteContactResponse": ".types",
21
+ "DeleteContactsResponse": ".types",
22
+ "DeleteContactsResponseData": ".types",
23
+ "GetContactResponse": ".types",
24
+ "ListContactsResponse": ".types",
25
+ "UpdateContactResponse": ".types",
26
+ }
27
+
28
+
29
+ def __getattr__(attr_name: str) -> typing.Any:
30
+ module_name = _dynamic_imports.get(attr_name)
31
+ if module_name is None:
32
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
33
+ try:
34
+ module = import_module(module_name, __package__)
35
+ if module_name == f".{attr_name}":
36
+ return module
37
+ else:
38
+ return getattr(module, attr_name)
39
+ except ImportError as e:
40
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
41
+ except AttributeError as e:
42
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
43
+
44
+
45
+ def __dir__():
46
+ lazy_attrs = list(_dynamic_imports.keys())
47
+ return sorted(lazy_attrs)
48
+
49
+
50
+ __all__ = [
51
+ "CreateContactResponse",
52
+ "DeleteContactResponse",
53
+ "DeleteContactsResponse",
54
+ "DeleteContactsResponseData",
55
+ "GetContactResponse",
56
+ "ListContactsResponse",
57
+ "UpdateContactResponse",
58
+ ]