22
33[ ![ PyPI version] ( https://badge.fury.io/py/devo-global-comms-python.svg )] ( https://badge.fury.io/py/devo-global-comms-python )
44[ ![ Python Support] ( https://img.shields.io/pypi/pyversions/devo-global-comms-python.svg )] ( https://pypi.org/project/devo-global-comms-python/ )
5+ [ ![ Documentation] ( https://img.shields.io/badge/docs-github%20pages-blue )] ( https://devotel.github.io/devo-global-comms-python/ )
56[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
67
78A Python SDK for the Devo Global Communications API, supporting SMS, Email, WhatsApp, RCS, and Contact management.
@@ -14,7 +15,6 @@ A Python SDK for the Devo Global Communications API, supporting SMS, Email, What
1415- ** Sync-first design** : Simple, blocking API calls
1516- ** Type safety** : Full Pydantic model support with type hints
1617- ** Minimal dependencies** : Only requires ` requests ` and ` pydantic `
17- - ** Resource-based pattern** : Familiar API design
1818- ** Python 3.8+ support** : Compatible with modern Python versions
1919
2020## Installation
@@ -32,26 +32,28 @@ from devo_global_comms_python import DevoClient
3232client = DevoClient(api_key = " your-api-key" )
3333
3434# Send an SMS
35- sms = client.sms.send(
36- to = " +1234567890" ,
37- body = " Hello, World!"
35+ sms_response = client.sms.send_sms(
36+ recipient = " +1234567890" ,
37+ message = " Hello, World!" ,
38+ sender = " +1987654321"
3839)
39- print (f " SMS sent with SID : { sms.sid } " )
40+ print (f " SMS sent with ID : { sms_response.id } " )
4041
4142# Send an email
42- email = client.email.send (
43- to = " recipient@example.com" ,
43+ email_response = client.email.send_email (
44+ recipient = " recipient@example.com" ,
4445 subject = " Hello from Devo!" ,
45- body = " This is a test email from the Devo SDK."
46+ content = " This is a test email from the Devo SDK." ,
47+ sender_email = " sender@example.com"
4648)
47- print (f " Email sent with ID: { email .id} " )
49+ print (f " Email sent with ID: { email_response .id} " )
4850
4951# Send a WhatsApp message
50- whatsapp = client.whatsapp.send_text (
51- to = " +1234567890" ,
52- text = " Hello via WhatsApp!"
52+ whatsapp_response = client.whatsapp.send_text_message (
53+ recipient = " +1234567890" ,
54+ message = " Hello via WhatsApp!"
5355)
54- print (f " WhatsApp message sent with ID: { whatsapp .id} " )
56+ print (f " WhatsApp message sent with ID: { whatsapp_response .id} " )
5557```
5658
5759## Authentication
@@ -64,214 +66,15 @@ from devo_global_comms_python import DevoClient
6466client = DevoClient(api_key = " your-api-key" )
6567```
6668
67- ## Usage Examples
68-
69- ### SMS Messages
70-
71- ``` python
72- # Send a simple SMS
73- message = client.sms.send(
74- to = " +1234567890" ,
75- body = " Your verification code is: 123456"
76- )
77-
78- # Send SMS with custom sender and callback
79- message = client.sms.send(
80- to = " +1234567890" ,
81- body = " Hello from Devo!" ,
82- from_ = " +1987654321" ,
83- callback_url = " https://your-app.com/webhook" ,
84- metadata = {" campaign" : " welcome_series" }
85- )
86-
87- # Get message details
88- message = client.sms.get(" message_sid" )
89- print (f " Status: { message.status} " )
90-
91- # List recent messages
92- messages = client.sms.list(
93- date_sent_after = " 2024-01-01" ,
94- status = " delivered" ,
95- limit = 10
96- )
97- ```
98-
99- ### Email Messages
100-
101- ``` python
102- # Send a simple email
103- email = client.email.send(
104- to = " user@example.com" ,
105- subject = " Welcome to Devo!" ,
106- body = " Thank you for signing up for our service."
107- )
108-
109- # Send HTML email with CC and attachments
110- email = client.email.send(
111- to = " user@example.com" ,
112- subject = " Monthly Newsletter" ,
113- body = " Check out our latest updates!" ,
114- html_body = " <h1>Monthly Newsletter</h1><p>Check out our latest updates!</p>" ,
115- cc = [" manager@example.com" ],
116- reply_to = " noreply@example.com" ,
117- attachments = [
118- {
119- " filename" : " newsletter.pdf" ,
120- " content" : " base64-encoded-content" ,
121- " content_type" : " application/pdf"
122- }
123- ]
124- )
125-
126- # List emails by recipient
127- emails = client.email.list(
128- to = " user@example.com" ,
129- limit = 20
130- )
131- ```
132-
133- ### WhatsApp Messages
134-
135- ``` python
136- # Send a text message
137- message = client.whatsapp.send_text(
138- to = " +1234567890" ,
139- text = " Hello from WhatsApp!"
140- )
141-
142- # Send a template message
143- message = client.whatsapp.send_template(
144- to = " +1234567890" ,
145- template_name = " welcome_message" ,
146- language = " en" ,
147- parameters = [" John" , " Devo Platform" ]
148- )
149-
150- # Get message status
151- message = client.whatsapp.get(" message_id" )
152- print (f " Status: { message.status} " )
153- ```
154-
155- ### RCS Messages
156-
157- ``` python
158- # Send a text message
159- message = client.rcs.send_text(
160- to = " +1234567890" ,
161- text = " Hello from RCS!"
162- )
163-
164- # Send a rich card
165- message = client.rcs.send_rich_card(
166- to = " +1234567890" ,
167- title = " Special Offer" ,
168- description = " Get 50% o ff your next purchase!" ,
169- media_url = " https://example.com/image.jpg" ,
170- actions = [
171- {
172- " type" : " url" ,
173- " text" : " Shop Now" ,
174- " url" : " https://example.com/shop"
175- }
176- ]
177- )
178- ```
179-
180- ### Contact Management
181-
182- ``` python
183- # Create a contact
184- contact = client.contacts.create(
185- phone_number = " +1234567890" ,
186- email = " user@example.com" ,
187- first_name = " John" ,
188- last_name = " Doe" ,
189- company = " Acme Corp" ,
190- metadata = {" source" : " website_signup" }
191- )
192-
193- # Update a contact
194- updated_contact = client.contacts.update(
195- contact_id = contact.id,
196- company = " New Company Inc." ,
197- metadata = {" updated" : " 2024-01-15" }
198- )
199-
200- # Get contact details
201- contact = client.contacts.get(" contact_id" )
202-
203- # List contacts
204- contacts = client.contacts.list(
205- company = " Acme Corp" ,
206- limit = 50
207- )
208-
209- # Delete a contact
210- success = client.contacts.delete(" contact_id" )
211- ```
212-
213- ### Unified Message Management
214-
215- ``` python
216- # Get any message by ID
217- message = client.messages.get(" message_id" )
218- print (f " Channel: { message.channel} , Status: { message.status} " )
219-
220- # List messages across all channels
221- messages = client.messages.list(
222- channel = " sms" , # Filter by channel
223- status = " delivered" ,
224- date_sent_after = " 2024-01-01" ,
225- limit = 100
226- )
227-
228- # Get detailed delivery status
229- delivery_status = client.messages.get_delivery_status(" message_id" )
230-
231- # Resend a failed message
232- resent_message = client.messages.resend(" failed_message_id" )
233- ```
234-
235- ## Error Handling
236-
237- The SDK provides specific exception types for different error scenarios:
238-
239- ``` python
240- from devo_global_comms_python import (
241- DevoException,
242- DevoAPIException,
243- DevoAuthenticationException,
244- DevoValidationException,
245- DevoRateLimitException,
246- DevoTimeoutException,
247- )
248-
249- try :
250- message = client.sms.send(
251- to = " invalid-number" ,
252- body = " Test message"
253- )
254- except DevoValidationException as e:
255- print (f " Validation error: { e} " )
256- except DevoAuthenticationException as e:
257- print (f " Authentication failed: { e} " )
258- except DevoRateLimitException as e:
259- print (f " Rate limit exceeded. Retry after: { e.retry_after} " )
260- except DevoAPIException as e:
261- print (f " API error [ { e.status_code} ]: { e} " )
262- except DevoException as e:
263- print (f " General error: { e} " )
264- ```
265-
26669## Configuration
26770
26871### Client Configuration
26972
27073``` python
27174client = DevoClient(
27275 api_key = " your-api-key" ,
273- timeout = 30.0 ,
274- max_retries = 3 ,
76+ base_url = " https://api.devo.com " , # Optional: custom base URL
77+ timeout = 30.0 , # Optional: request timeout
27578)
27679```
27780
@@ -294,36 +97,21 @@ client = DevoClient(
29497
29598## Models
29699
297- All API responses are returned as Pydantic models with full type support:
100+ All API responses are returned as Pydantic models with full type support. The SDK includes models for:
101+
102+ - ** SMS** : ` SMSQuickSendResponse ` , ` SenderInfo ` , ` AvailableNumber `
103+ - ** Email** : ` EmailSendResponse ` , ` EmailTemplateResponse `
104+ - ** WhatsApp** : ` WhatsAppTextResponse ` , ` WhatsAppMediaResponse `
105+ - ** RCS** : ` RCSMessage ` , ` RcsSendMessageSerializer `
106+ - ** Contacts** : ` ContactSerializer ` , ` CreateContactDto ` , ` UpdateContactDto `
107+ - ** Contact Groups** : ` ContactsGroup ` , ` CreateContactsGroupDto `
298108
109+ Example usage:
299110``` python
300- # SMS Message model
301- class SMSMessage (BaseModel ):
302- sid: str
303- to: str
304- from_: Optional[str ]
305- body: str
306- status: str
307- date_created: Optional[datetime]
308- # ... other fields
309-
310- # Email Message model
311- class EmailMessage (BaseModel ):
312- id : str
313- to: str
314- subject: str
315- body: str
316- status: str
317- # ... other fields
318-
319- # Contact model
320- class Contact (BaseModel ):
321- id : str
322- phone_number: Optional[str ]
323- email: Optional[str ]
324- first_name: Optional[str ]
325- last_name: Optional[str ]
326- # ... other fields
111+ # All responses are typed Pydantic models
112+ sms_response = client.sms.send_sms(recipient = " +1234567890" , message = " Hello" , sender = " +1987654321" )
113+ print (f " Message ID: { sms_response.id} " ) # Type-safe access
114+ print (f " Status: { sms_response.status} " )
327115```
328116
329117## Development
@@ -384,7 +172,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
384172
385173## Support
386174
387- - ** Documentation** : [ https://devo-global-comms-python.readthedocs.io ] ( https://devo-global-comms-python.readthedocs.io )
175+ - ** Documentation** : [ https://devotel.github.io/ devo-global-comms-python/ ] ( https://devotel.github.io/ devo-global-comms-python/ )
388176- ** Issues** : [ GitHub Issues] ( https://github.com/devotel/devo-global-comms-python/issues )
389177- ** Email** : [ support@devotel.io ] ( mailto:support@devotel.io )
390178
0 commit comments