aiinbx 0.1.0__py3-none-any.whl

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.

Potentially problematic release.


This version of aiinbx might be problematic. Click here for more details.

@@ -0,0 +1,443 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import List, Union
6
+
7
+ import httpx
8
+
9
+ from ..types import email_send_params, email_reply_params
10
+ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11
+ from .._utils import maybe_transform, async_maybe_transform
12
+ from .._compat import cached_property
13
+ from .._resource import SyncAPIResource, AsyncAPIResource
14
+ from .._response import (
15
+ to_raw_response_wrapper,
16
+ to_streamed_response_wrapper,
17
+ async_to_raw_response_wrapper,
18
+ async_to_streamed_response_wrapper,
19
+ )
20
+ from .._base_client import make_request_options
21
+ from ..types.email_send_response import EmailSendResponse
22
+ from ..types.email_reply_response import EmailReplyResponse
23
+ from ..types.email_retrieve_response import EmailRetrieveResponse
24
+
25
+ __all__ = ["EmailsResource", "AsyncEmailsResource"]
26
+
27
+
28
+ class EmailsResource(SyncAPIResource):
29
+ @cached_property
30
+ def with_raw_response(self) -> EmailsResourceWithRawResponse:
31
+ """
32
+ This property can be used as a prefix for any HTTP method call to return
33
+ the raw response object instead of the parsed content.
34
+
35
+ For more information, see https://www.github.com/aiinbx/aiinbx-py#accessing-raw-response-data-eg-headers
36
+ """
37
+ return EmailsResourceWithRawResponse(self)
38
+
39
+ @cached_property
40
+ def with_streaming_response(self) -> EmailsResourceWithStreamingResponse:
41
+ """
42
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
43
+
44
+ For more information, see https://www.github.com/aiinbx/aiinbx-py#with_streaming_response
45
+ """
46
+ return EmailsResourceWithStreamingResponse(self)
47
+
48
+ def retrieve(
49
+ self,
50
+ email_id: str,
51
+ *,
52
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
53
+ # The extra values given here take precedence over values defined on the client or passed to this method.
54
+ extra_headers: Headers | None = None,
55
+ extra_query: Query | None = None,
56
+ extra_body: Body | None = None,
57
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
58
+ ) -> EmailRetrieveResponse:
59
+ """
60
+ Retrieve a specific email by its ID using API key authentication
61
+
62
+ Args:
63
+ extra_headers: Send extra headers
64
+
65
+ extra_query: Add additional query parameters to the request
66
+
67
+ extra_body: Add additional JSON properties to the request
68
+
69
+ timeout: Override the client-level default timeout for this request, in seconds
70
+ """
71
+ if not email_id:
72
+ raise ValueError(f"Expected a non-empty value for `email_id` but received {email_id!r}")
73
+ return self._get(
74
+ f"/emails/{email_id}",
75
+ options=make_request_options(
76
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
77
+ ),
78
+ cast_to=EmailRetrieveResponse,
79
+ )
80
+
81
+ def reply(
82
+ self,
83
+ email_id: str,
84
+ *,
85
+ from_: str,
86
+ html: str,
87
+ bcc: Union[str, List[str]] | NotGiven = NOT_GIVEN,
88
+ cc: Union[str, List[str]] | NotGiven = NOT_GIVEN,
89
+ from_name: str | NotGiven = NOT_GIVEN,
90
+ is_draft: bool | NotGiven = NOT_GIVEN,
91
+ reply_all: bool | NotGiven = NOT_GIVEN,
92
+ subject: str | NotGiven = NOT_GIVEN,
93
+ text: str | NotGiven = NOT_GIVEN,
94
+ to: Union[str, List[str]] | NotGiven = NOT_GIVEN,
95
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
96
+ # The extra values given here take precedence over values defined on the client or passed to this method.
97
+ extra_headers: Headers | None = None,
98
+ extra_query: Query | None = None,
99
+ extra_body: Body | None = None,
100
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
101
+ ) -> EmailReplyResponse:
102
+ """Reply to an existing email.
103
+
104
+ Automatically handles reply headers (In-Reply-To,
105
+ References) and thread association. The reply will be sent from a verified
106
+ domain belonging to the organization.
107
+
108
+ Args:
109
+ extra_headers: Send extra headers
110
+
111
+ extra_query: Add additional query parameters to the request
112
+
113
+ extra_body: Add additional JSON properties to the request
114
+
115
+ timeout: Override the client-level default timeout for this request, in seconds
116
+ """
117
+ if not email_id:
118
+ raise ValueError(f"Expected a non-empty value for `email_id` but received {email_id!r}")
119
+ return self._post(
120
+ f"/emails/{email_id}/reply",
121
+ body=maybe_transform(
122
+ {
123
+ "from_": from_,
124
+ "html": html,
125
+ "bcc": bcc,
126
+ "cc": cc,
127
+ "from_name": from_name,
128
+ "is_draft": is_draft,
129
+ "reply_all": reply_all,
130
+ "subject": subject,
131
+ "text": text,
132
+ "to": to,
133
+ },
134
+ email_reply_params.EmailReplyParams,
135
+ ),
136
+ options=make_request_options(
137
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
138
+ ),
139
+ cast_to=EmailReplyResponse,
140
+ )
141
+
142
+ def send(
143
+ self,
144
+ *,
145
+ from_: str,
146
+ html: str,
147
+ subject: str,
148
+ to: Union[str, List[str]],
149
+ bcc: Union[str, List[str]] | NotGiven = NOT_GIVEN,
150
+ cc: Union[str, List[str]] | NotGiven = NOT_GIVEN,
151
+ from_name: str | NotGiven = NOT_GIVEN,
152
+ in_reply_to: str | NotGiven = NOT_GIVEN,
153
+ is_draft: bool | NotGiven = NOT_GIVEN,
154
+ references: List[str] | NotGiven = NOT_GIVEN,
155
+ reply_to: Union[str, List[str]] | NotGiven = NOT_GIVEN,
156
+ text: str | NotGiven = NOT_GIVEN,
157
+ thread_id: str | NotGiven = NOT_GIVEN,
158
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
159
+ # The extra values given here take precedence over values defined on the client or passed to this method.
160
+ extra_headers: Headers | None = None,
161
+ extra_query: Query | None = None,
162
+ extra_body: Body | None = None,
163
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
164
+ ) -> EmailSendResponse:
165
+ """Send an email from a verified domain belonging to the organization.
166
+
167
+ Useful for
168
+ transactional or conversational messages. Returns metadata including identifiers
169
+ for further queries.
170
+
171
+ Args:
172
+ extra_headers: Send extra headers
173
+
174
+ extra_query: Add additional query parameters to the request
175
+
176
+ extra_body: Add additional JSON properties to the request
177
+
178
+ timeout: Override the client-level default timeout for this request, in seconds
179
+ """
180
+ return self._post(
181
+ "/emails/send",
182
+ body=maybe_transform(
183
+ {
184
+ "from_": from_,
185
+ "html": html,
186
+ "subject": subject,
187
+ "to": to,
188
+ "bcc": bcc,
189
+ "cc": cc,
190
+ "from_name": from_name,
191
+ "in_reply_to": in_reply_to,
192
+ "is_draft": is_draft,
193
+ "references": references,
194
+ "reply_to": reply_to,
195
+ "text": text,
196
+ "thread_id": thread_id,
197
+ },
198
+ email_send_params.EmailSendParams,
199
+ ),
200
+ options=make_request_options(
201
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
202
+ ),
203
+ cast_to=EmailSendResponse,
204
+ )
205
+
206
+
207
+ class AsyncEmailsResource(AsyncAPIResource):
208
+ @cached_property
209
+ def with_raw_response(self) -> AsyncEmailsResourceWithRawResponse:
210
+ """
211
+ This property can be used as a prefix for any HTTP method call to return
212
+ the raw response object instead of the parsed content.
213
+
214
+ For more information, see https://www.github.com/aiinbx/aiinbx-py#accessing-raw-response-data-eg-headers
215
+ """
216
+ return AsyncEmailsResourceWithRawResponse(self)
217
+
218
+ @cached_property
219
+ def with_streaming_response(self) -> AsyncEmailsResourceWithStreamingResponse:
220
+ """
221
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
222
+
223
+ For more information, see https://www.github.com/aiinbx/aiinbx-py#with_streaming_response
224
+ """
225
+ return AsyncEmailsResourceWithStreamingResponse(self)
226
+
227
+ async def retrieve(
228
+ self,
229
+ email_id: str,
230
+ *,
231
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
232
+ # The extra values given here take precedence over values defined on the client or passed to this method.
233
+ extra_headers: Headers | None = None,
234
+ extra_query: Query | None = None,
235
+ extra_body: Body | None = None,
236
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
237
+ ) -> EmailRetrieveResponse:
238
+ """
239
+ Retrieve a specific email by its ID using API key authentication
240
+
241
+ Args:
242
+ extra_headers: Send extra headers
243
+
244
+ extra_query: Add additional query parameters to the request
245
+
246
+ extra_body: Add additional JSON properties to the request
247
+
248
+ timeout: Override the client-level default timeout for this request, in seconds
249
+ """
250
+ if not email_id:
251
+ raise ValueError(f"Expected a non-empty value for `email_id` but received {email_id!r}")
252
+ return await self._get(
253
+ f"/emails/{email_id}",
254
+ options=make_request_options(
255
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
256
+ ),
257
+ cast_to=EmailRetrieveResponse,
258
+ )
259
+
260
+ async def reply(
261
+ self,
262
+ email_id: str,
263
+ *,
264
+ from_: str,
265
+ html: str,
266
+ bcc: Union[str, List[str]] | NotGiven = NOT_GIVEN,
267
+ cc: Union[str, List[str]] | NotGiven = NOT_GIVEN,
268
+ from_name: str | NotGiven = NOT_GIVEN,
269
+ is_draft: bool | NotGiven = NOT_GIVEN,
270
+ reply_all: bool | NotGiven = NOT_GIVEN,
271
+ subject: str | NotGiven = NOT_GIVEN,
272
+ text: str | NotGiven = NOT_GIVEN,
273
+ to: Union[str, List[str]] | NotGiven = NOT_GIVEN,
274
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
275
+ # The extra values given here take precedence over values defined on the client or passed to this method.
276
+ extra_headers: Headers | None = None,
277
+ extra_query: Query | None = None,
278
+ extra_body: Body | None = None,
279
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
280
+ ) -> EmailReplyResponse:
281
+ """Reply to an existing email.
282
+
283
+ Automatically handles reply headers (In-Reply-To,
284
+ References) and thread association. The reply will be sent from a verified
285
+ domain belonging to the organization.
286
+
287
+ Args:
288
+ extra_headers: Send extra headers
289
+
290
+ extra_query: Add additional query parameters to the request
291
+
292
+ extra_body: Add additional JSON properties to the request
293
+
294
+ timeout: Override the client-level default timeout for this request, in seconds
295
+ """
296
+ if not email_id:
297
+ raise ValueError(f"Expected a non-empty value for `email_id` but received {email_id!r}")
298
+ return await self._post(
299
+ f"/emails/{email_id}/reply",
300
+ body=await async_maybe_transform(
301
+ {
302
+ "from_": from_,
303
+ "html": html,
304
+ "bcc": bcc,
305
+ "cc": cc,
306
+ "from_name": from_name,
307
+ "is_draft": is_draft,
308
+ "reply_all": reply_all,
309
+ "subject": subject,
310
+ "text": text,
311
+ "to": to,
312
+ },
313
+ email_reply_params.EmailReplyParams,
314
+ ),
315
+ options=make_request_options(
316
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
317
+ ),
318
+ cast_to=EmailReplyResponse,
319
+ )
320
+
321
+ async def send(
322
+ self,
323
+ *,
324
+ from_: str,
325
+ html: str,
326
+ subject: str,
327
+ to: Union[str, List[str]],
328
+ bcc: Union[str, List[str]] | NotGiven = NOT_GIVEN,
329
+ cc: Union[str, List[str]] | NotGiven = NOT_GIVEN,
330
+ from_name: str | NotGiven = NOT_GIVEN,
331
+ in_reply_to: str | NotGiven = NOT_GIVEN,
332
+ is_draft: bool | NotGiven = NOT_GIVEN,
333
+ references: List[str] | NotGiven = NOT_GIVEN,
334
+ reply_to: Union[str, List[str]] | NotGiven = NOT_GIVEN,
335
+ text: str | NotGiven = NOT_GIVEN,
336
+ thread_id: str | NotGiven = NOT_GIVEN,
337
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
338
+ # The extra values given here take precedence over values defined on the client or passed to this method.
339
+ extra_headers: Headers | None = None,
340
+ extra_query: Query | None = None,
341
+ extra_body: Body | None = None,
342
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
343
+ ) -> EmailSendResponse:
344
+ """Send an email from a verified domain belonging to the organization.
345
+
346
+ Useful for
347
+ transactional or conversational messages. Returns metadata including identifiers
348
+ for further queries.
349
+
350
+ Args:
351
+ extra_headers: Send extra headers
352
+
353
+ extra_query: Add additional query parameters to the request
354
+
355
+ extra_body: Add additional JSON properties to the request
356
+
357
+ timeout: Override the client-level default timeout for this request, in seconds
358
+ """
359
+ return await self._post(
360
+ "/emails/send",
361
+ body=await async_maybe_transform(
362
+ {
363
+ "from_": from_,
364
+ "html": html,
365
+ "subject": subject,
366
+ "to": to,
367
+ "bcc": bcc,
368
+ "cc": cc,
369
+ "from_name": from_name,
370
+ "in_reply_to": in_reply_to,
371
+ "is_draft": is_draft,
372
+ "references": references,
373
+ "reply_to": reply_to,
374
+ "text": text,
375
+ "thread_id": thread_id,
376
+ },
377
+ email_send_params.EmailSendParams,
378
+ ),
379
+ options=make_request_options(
380
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
381
+ ),
382
+ cast_to=EmailSendResponse,
383
+ )
384
+
385
+
386
+ class EmailsResourceWithRawResponse:
387
+ def __init__(self, emails: EmailsResource) -> None:
388
+ self._emails = emails
389
+
390
+ self.retrieve = to_raw_response_wrapper(
391
+ emails.retrieve,
392
+ )
393
+ self.reply = to_raw_response_wrapper(
394
+ emails.reply,
395
+ )
396
+ self.send = to_raw_response_wrapper(
397
+ emails.send,
398
+ )
399
+
400
+
401
+ class AsyncEmailsResourceWithRawResponse:
402
+ def __init__(self, emails: AsyncEmailsResource) -> None:
403
+ self._emails = emails
404
+
405
+ self.retrieve = async_to_raw_response_wrapper(
406
+ emails.retrieve,
407
+ )
408
+ self.reply = async_to_raw_response_wrapper(
409
+ emails.reply,
410
+ )
411
+ self.send = async_to_raw_response_wrapper(
412
+ emails.send,
413
+ )
414
+
415
+
416
+ class EmailsResourceWithStreamingResponse:
417
+ def __init__(self, emails: EmailsResource) -> None:
418
+ self._emails = emails
419
+
420
+ self.retrieve = to_streamed_response_wrapper(
421
+ emails.retrieve,
422
+ )
423
+ self.reply = to_streamed_response_wrapper(
424
+ emails.reply,
425
+ )
426
+ self.send = to_streamed_response_wrapper(
427
+ emails.send,
428
+ )
429
+
430
+
431
+ class AsyncEmailsResourceWithStreamingResponse:
432
+ def __init__(self, emails: AsyncEmailsResource) -> None:
433
+ self._emails = emails
434
+
435
+ self.retrieve = async_to_streamed_response_wrapper(
436
+ emails.retrieve,
437
+ )
438
+ self.reply = async_to_streamed_response_wrapper(
439
+ emails.reply,
440
+ )
441
+ self.send = async_to_streamed_response_wrapper(
442
+ emails.send,
443
+ )