omdaa-api-client 1.0.0__tar.gz → 1.2.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.
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/PKG-INFO +66 -66
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/README.md +50 -50
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/pyproject.toml +33 -33
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/setup.cfg +4 -4
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/src/omdaa/__init__.py +9 -9
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/src/omdaa/client.py +167 -157
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/src/omdaa/exceptions.py +8 -8
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/src/omdaa/resources/__init__.py +83 -79
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/src/omdaa/resources/resources.py +707 -617
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/src/omdaa_api_client.egg-info/PKG-INFO +66 -66
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/tests/test_client.py +97 -97
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/src/omdaa_api_client.egg-info/SOURCES.txt +0 -0
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/src/omdaa_api_client.egg-info/dependency_links.txt +0 -0
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/src/omdaa_api_client.egg-info/requires.txt +0 -0
- {omdaa_api_client-1.0.0 → omdaa_api_client-1.2.0}/src/omdaa_api_client.egg-info/top_level.txt +0 -0
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: omdaa-api-client
|
|
3
|
-
Version: 1.
|
|
4
|
-
Summary: Official Python client for Omdaa WhatsApp Business API
|
|
5
|
-
Author: Omdaa
|
|
6
|
-
License:
|
|
7
|
-
Project-URL: Homepage, https://omdaa.com
|
|
8
|
-
Project-URL: Documentation, https://
|
|
9
|
-
Keywords: omdaa,whatsapp,api,client,sdk
|
|
10
|
-
Requires-Python: >=3.9
|
|
11
|
-
Description-Content-Type: text/markdown
|
|
12
|
-
Requires-Dist: requests>=2.28.0
|
|
13
|
-
Provides-Extra: dev
|
|
14
|
-
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
15
|
-
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
16
|
-
|
|
17
|
-
# omdaa-api-client (Python)
|
|
18
|
-
|
|
19
|
-
Official Python client for the [Omdaa](https://omdaa.com) WhatsApp Business API.
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
pip install omdaa-api-client
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Quick Start
|
|
28
|
-
|
|
29
|
-
```python
|
|
30
|
-
from omdaa import OmdaaClient, OmdaaError
|
|
31
|
-
|
|
32
|
-
client = OmdaaClient("your-api-key")
|
|
33
|
-
# Optional: OmdaaClient("your-api-key", base_url="https://omdaa.com/api/v1")
|
|
34
|
-
|
|
35
|
-
try:
|
|
36
|
-
sessions = client.sessions.list()
|
|
37
|
-
result = client.messages.send_text({
|
|
38
|
-
"sessionId": "default",
|
|
39
|
-
"to": "201234567890",
|
|
40
|
-
"message": "Hello from Omdaa Python!",
|
|
41
|
-
})
|
|
42
|
-
client.webhooks.set({"url": "https://yoursite.com/webhook", "enabled": True})
|
|
43
|
-
except OmdaaError as e:
|
|
44
|
-
print(e.status_code, str(e))
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## API Resources
|
|
48
|
-
|
|
49
|
-
Same as the Node.js SDK: `messages`, `sessions`, `webhooks`, `templates`, `scheduled`, `bulk`, `contacts`, `groups`, `chats`, `business`, `storage`, `labels`, `integrations`, `queue`, `interactive`, `api_keys`, `profile`, `dashboard`, `plans`, `billing`, `referral`, `notifications`, `metrics`, `backup`, `security`, `audit`, `organizations`, `settings`, `channels`, `privacy`, `support`, `proxy`, `calls`, `auth`, `users`, `email`, `ai`.
|
|
50
|
-
|
|
51
|
-
## Requirements
|
|
52
|
-
|
|
53
|
-
- Python 3.9+
|
|
54
|
-
- requests >= 2.28.0
|
|
55
|
-
|
|
56
|
-
## Development & tests
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
pip install -e ".[dev]"
|
|
60
|
-
python -m pytest tests -v
|
|
61
|
-
# or: python -m unittest discover -s tests -v
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## License
|
|
65
|
-
|
|
66
|
-
MIT
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: omdaa-api-client
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: Official Python client for Omdaa WhatsApp Business API + Omdaa Mail
|
|
5
|
+
Author: Omdaa
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://omdaa.com
|
|
8
|
+
Project-URL: Documentation, https://omdaa.com
|
|
9
|
+
Keywords: omdaa,whatsapp,mail,api,client,sdk,bulk,groups
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: requests>=2.28.0
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
15
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
16
|
+
|
|
17
|
+
# omdaa-api-client (Python)
|
|
18
|
+
|
|
19
|
+
Official Python client for the [Omdaa](https://omdaa.com) WhatsApp Business API. **Omdaa API is free forever** — unlimited sessions, messages, and Omdaa AI.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install omdaa-api-client
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from omdaa import OmdaaClient, OmdaaError
|
|
31
|
+
|
|
32
|
+
client = OmdaaClient("your-api-key")
|
|
33
|
+
# Optional: OmdaaClient("your-api-key", base_url="https://omdaa.com/api/v1")
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
sessions = client.sessions.list()
|
|
37
|
+
result = client.messages.send_text({
|
|
38
|
+
"sessionId": "default",
|
|
39
|
+
"to": "201234567890",
|
|
40
|
+
"message": "Hello from Omdaa Python!",
|
|
41
|
+
})
|
|
42
|
+
client.webhooks.set({"url": "https://yoursite.com/webhook", "enabled": True})
|
|
43
|
+
except OmdaaError as e:
|
|
44
|
+
print(e.status_code, str(e))
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## API Resources
|
|
48
|
+
|
|
49
|
+
Same as the Node.js SDK: `messages`, `sessions`, `webhooks`, `templates`, `scheduled`, `bulk`, `contacts`, `groups`, `chats`, `business`, `storage`, `labels`, `integrations`, `queue`, `interactive`, `api_keys`, `profile`, `dashboard`, `plans`, `billing`, `referral`, `notifications`, `metrics`, `backup`, `security`, `audit`, `organizations`, `settings`, `channels`, `privacy`, `support`, `proxy`, `calls`, `auth`, `users`, `email`, `ai`.
|
|
50
|
+
|
|
51
|
+
## Requirements
|
|
52
|
+
|
|
53
|
+
- Python 3.9+
|
|
54
|
+
- requests >= 2.28.0
|
|
55
|
+
|
|
56
|
+
## Development & tests
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install -e ".[dev]"
|
|
60
|
+
python -m pytest tests -v
|
|
61
|
+
# or: python -m unittest discover -s tests -v
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
# omdaa-api-client (Python)
|
|
2
|
-
|
|
3
|
-
Official Python client for the [Omdaa](https://omdaa.com) WhatsApp Business API.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pip install omdaa-api-client
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
```python
|
|
14
|
-
from omdaa import OmdaaClient, OmdaaError
|
|
15
|
-
|
|
16
|
-
client = OmdaaClient("your-api-key")
|
|
17
|
-
# Optional: OmdaaClient("your-api-key", base_url="https://omdaa.com/api/v1")
|
|
18
|
-
|
|
19
|
-
try:
|
|
20
|
-
sessions = client.sessions.list()
|
|
21
|
-
result = client.messages.send_text({
|
|
22
|
-
"sessionId": "default",
|
|
23
|
-
"to": "201234567890",
|
|
24
|
-
"message": "Hello from Omdaa Python!",
|
|
25
|
-
})
|
|
26
|
-
client.webhooks.set({"url": "https://yoursite.com/webhook", "enabled": True})
|
|
27
|
-
except OmdaaError as e:
|
|
28
|
-
print(e.status_code, str(e))
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## API Resources
|
|
32
|
-
|
|
33
|
-
Same as the Node.js SDK: `messages`, `sessions`, `webhooks`, `templates`, `scheduled`, `bulk`, `contacts`, `groups`, `chats`, `business`, `storage`, `labels`, `integrations`, `queue`, `interactive`, `api_keys`, `profile`, `dashboard`, `plans`, `billing`, `referral`, `notifications`, `metrics`, `backup`, `security`, `audit`, `organizations`, `settings`, `channels`, `privacy`, `support`, `proxy`, `calls`, `auth`, `users`, `email`, `ai`.
|
|
34
|
-
|
|
35
|
-
## Requirements
|
|
36
|
-
|
|
37
|
-
- Python 3.9+
|
|
38
|
-
- requests >= 2.28.0
|
|
39
|
-
|
|
40
|
-
## Development & tests
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
pip install -e ".[dev]"
|
|
44
|
-
python -m pytest tests -v
|
|
45
|
-
# or: python -m unittest discover -s tests -v
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## License
|
|
49
|
-
|
|
50
|
-
MIT
|
|
1
|
+
# omdaa-api-client (Python)
|
|
2
|
+
|
|
3
|
+
Official Python client for the [Omdaa](https://omdaa.com) WhatsApp Business API. **Omdaa API is free forever** — unlimited sessions, messages, and Omdaa AI.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install omdaa-api-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from omdaa import OmdaaClient, OmdaaError
|
|
15
|
+
|
|
16
|
+
client = OmdaaClient("your-api-key")
|
|
17
|
+
# Optional: OmdaaClient("your-api-key", base_url="https://omdaa.com/api/v1")
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
sessions = client.sessions.list()
|
|
21
|
+
result = client.messages.send_text({
|
|
22
|
+
"sessionId": "default",
|
|
23
|
+
"to": "201234567890",
|
|
24
|
+
"message": "Hello from Omdaa Python!",
|
|
25
|
+
})
|
|
26
|
+
client.webhooks.set({"url": "https://yoursite.com/webhook", "enabled": True})
|
|
27
|
+
except OmdaaError as e:
|
|
28
|
+
print(e.status_code, str(e))
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API Resources
|
|
32
|
+
|
|
33
|
+
Same as the Node.js SDK: `messages`, `sessions`, `webhooks`, `templates`, `scheduled`, `bulk`, `contacts`, `groups`, `chats`, `business`, `storage`, `labels`, `integrations`, `queue`, `interactive`, `api_keys`, `profile`, `dashboard`, `plans`, `billing`, `referral`, `notifications`, `metrics`, `backup`, `security`, `audit`, `organizations`, `settings`, `channels`, `privacy`, `support`, `proxy`, `calls`, `auth`, `users`, `email`, `ai`.
|
|
34
|
+
|
|
35
|
+
## Requirements
|
|
36
|
+
|
|
37
|
+
- Python 3.9+
|
|
38
|
+
- requests >= 2.28.0
|
|
39
|
+
|
|
40
|
+
## Development & tests
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install -e ".[dev]"
|
|
44
|
+
python -m pytest tests -v
|
|
45
|
+
# or: python -m unittest discover -s tests -v
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=61", "wheel"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "omdaa-api-client"
|
|
7
|
-
version = "1.
|
|
8
|
-
description = "Official Python client for Omdaa WhatsApp Business API"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.9"
|
|
11
|
-
license =
|
|
12
|
-
authors = [{ name = "Omdaa" }]
|
|
13
|
-
keywords = ["omdaa", "whatsapp", "api", "client", "sdk"]
|
|
14
|
-
dependencies = [
|
|
15
|
-
"requests>=2.28.0",
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
[project.optional-dependencies]
|
|
19
|
-
dev = ["pytest>=7.0", "pytest-cov>=4.0"]
|
|
20
|
-
|
|
21
|
-
[project.urls]
|
|
22
|
-
Homepage = "https://omdaa.com"
|
|
23
|
-
Documentation = "https://
|
|
24
|
-
|
|
25
|
-
[tool.pytest.ini_options]
|
|
26
|
-
testpaths = ["tests"]
|
|
27
|
-
pythonpath = ["src"]
|
|
28
|
-
|
|
29
|
-
[tool.setuptools.packages.find]
|
|
30
|
-
where = ["src"]
|
|
31
|
-
|
|
32
|
-
[tool.setuptools.package-dir]
|
|
33
|
-
"" = "src"
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "omdaa-api-client"
|
|
7
|
+
version = "1.2.0"
|
|
8
|
+
description = "Official Python client for Omdaa WhatsApp Business API + Omdaa Mail"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
authors = [{ name = "Omdaa" }]
|
|
13
|
+
keywords = ["omdaa", "whatsapp", "mail", "api", "client", "sdk", "bulk", "groups"]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"requests>=2.28.0",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.optional-dependencies]
|
|
19
|
+
dev = ["pytest>=7.0", "pytest-cov>=4.0"]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://omdaa.com"
|
|
23
|
+
Documentation = "https://omdaa.com"
|
|
24
|
+
|
|
25
|
+
[tool.pytest.ini_options]
|
|
26
|
+
testpaths = ["tests"]
|
|
27
|
+
pythonpath = ["src"]
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
where = ["src"]
|
|
31
|
+
|
|
32
|
+
[tool.setuptools.package-dir]
|
|
33
|
+
"" = "src"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Omdaa API Client - Official Python SDK for Omdaa WhatsApp Business API.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from omdaa.client import OmdaaClient
|
|
6
|
-
from omdaa.exceptions import OmdaaError
|
|
7
|
-
|
|
8
|
-
__all__ = ["OmdaaClient", "OmdaaError"]
|
|
9
|
-
__version__ = "1.0.0"
|
|
1
|
+
"""
|
|
2
|
+
Omdaa API Client - Official Python SDK for Omdaa WhatsApp Business API.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from omdaa.client import OmdaaClient
|
|
6
|
+
from omdaa.exceptions import OmdaaError
|
|
7
|
+
|
|
8
|
+
__all__ = ["OmdaaClient", "OmdaaError"]
|
|
9
|
+
__version__ = "1.0.0"
|
|
@@ -1,157 +1,167 @@
|
|
|
1
|
-
"""
|
|
2
|
-
HTTP client for Omdaa API with Bearer auth.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from typing import Optional
|
|
6
|
-
|
|
7
|
-
import requests
|
|
8
|
-
from omdaa.exceptions import OmdaaError
|
|
9
|
-
|
|
10
|
-
DEFAULT_BASE_URL = "https://omdaa.com/api/v1"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class Client:
|
|
14
|
-
def __init__(self, api_key: str, base_url: Optional[str] = None):
|
|
15
|
-
self.api_key = api_key
|
|
16
|
-
self.base_url = (base_url or DEFAULT_BASE_URL).rstrip("/")
|
|
17
|
-
self._session = requests.Session()
|
|
18
|
-
self._session.headers.update({
|
|
19
|
-
"Authorization": f"Bearer {api_key}",
|
|
20
|
-
"Content-Type": "application/json",
|
|
21
|
-
"Accept": "application/json",
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
def request(
|
|
25
|
-
self,
|
|
26
|
-
method: str,
|
|
27
|
-
path: str,
|
|
28
|
-
body: Optional[dict] = None,
|
|
29
|
-
params: Optional[dict] = None,
|
|
30
|
-
) -> dict:
|
|
31
|
-
url = f"{self.base_url}{path}" if path.startswith("/") else f"{self.base_url}/{path}"
|
|
32
|
-
kwargs = {}
|
|
33
|
-
if params:
|
|
34
|
-
kwargs["params"] = {k: v for k, v in params.items() if v is not None}
|
|
35
|
-
if body and method != "GET":
|
|
36
|
-
kwargs["json"] = body
|
|
37
|
-
try:
|
|
38
|
-
r = self._session.request(method, url, **kwargs)
|
|
39
|
-
data = r.json() if r.content else {}
|
|
40
|
-
if not r.ok:
|
|
41
|
-
raise OmdaaError(
|
|
42
|
-
data.get("message", r.text or r.reason),
|
|
43
|
-
status_code=r.status_code,
|
|
44
|
-
body=data if isinstance(data, dict) else None,
|
|
45
|
-
)
|
|
46
|
-
return data
|
|
47
|
-
except OmdaaError:
|
|
48
|
-
raise
|
|
49
|
-
except requests.RequestException as e:
|
|
50
|
-
raise OmdaaError(str(e)) from e
|
|
51
|
-
|
|
52
|
-
def get(self, path: str, params: dict | None = None) -> dict:
|
|
53
|
-
return self.request("GET", path, params=params)
|
|
54
|
-
|
|
55
|
-
def post(self, path: str, body: Optional[dict] = None) -> dict:
|
|
56
|
-
return self.request("POST", path, body=body or {})
|
|
57
|
-
|
|
58
|
-
def put(self, path: str, body: Optional[dict] = None) -> dict:
|
|
59
|
-
return self.request("PUT", path, body=body or {})
|
|
60
|
-
|
|
61
|
-
def
|
|
62
|
-
return self.request("
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
self.
|
|
115
|
-
self.
|
|
116
|
-
self.
|
|
117
|
-
self.
|
|
118
|
-
self.
|
|
119
|
-
self.
|
|
120
|
-
self.
|
|
121
|
-
self.
|
|
122
|
-
self.
|
|
123
|
-
self.
|
|
124
|
-
self.
|
|
125
|
-
self.
|
|
126
|
-
self.
|
|
127
|
-
self.
|
|
128
|
-
self.
|
|
129
|
-
self.
|
|
130
|
-
self.
|
|
131
|
-
self.
|
|
132
|
-
self.
|
|
133
|
-
self.
|
|
134
|
-
self.
|
|
135
|
-
self.
|
|
136
|
-
self.
|
|
137
|
-
self.
|
|
138
|
-
self.
|
|
139
|
-
self.
|
|
140
|
-
self.
|
|
141
|
-
self.
|
|
142
|
-
self.
|
|
143
|
-
self.
|
|
144
|
-
self.
|
|
145
|
-
self.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
1
|
+
"""
|
|
2
|
+
HTTP client for Omdaa API with Bearer auth.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
import requests
|
|
8
|
+
from omdaa.exceptions import OmdaaError
|
|
9
|
+
|
|
10
|
+
DEFAULT_BASE_URL = "https://omdaa.com/api/v1"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Client:
|
|
14
|
+
def __init__(self, api_key: str, base_url: Optional[str] = None):
|
|
15
|
+
self.api_key = api_key
|
|
16
|
+
self.base_url = (base_url or DEFAULT_BASE_URL).rstrip("/")
|
|
17
|
+
self._session = requests.Session()
|
|
18
|
+
self._session.headers.update({
|
|
19
|
+
"Authorization": f"Bearer {api_key}",
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
"Accept": "application/json",
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
def request(
|
|
25
|
+
self,
|
|
26
|
+
method: str,
|
|
27
|
+
path: str,
|
|
28
|
+
body: Optional[dict] = None,
|
|
29
|
+
params: Optional[dict] = None,
|
|
30
|
+
) -> dict:
|
|
31
|
+
url = f"{self.base_url}{path}" if path.startswith("/") else f"{self.base_url}/{path}"
|
|
32
|
+
kwargs = {}
|
|
33
|
+
if params:
|
|
34
|
+
kwargs["params"] = {k: v for k, v in params.items() if v is not None}
|
|
35
|
+
if body and method != "GET":
|
|
36
|
+
kwargs["json"] = body
|
|
37
|
+
try:
|
|
38
|
+
r = self._session.request(method, url, **kwargs)
|
|
39
|
+
data = r.json() if r.content else {}
|
|
40
|
+
if not r.ok:
|
|
41
|
+
raise OmdaaError(
|
|
42
|
+
data.get("message", r.text or r.reason),
|
|
43
|
+
status_code=r.status_code,
|
|
44
|
+
body=data if isinstance(data, dict) else None,
|
|
45
|
+
)
|
|
46
|
+
return data
|
|
47
|
+
except OmdaaError:
|
|
48
|
+
raise
|
|
49
|
+
except requests.RequestException as e:
|
|
50
|
+
raise OmdaaError(str(e)) from e
|
|
51
|
+
|
|
52
|
+
def get(self, path: str, params: dict | None = None) -> dict:
|
|
53
|
+
return self.request("GET", path, params=params)
|
|
54
|
+
|
|
55
|
+
def post(self, path: str, body: Optional[dict] = None) -> dict:
|
|
56
|
+
return self.request("POST", path, body=body or {})
|
|
57
|
+
|
|
58
|
+
def put(self, path: str, body: Optional[dict] = None) -> dict:
|
|
59
|
+
return self.request("PUT", path, body=body or {})
|
|
60
|
+
|
|
61
|
+
def patch(self, path: str, body: Optional[dict] = None) -> dict:
|
|
62
|
+
return self.request("PATCH", path, body=body or {})
|
|
63
|
+
|
|
64
|
+
def delete(self, path: str, body: Optional[dict] = None) -> dict:
|
|
65
|
+
return self.request("DELETE", path, body=body)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class OmdaaClient:
|
|
69
|
+
"""Main client with all API resources. Use with API Key (Bearer auth)."""
|
|
70
|
+
|
|
71
|
+
def __init__(self, api_key: str, base_url: Optional[str] = None):
|
|
72
|
+
self._client = Client(api_key, base_url)
|
|
73
|
+
from omdaa.resources.resources import (
|
|
74
|
+
MessagesResource,
|
|
75
|
+
SessionsResource,
|
|
76
|
+
WebhooksResource,
|
|
77
|
+
TemplatesResource,
|
|
78
|
+
ScheduledResource,
|
|
79
|
+
BulkResource,
|
|
80
|
+
ContactsResource,
|
|
81
|
+
GroupsResource,
|
|
82
|
+
ChatsResource,
|
|
83
|
+
BusinessResource,
|
|
84
|
+
StorageResource,
|
|
85
|
+
LabelsResource,
|
|
86
|
+
IntegrationsResource,
|
|
87
|
+
QueueResource,
|
|
88
|
+
InteractiveResource,
|
|
89
|
+
ApiKeysResource,
|
|
90
|
+
ProfileResource,
|
|
91
|
+
DashboardResource,
|
|
92
|
+
PlansResource,
|
|
93
|
+
BillingResource,
|
|
94
|
+
ReferralResource,
|
|
95
|
+
NotificationsResource,
|
|
96
|
+
MetricsResource,
|
|
97
|
+
BackupResource,
|
|
98
|
+
SecurityResource,
|
|
99
|
+
AuditResource,
|
|
100
|
+
OrganizationsResource,
|
|
101
|
+
SettingsResource,
|
|
102
|
+
ChannelsResource,
|
|
103
|
+
PrivacyResource,
|
|
104
|
+
SupportResource,
|
|
105
|
+
ProxyResource,
|
|
106
|
+
CallsResource,
|
|
107
|
+
AuthResource,
|
|
108
|
+
UsersResource,
|
|
109
|
+
EmailResource,
|
|
110
|
+
MailboxesResource,
|
|
111
|
+
MailResource,
|
|
112
|
+
AiResource,
|
|
113
|
+
)
|
|
114
|
+
self.messages = MessagesResource(self)
|
|
115
|
+
self.sessions = SessionsResource(self)
|
|
116
|
+
self.webhooks = WebhooksResource(self)
|
|
117
|
+
self.templates = TemplatesResource(self)
|
|
118
|
+
self.scheduled = ScheduledResource(self)
|
|
119
|
+
self.bulk = BulkResource(self)
|
|
120
|
+
self.contacts = ContactsResource(self)
|
|
121
|
+
self.groups = GroupsResource(self)
|
|
122
|
+
self.chats = ChatsResource(self)
|
|
123
|
+
self.business = BusinessResource(self)
|
|
124
|
+
self.storage = StorageResource(self)
|
|
125
|
+
self.labels = LabelsResource(self)
|
|
126
|
+
self.integrations = IntegrationsResource(self)
|
|
127
|
+
self.queue = QueueResource(self)
|
|
128
|
+
self.interactive = InteractiveResource(self)
|
|
129
|
+
self.api_keys = ApiKeysResource(self)
|
|
130
|
+
self.profile = ProfileResource(self)
|
|
131
|
+
self.dashboard = DashboardResource(self)
|
|
132
|
+
self.plans = PlansResource(self)
|
|
133
|
+
self.billing = BillingResource(self)
|
|
134
|
+
self.referral = ReferralResource(self)
|
|
135
|
+
self.notifications = NotificationsResource(self)
|
|
136
|
+
self.metrics = MetricsResource(self)
|
|
137
|
+
self.backup = BackupResource(self)
|
|
138
|
+
self.security = SecurityResource(self)
|
|
139
|
+
self.audit = AuditResource(self)
|
|
140
|
+
self.organizations = OrganizationsResource(self)
|
|
141
|
+
self.settings = SettingsResource(self)
|
|
142
|
+
self.channels = ChannelsResource(self)
|
|
143
|
+
self.privacy = PrivacyResource(self)
|
|
144
|
+
self.support = SupportResource(self)
|
|
145
|
+
self.proxy = ProxyResource(self)
|
|
146
|
+
self.calls = CallsResource(self)
|
|
147
|
+
self.auth = AuthResource(self)
|
|
148
|
+
self.users = UsersResource(self)
|
|
149
|
+
self.email = EmailResource(self)
|
|
150
|
+
self.mailboxes = MailboxesResource(self)
|
|
151
|
+
self.mail = MailResource(self)
|
|
152
|
+
self.ai = AiResource(self)
|
|
153
|
+
|
|
154
|
+
def get(self, path: str, params: Optional[dict] = None) -> dict:
|
|
155
|
+
return self._client.get(path, params=params)
|
|
156
|
+
|
|
157
|
+
def post(self, path: str, body: Optional[dict] = None) -> dict:
|
|
158
|
+
return self._client.post(path, body=body)
|
|
159
|
+
|
|
160
|
+
def put(self, path: str, body: Optional[dict] = None) -> dict:
|
|
161
|
+
return self._client.put(path, body=body)
|
|
162
|
+
|
|
163
|
+
def patch(self, path: str, body: Optional[dict] = None) -> dict:
|
|
164
|
+
return self._client.patch(path, body=body)
|
|
165
|
+
|
|
166
|
+
def delete(self, path: str, body: Optional[dict] = None) -> dict:
|
|
167
|
+
return self._client.delete(path, body=body)
|