definite-sdk 0.1.18__tar.gz → 0.1.19__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: definite-sdk
3
- Version: 0.1.18
3
+ Version: 0.1.19
4
4
  Summary: Definite SDK for Python
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -107,6 +107,14 @@ class DefiniteMessageClient:
107
107
  thread_ts=thread_ts,
108
108
  **kwargs,
109
109
  )
110
+ elif channel_lower == "email":
111
+ to_emails = [e.strip() for e in to.split(",") if e.strip()]
112
+ return self._send_email_message(
113
+ to_emails=to_emails,
114
+ subject=subject or "",
115
+ body=content,
116
+ **kwargs,
117
+ )
110
118
  else:
111
119
  raise ValueError(f"Unsupported channel: {channel}")
112
120
 
@@ -197,3 +205,76 @@ class DefiniteMessageClient:
197
205
  thread_ts=thread_ts,
198
206
  **kwargs,
199
207
  )
208
+
209
+ def _send_email_message(
210
+ self,
211
+ to_emails: List[str],
212
+ subject: str,
213
+ body: str,
214
+ **kwargs: Any,
215
+ ) -> Dict[str, Any]:
216
+ """
217
+ Internal method to send an email message via SendGrid.
218
+
219
+ Args:
220
+ to_emails (List[str]): List of recipient email addresses.
221
+ subject (str): The email subject line.
222
+ body (str): The email body (HTML supported).
223
+ **kwargs: Additional email-specific parameters.
224
+
225
+ Returns:
226
+ Dict[str, Any]: The API response.
227
+ """
228
+ url = f"{self._message_url}/email/message"
229
+
230
+ payload: Dict[str, Any] = {
231
+ "toEmails": to_emails,
232
+ "subject": subject,
233
+ "body": body,
234
+ }
235
+
236
+ payload.update(kwargs)
237
+
238
+ response = requests.post(
239
+ url,
240
+ json=payload,
241
+ headers={"Authorization": "Bearer " + self._api_key},
242
+ )
243
+ response.raise_for_status()
244
+ return response.json()
245
+
246
+ def send_email_message(
247
+ self,
248
+ to_emails: List[str],
249
+ subject: str,
250
+ body: str,
251
+ **kwargs: Any,
252
+ ) -> Dict[str, Any]:
253
+ """
254
+ Convenience method to send an email directly via SendGrid.
255
+
256
+ Args:
257
+ to_emails (List[str]): List of recipient email addresses.
258
+ subject (str): The email subject line.
259
+ body (str): The email body (HTML supported).
260
+ **kwargs: Additional email-specific parameters.
261
+
262
+ Returns:
263
+ Dict[str, Any]: The API response.
264
+
265
+ Example:
266
+ >>> result = message_client.send_email_message(
267
+ ... to_emails=["user@example.com"],
268
+ ... subject="Daily Report",
269
+ ... body="<h1>Report</h1><p>All systems operational.</p>"
270
+ ... )
271
+ >>> print(f"Email sent: {result['ok']}")
272
+ """
273
+ return self.send_message(
274
+ channel="email",
275
+ integration_id="",
276
+ to=",".join(to_emails),
277
+ content=body,
278
+ subject=subject,
279
+ **kwargs,
280
+ )
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "definite-sdk"
3
- version = "0.1.18"
3
+ version = "0.1.19"
4
4
  description = "Definite SDK for Python"
5
5
  authors = ["Definite <hello@definite.app>"]
6
6
  license = "MIT"
File without changes
File without changes