informly 0.1.0__tar.gz
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.
- informly-0.1.0/LICENSE +21 -0
- informly-0.1.0/PKG-INFO +12 -0
- informly-0.1.0/README.md +164 -0
- informly-0.1.0/pyproject.toml +19 -0
- informly-0.1.0/setup.cfg +4 -0
- informly-0.1.0/src/informly/__init__.py +114 -0
- informly-0.1.0/src/informly/_default_clients.py +30 -0
- informly-0.1.0/src/informly/client.py +220 -0
- informly-0.1.0/src/informly/contacts/__init__.py +58 -0
- informly-0.1.0/src/informly/contacts/client.py +582 -0
- informly-0.1.0/src/informly/contacts/raw_client.py +1059 -0
- informly-0.1.0/src/informly/contacts/types/__init__.py +56 -0
- informly-0.1.0/src/informly/contacts/types/create_contact_response.py +13 -0
- informly-0.1.0/src/informly/contacts/types/delete_contact_response.py +13 -0
- informly-0.1.0/src/informly/contacts/types/delete_contacts_response.py +13 -0
- informly-0.1.0/src/informly/contacts/types/delete_contacts_response_data.py +15 -0
- informly-0.1.0/src/informly/contacts/types/get_contact_response.py +13 -0
- informly-0.1.0/src/informly/contacts/types/list_contacts_response.py +15 -0
- informly-0.1.0/src/informly/contacts/types/update_contact_response.py +13 -0
- informly-0.1.0/src/informly/core/__init__.py +125 -0
- informly-0.1.0/src/informly/core/api_error.py +23 -0
- informly-0.1.0/src/informly/core/client_wrapper.py +103 -0
- informly-0.1.0/src/informly/core/datetime_utils.py +70 -0
- informly-0.1.0/src/informly/core/file.py +67 -0
- informly-0.1.0/src/informly/core/force_multipart.py +18 -0
- informly-0.1.0/src/informly/core/http_client.py +840 -0
- informly-0.1.0/src/informly/core/http_response.py +59 -0
- informly-0.1.0/src/informly/core/http_sse/__init__.py +42 -0
- informly-0.1.0/src/informly/core/http_sse/_api.py +112 -0
- informly-0.1.0/src/informly/core/http_sse/_decoders.py +61 -0
- informly-0.1.0/src/informly/core/http_sse/_exceptions.py +7 -0
- informly-0.1.0/src/informly/core/http_sse/_models.py +17 -0
- informly-0.1.0/src/informly/core/jsonable_encoder.py +108 -0
- informly-0.1.0/src/informly/core/logging.py +107 -0
- informly-0.1.0/src/informly/core/parse_error.py +36 -0
- informly-0.1.0/src/informly/core/pydantic_utilities.py +634 -0
- informly-0.1.0/src/informly/core/query_encoder.py +58 -0
- informly-0.1.0/src/informly/core/remove_none_from_dict.py +11 -0
- informly-0.1.0/src/informly/core/request_options.py +35 -0
- informly-0.1.0/src/informly/core/serialization.py +276 -0
- informly-0.1.0/src/informly/environment.py +7 -0
- informly-0.1.0/src/informly/errors/__init__.py +42 -0
- informly-0.1.0/src/informly/errors/bad_request_error.py +11 -0
- informly-0.1.0/src/informly/errors/forbidden_error.py +11 -0
- informly-0.1.0/src/informly/errors/not_found_error.py +11 -0
- informly-0.1.0/src/informly/errors/unauthorized_error.py +11 -0
- informly-0.1.0/src/informly/segments/__init__.py +34 -0
- informly-0.1.0/src/informly/segments/client.py +92 -0
- informly-0.1.0/src/informly/segments/raw_client.py +150 -0
- informly-0.1.0/src/informly/segments/types/__init__.py +34 -0
- informly-0.1.0/src/informly/segments/types/list_segments_response.py +13 -0
- informly-0.1.0/src/informly/types/__init__.py +59 -0
- informly-0.1.0/src/informly/types/contact.py +52 -0
- informly-0.1.0/src/informly/types/contact_contact.py +30 -0
- informly-0.1.0/src/informly/types/contact_segments_item.py +22 -0
- informly-0.1.0/src/informly/types/error_response.py +13 -0
- informly-0.1.0/src/informly/types/error_response_error.py +26 -0
- informly-0.1.0/src/informly/types/error_response_error_details_item.py +20 -0
- informly-0.1.0/src/informly/types/pagination_meta.py +31 -0
- informly-0.1.0/src/informly/types/segment.py +25 -0
- informly-0.1.0/src/informly.egg-info/PKG-INFO +12 -0
- informly-0.1.0/src/informly.egg-info/SOURCES.txt +64 -0
- informly-0.1.0/src/informly.egg-info/dependency_links.txt +1 -0
- informly-0.1.0/src/informly.egg-info/requires.txt +4 -0
- informly-0.1.0/src/informly.egg-info/top_level.txt +1 -0
- informly-0.1.0/tests/test_aiohttp_autodetect.py +113 -0
informly-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Informly
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
informly-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: informly
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Informly API client for Python
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: httpx>=0.21.2
|
|
9
|
+
Requires-Dist: pydantic>=2.0
|
|
10
|
+
Requires-Dist: pydantic-core>=2.18.2
|
|
11
|
+
Requires-Dist: typing_extensions>=4.0.0
|
|
12
|
+
Dynamic: license-file
|
informly-0.1.0/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Informly Python Library
|
|
2
|
+
|
|
3
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=Informly%2FPython)
|
|
4
|
+
[](https://pypi.python.org/pypi/informly-sdk)
|
|
5
|
+
|
|
6
|
+
The Informly Python library provides convenient access to the Informly APIs from Python.
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Documentation](#documentation)
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Usage](#usage)
|
|
13
|
+
- [Environments](#environments)
|
|
14
|
+
- [Async Client](#async-client)
|
|
15
|
+
- [Exception Handling](#exception-handling)
|
|
16
|
+
- [Advanced](#advanced)
|
|
17
|
+
- [Access Raw Response Data](#access-raw-response-data)
|
|
18
|
+
- [Retries](#retries)
|
|
19
|
+
- [Timeouts](#timeouts)
|
|
20
|
+
- [Custom Client](#custom-client)
|
|
21
|
+
|
|
22
|
+
## Documentation
|
|
23
|
+
|
|
24
|
+
API reference documentation is available [here](https://docs.informly.com/docs/api-reference).
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
pip install informly-sdk
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
Instantiate and use the client with the following:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from informly-sdk import Informly
|
|
38
|
+
|
|
39
|
+
client = Informly(
|
|
40
|
+
token="<token>",
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
client.contacts.create_contact()
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Environments
|
|
47
|
+
|
|
48
|
+
This SDK allows you to configure different environments for API requests.
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from informly-sdk import Informly
|
|
52
|
+
from informly-sdk.environment import InformlyEnvironment
|
|
53
|
+
|
|
54
|
+
client = Informly(
|
|
55
|
+
environment=InformlyEnvironment.DEFAULT,
|
|
56
|
+
)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Async Client
|
|
60
|
+
|
|
61
|
+
The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import asyncio
|
|
65
|
+
|
|
66
|
+
from informly-sdk import AsyncInformly
|
|
67
|
+
|
|
68
|
+
client = AsyncInformly(
|
|
69
|
+
token="<token>",
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
async def main() -> None:
|
|
74
|
+
await client.contacts.create_contact()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
asyncio.run(main())
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Exception Handling
|
|
81
|
+
|
|
82
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
83
|
+
will be thrown.
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from informly-sdk.core.api_error import ApiError
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
client.contacts.create_contact(...)
|
|
90
|
+
except ApiError as e:
|
|
91
|
+
print(e.status_code)
|
|
92
|
+
print(e.body)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Advanced
|
|
96
|
+
|
|
97
|
+
### Access Raw Response Data
|
|
98
|
+
|
|
99
|
+
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
|
|
100
|
+
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from informly-sdk import Informly
|
|
104
|
+
|
|
105
|
+
client = Informly(...)
|
|
106
|
+
response = client.contacts.with_raw_response.create_contact(...)
|
|
107
|
+
print(response.headers) # access the response headers
|
|
108
|
+
print(response.status_code) # access the response status code
|
|
109
|
+
print(response.data) # access the underlying object
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Retries
|
|
113
|
+
|
|
114
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
115
|
+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
116
|
+
retry limit (default: 2).
|
|
117
|
+
|
|
118
|
+
A request is deemed retryable when any of the following HTTP status codes is returned:
|
|
119
|
+
|
|
120
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
121
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
122
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
|
123
|
+
|
|
124
|
+
Use the `max_retries` request option to configure this behavior.
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
client.contacts.create_contact(..., request_options={
|
|
128
|
+
"max_retries": 1
|
|
129
|
+
})
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Timeouts
|
|
133
|
+
|
|
134
|
+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from informly-sdk import Informly
|
|
138
|
+
|
|
139
|
+
client = Informly(..., timeout=20.0)
|
|
140
|
+
|
|
141
|
+
# Override timeout for a specific method
|
|
142
|
+
client.contacts.create_contact(..., request_options={
|
|
143
|
+
"timeout_in_seconds": 1
|
|
144
|
+
})
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Custom Client
|
|
148
|
+
|
|
149
|
+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
|
|
150
|
+
and transports.
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
import httpx
|
|
154
|
+
from informly-sdk import Informly
|
|
155
|
+
|
|
156
|
+
client = Informly(
|
|
157
|
+
...,
|
|
158
|
+
httpx_client=httpx.Client(
|
|
159
|
+
proxy="http://my.test.proxy.example.com",
|
|
160
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
161
|
+
),
|
|
162
|
+
)
|
|
163
|
+
```
|
|
164
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "informly"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Official Informly API client for Python"
|
|
5
|
+
license = "MIT"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"httpx >= 0.21.2",
|
|
9
|
+
"pydantic >= 2.0",
|
|
10
|
+
"pydantic-core >= 2.18.2",
|
|
11
|
+
"typing_extensions >= 4.0.0",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[build-system]
|
|
15
|
+
requires = ["setuptools>=61.0"]
|
|
16
|
+
build-backend = "setuptools.build_meta"
|
|
17
|
+
|
|
18
|
+
[tool.setuptools.packages.find]
|
|
19
|
+
where = ["src"]
|
informly-0.1.0/setup.cfg
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)
|
|
@@ -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
|
+
]
|