sending-sdk 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.
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .pytest_cache/
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .venv/
@@ -0,0 +1,132 @@
1
+ Metadata-Version: 2.4
2
+ Name: sending-sdk
3
+ Version: 0.1.0
4
+ Summary: SDK Python ufficiale per l'API di Sending.dev (email + WhatsApp + Telegram)
5
+ Project-URL: Homepage, https://sending.dev
6
+ Project-URL: Documentation, https://sending.dev/api-reference
7
+ Author: Sending.dev
8
+ License: MIT
9
+ Keywords: api,email,sdk,sending,telegram,whatsapp
10
+ Requires-Python: >=3.10
11
+ Requires-Dist: httpx>=0.24
12
+ Requires-Dist: pydantic[email]>=2
13
+ Provides-Extra: dev
14
+ Requires-Dist: datamodel-code-generator>=0.25; extra == 'dev'
15
+ Requires-Dist: pytest>=7; extra == 'dev'
16
+ Requires-Dist: respx>=0.20; extra == 'dev'
17
+ Description-Content-Type: text/markdown
18
+
19
+ # sending-sdk
20
+
21
+ SDK Python ufficiale per l'[API di Sending.dev](https://sending.dev) (email + WhatsApp + Telegram).
22
+
23
+ I modelli Pydantic sono generati dallo spec OpenAPI; il client e' scritto a mano per la migliore DX.
24
+
25
+ ## Installazione
26
+
27
+ ```bash
28
+ pip install sending-sdk
29
+ ```
30
+
31
+ Si importa come `sending`:
32
+
33
+ ```python
34
+ from sending import Sending
35
+ ```
36
+
37
+ Richiede Python >= 3.10.
38
+
39
+ ## Uso
40
+
41
+ ```python
42
+ from sending import Sending
43
+
44
+ client = Sending(api_key="sk_...")
45
+
46
+ # Email transazionale (accetta un dict oppure un modello Pydantic)
47
+ client.emails.send({
48
+ "to": "cliente@esempio.com",
49
+ "from": "you@tuodominio.com",
50
+ "subject": "Benvenuto",
51
+ "html": "<p>Ciao!</p>",
52
+ "idempotencyKey": "welcome-001",
53
+ })
54
+
55
+ # Messaggio multi-canale
56
+ client.messages.send({
57
+ "channel": "whatsapp",
58
+ "to": "+393331234567",
59
+ "text": "Ciao!",
60
+ "idempotencyKey": "wa-001",
61
+ })
62
+ ```
63
+
64
+ Come context manager (chiude la connessione httpx):
65
+
66
+ ```python
67
+ with Sending(api_key="sk_...") as client:
68
+ page = client.contacts.list(q="mario", page=1, page_size=50)
69
+ print(page["total"], page["data"])
70
+ ```
71
+
72
+ ### Client asincrono
73
+
74
+ Stessa API, su `httpx.AsyncClient`:
75
+
76
+ ```python
77
+ import asyncio
78
+ from sending import AsyncSending
79
+
80
+ async def main():
81
+ async with AsyncSending(api_key="sk_...") as client:
82
+ await client.emails.send({
83
+ "to": "cliente@esempio.com",
84
+ "from": "you@tuodominio.com",
85
+ "subject": "Benvenuto",
86
+ "html": "<p>Ciao!</p>",
87
+ "idempotencyKey": "welcome-001",
88
+ })
89
+ page = await client.contacts.list(q="mario", page=1, page_size=50)
90
+ print(page["total"])
91
+
92
+ asyncio.run(main())
93
+ ```
94
+
95
+ ### Modelli tipizzati (opzionali)
96
+
97
+ ```python
98
+ from sending import models
99
+
100
+ body = models.SendEmailInput(
101
+ to="a@b.com", **{"from": "you@dominio.com"},
102
+ subject="Ciao", html="<p>Hi</p>", idempotencyKey="welcome-001",
103
+ )
104
+ client.emails.send(body) # serializzato con gli alias corretti (es. "from")
105
+ ```
106
+
107
+ ### Gestione errori
108
+
109
+ ```python
110
+ from sending import SendingError
111
+
112
+ try:
113
+ client.emails.send({...})
114
+ except SendingError as err:
115
+ print(err.status, err.code, err.body)
116
+ ```
117
+
118
+ ## Risorse disponibili
119
+
120
+ `emails` · `messages` · `events` · `campaigns` · `contacts` · `lists` · `tags` ·
121
+ `custom_fields` · `segments` · `domains` · `inboxes` · `email_rules` · `automations` ·
122
+ `webhooks` · `utm` · `integrations` · `usage`.
123
+
124
+ ## Sviluppo
125
+
126
+ ```bash
127
+ pip install -e ".[dev]"
128
+ python scripts/gen.py # rigenera sending/models.py da openapi.json
129
+ pytest
130
+ ```
131
+
132
+ Lo `openapi.json` viene copiato qui da `pnpm openapi:generate` (package `@sending/openapi`).
@@ -0,0 +1,114 @@
1
+ # sending-sdk
2
+
3
+ SDK Python ufficiale per l'[API di Sending.dev](https://sending.dev) (email + WhatsApp + Telegram).
4
+
5
+ I modelli Pydantic sono generati dallo spec OpenAPI; il client e' scritto a mano per la migliore DX.
6
+
7
+ ## Installazione
8
+
9
+ ```bash
10
+ pip install sending-sdk
11
+ ```
12
+
13
+ Si importa come `sending`:
14
+
15
+ ```python
16
+ from sending import Sending
17
+ ```
18
+
19
+ Richiede Python >= 3.10.
20
+
21
+ ## Uso
22
+
23
+ ```python
24
+ from sending import Sending
25
+
26
+ client = Sending(api_key="sk_...")
27
+
28
+ # Email transazionale (accetta un dict oppure un modello Pydantic)
29
+ client.emails.send({
30
+ "to": "cliente@esempio.com",
31
+ "from": "you@tuodominio.com",
32
+ "subject": "Benvenuto",
33
+ "html": "<p>Ciao!</p>",
34
+ "idempotencyKey": "welcome-001",
35
+ })
36
+
37
+ # Messaggio multi-canale
38
+ client.messages.send({
39
+ "channel": "whatsapp",
40
+ "to": "+393331234567",
41
+ "text": "Ciao!",
42
+ "idempotencyKey": "wa-001",
43
+ })
44
+ ```
45
+
46
+ Come context manager (chiude la connessione httpx):
47
+
48
+ ```python
49
+ with Sending(api_key="sk_...") as client:
50
+ page = client.contacts.list(q="mario", page=1, page_size=50)
51
+ print(page["total"], page["data"])
52
+ ```
53
+
54
+ ### Client asincrono
55
+
56
+ Stessa API, su `httpx.AsyncClient`:
57
+
58
+ ```python
59
+ import asyncio
60
+ from sending import AsyncSending
61
+
62
+ async def main():
63
+ async with AsyncSending(api_key="sk_...") as client:
64
+ await client.emails.send({
65
+ "to": "cliente@esempio.com",
66
+ "from": "you@tuodominio.com",
67
+ "subject": "Benvenuto",
68
+ "html": "<p>Ciao!</p>",
69
+ "idempotencyKey": "welcome-001",
70
+ })
71
+ page = await client.contacts.list(q="mario", page=1, page_size=50)
72
+ print(page["total"])
73
+
74
+ asyncio.run(main())
75
+ ```
76
+
77
+ ### Modelli tipizzati (opzionali)
78
+
79
+ ```python
80
+ from sending import models
81
+
82
+ body = models.SendEmailInput(
83
+ to="a@b.com", **{"from": "you@dominio.com"},
84
+ subject="Ciao", html="<p>Hi</p>", idempotencyKey="welcome-001",
85
+ )
86
+ client.emails.send(body) # serializzato con gli alias corretti (es. "from")
87
+ ```
88
+
89
+ ### Gestione errori
90
+
91
+ ```python
92
+ from sending import SendingError
93
+
94
+ try:
95
+ client.emails.send({...})
96
+ except SendingError as err:
97
+ print(err.status, err.code, err.body)
98
+ ```
99
+
100
+ ## Risorse disponibili
101
+
102
+ `emails` · `messages` · `events` · `campaigns` · `contacts` · `lists` · `tags` ·
103
+ `custom_fields` · `segments` · `domains` · `inboxes` · `email_rules` · `automations` ·
104
+ `webhooks` · `utm` · `integrations` · `usage`.
105
+
106
+ ## Sviluppo
107
+
108
+ ```bash
109
+ pip install -e ".[dev]"
110
+ python scripts/gen.py # rigenera sending/models.py da openapi.json
111
+ pytest
112
+ ```
113
+
114
+ Lo `openapi.json` viene copiato qui da `pnpm openapi:generate` (package `@sending/openapi`).