linq-python 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.
- linq/__init__.py +102 -0
- linq/_base_client.py +2149 -0
- linq/_client.py +2479 -0
- linq/_compat.py +226 -0
- linq/_constants.py +14 -0
- linq/_exceptions.py +108 -0
- linq/_files.py +123 -0
- linq/_models.py +878 -0
- linq/_qs.py +153 -0
- linq/_resource.py +43 -0
- linq/_response.py +833 -0
- linq/_streaming.py +338 -0
- linq/_types.py +271 -0
- linq/_utils/__init__.py +65 -0
- linq/_utils/_compat.py +45 -0
- linq/_utils/_datetime_parse.py +136 -0
- linq/_utils/_json.py +35 -0
- linq/_utils/_logs.py +25 -0
- linq/_utils/_path.py +127 -0
- linq/_utils/_proxy.py +65 -0
- linq/_utils/_reflection.py +42 -0
- linq/_utils/_resources_proxy.py +24 -0
- linq/_utils/_streams.py +12 -0
- linq/_utils/_sync.py +58 -0
- linq/_utils/_transform.py +457 -0
- linq/_utils/_typing.py +156 -0
- linq/_utils/_utils.py +421 -0
- linq/_version.py +4 -0
- linq/lib/.keep +4 -0
- linq/pagination.py +95 -0
- linq/py.typed +0 -0
- linq/resources/__init__.py +134 -0
- linq/resources/attachments.py +589 -0
- linq/resources/capability.py +297 -0
- linq/resources/chats/__init__.py +61 -0
- linq/resources/chats/chats.py +1492 -0
- linq/resources/chats/messages.py +416 -0
- linq/resources/chats/participants.py +322 -0
- linq/resources/chats/typing.py +299 -0
- linq/resources/contact_card.py +472 -0
- linq/resources/messages.py +686 -0
- linq/resources/phone_numbers.py +163 -0
- linq/resources/phonenumbers.py +165 -0
- linq/resources/webhook_events.py +319 -0
- linq/resources/webhook_subscriptions.py +776 -0
- linq/resources/webhooks.py +34 -0
- linq/types/__init__.py +90 -0
- linq/types/attachment_create_params.py +42 -0
- linq/types/attachment_create_response.py +44 -0
- linq/types/attachment_retrieve_response.py +55 -0
- linq/types/capability_check_RCS_params.py +20 -0
- linq/types/capability_check_i_message_params.py +20 -0
- linq/types/chat.py +44 -0
- linq/types/chat_create_params.py +33 -0
- linq/types/chat_create_response.py +44 -0
- linq/types/chat_created_webhook_event.py +87 -0
- linq/types/chat_group_icon_update_failed_webhook_event.py +65 -0
- linq/types/chat_group_icon_updated_webhook_event.py +66 -0
- linq/types/chat_group_name_update_failed_webhook_event.py +65 -0
- linq/types/chat_group_name_updated_webhook_event.py +66 -0
- linq/types/chat_leave_chat_response.py +15 -0
- linq/types/chat_list_chats_params.py +36 -0
- linq/types/chat_send_voicememo_params.py +23 -0
- linq/types/chat_send_voicememo_response.py +79 -0
- linq/types/chat_typing_indicator_started_webhook_event.py +52 -0
- linq/types/chat_typing_indicator_stopped_webhook_event.py +52 -0
- linq/types/chat_update_params.py +15 -0
- linq/types/chat_update_response.py +13 -0
- linq/types/chats/__init__.py +12 -0
- linq/types/chats/message_list_params.py +15 -0
- linq/types/chats/message_send_params.py +18 -0
- linq/types/chats/message_send_response.py +16 -0
- linq/types/chats/participant_add_params.py +12 -0
- linq/types/chats/participant_add_response.py +15 -0
- linq/types/chats/participant_remove_params.py +12 -0
- linq/types/chats/participant_remove_response.py +15 -0
- linq/types/chats/sent_message.py +69 -0
- linq/types/contact_card_create_params.py +24 -0
- linq/types/contact_card_retrieve_params.py +15 -0
- linq/types/contact_card_retrieve_response.py +23 -0
- linq/types/contact_card_update_params.py +21 -0
- linq/types/events_webhook_event.py +50 -0
- linq/types/handle_check_response.py +13 -0
- linq/types/link_part_param.py +22 -0
- linq/types/media_part_param.py +54 -0
- linq/types/message.py +87 -0
- linq/types/message_add_reaction_params.py +32 -0
- linq/types/message_add_reaction_response.py +15 -0
- linq/types/message_content_param.py +82 -0
- linq/types/message_delivered_webhook_event.py +65 -0
- linq/types/message_edited_webhook_event.py +100 -0
- linq/types/message_effect.py +23 -0
- linq/types/message_effect_param.py +22 -0
- linq/types/message_event_v2.py +116 -0
- linq/types/message_failed_webhook_event.py +72 -0
- linq/types/message_list_messages_thread_params.py +18 -0
- linq/types/message_read_webhook_event.py +65 -0
- linq/types/message_received_webhook_event.py +65 -0
- linq/types/message_sent_webhook_event.py +65 -0
- linq/types/message_update_params.py +15 -0
- linq/types/participant_added_webhook_event.py +66 -0
- linq/types/participant_removed_webhook_event.py +66 -0
- linq/types/phone_number_list_response.py +20 -0
- linq/types/phone_number_status_updated_webhook_event.py +82 -0
- linq/types/phonenumber_list_response.py +39 -0
- linq/types/reaction_added_webhook_event.py +46 -0
- linq/types/reaction_event_base.py +85 -0
- linq/types/reaction_removed_webhook_event.py +46 -0
- linq/types/reply_to.py +21 -0
- linq/types/reply_to_param.py +21 -0
- linq/types/schemas_media_part_response.py +29 -0
- linq/types/schemas_message_effect.py +18 -0
- linq/types/schemas_text_part_response.py +22 -0
- linq/types/set_contact_card.py +24 -0
- linq/types/shared/__init__.py +9 -0
- linq/types/shared/chat_handle.py +33 -0
- linq/types/shared/media_part_response.py +34 -0
- linq/types/shared/reaction.py +56 -0
- linq/types/shared/reaction_type.py +7 -0
- linq/types/shared/service_type.py +7 -0
- linq/types/shared/text_decoration.py +23 -0
- linq/types/shared/text_part_response.py +26 -0
- linq/types/shared_params/__init__.py +5 -0
- linq/types/shared_params/reaction_type.py +9 -0
- linq/types/shared_params/service_type.py +9 -0
- linq/types/shared_params/text_decoration.py +23 -0
- linq/types/supported_content_type.py +60 -0
- linq/types/text_part_param.py +44 -0
- linq/types/webhook_event_list_response.py +17 -0
- linq/types/webhook_event_type.py +33 -0
- linq/types/webhook_subscription.py +35 -0
- linq/types/webhook_subscription_create_params.py +27 -0
- linq/types/webhook_subscription_create_response.py +46 -0
- linq/types/webhook_subscription_list_response.py +13 -0
- linq/types/webhook_subscription_update_params.py +30 -0
- linq_python-0.1.0.dist-info/METADATA +572 -0
- linq_python-0.1.0.dist-info/RECORD +139 -0
- linq_python-0.1.0.dist-info/WHEEL +4 -0
- linq_python-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ..._types import Body, Query, Headers, NotGiven, not_given
|
|
8
|
+
from ..._utils import path_template, maybe_transform, async_maybe_transform
|
|
9
|
+
from ..._compat import cached_property
|
|
10
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
11
|
+
from ..._response import (
|
|
12
|
+
to_raw_response_wrapper,
|
|
13
|
+
to_streamed_response_wrapper,
|
|
14
|
+
async_to_raw_response_wrapper,
|
|
15
|
+
async_to_streamed_response_wrapper,
|
|
16
|
+
)
|
|
17
|
+
from ...types.chats import participant_add_params, participant_remove_params
|
|
18
|
+
from ..._base_client import make_request_options
|
|
19
|
+
from ...types.chats.participant_add_response import ParticipantAddResponse
|
|
20
|
+
from ...types.chats.participant_remove_response import ParticipantRemoveResponse
|
|
21
|
+
|
|
22
|
+
__all__ = ["ParticipantsResource", "AsyncParticipantsResource"]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ParticipantsResource(SyncAPIResource):
|
|
26
|
+
"""A Chat is a conversation thread with one or more participants.
|
|
27
|
+
|
|
28
|
+
To begin a chat, you must create a Chat with at least one recipient handle.
|
|
29
|
+
Including multiple handles creates a group chat.
|
|
30
|
+
|
|
31
|
+
When creating a chat, the `from` field specifies which of your
|
|
32
|
+
authorized phone numbers the message originates from. Your authentication token grants
|
|
33
|
+
access to one or more phone numbers, but the `from` field determines the actual sender.
|
|
34
|
+
|
|
35
|
+
**Handle Format:**
|
|
36
|
+
- Handles can be phone numbers or email addresses
|
|
37
|
+
- Phone numbers MUST be in E.164 format (starting with +)
|
|
38
|
+
- Phone format: `+[country code][subscriber number]`
|
|
39
|
+
- Example phone: `+12223334444` (US), `+442071234567` (UK), `+81312345678` (Japan)
|
|
40
|
+
- Example email: `user@example.com`
|
|
41
|
+
- No spaces, dashes, or parentheses in phone numbers
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
@cached_property
|
|
45
|
+
def with_raw_response(self) -> ParticipantsResourceWithRawResponse:
|
|
46
|
+
"""
|
|
47
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
48
|
+
the raw response object instead of the parsed content.
|
|
49
|
+
|
|
50
|
+
For more information, see https://www.github.com/linq-team/linq-python#accessing-raw-response-data-eg-headers
|
|
51
|
+
"""
|
|
52
|
+
return ParticipantsResourceWithRawResponse(self)
|
|
53
|
+
|
|
54
|
+
@cached_property
|
|
55
|
+
def with_streaming_response(self) -> ParticipantsResourceWithStreamingResponse:
|
|
56
|
+
"""
|
|
57
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
58
|
+
|
|
59
|
+
For more information, see https://www.github.com/linq-team/linq-python#with_streaming_response
|
|
60
|
+
"""
|
|
61
|
+
return ParticipantsResourceWithStreamingResponse(self)
|
|
62
|
+
|
|
63
|
+
def add(
|
|
64
|
+
self,
|
|
65
|
+
chat_id: str,
|
|
66
|
+
*,
|
|
67
|
+
handle: str,
|
|
68
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
69
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
70
|
+
extra_headers: Headers | None = None,
|
|
71
|
+
extra_query: Query | None = None,
|
|
72
|
+
extra_body: Body | None = None,
|
|
73
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
74
|
+
) -> ParticipantAddResponse:
|
|
75
|
+
"""
|
|
76
|
+
Add a new participant to an existing group chat.
|
|
77
|
+
|
|
78
|
+
**Requirements:**
|
|
79
|
+
|
|
80
|
+
- Group chats only (3+ existing participants)
|
|
81
|
+
- New participant must support the same messaging service as the group
|
|
82
|
+
- Cross-service additions not allowed (e.g., can't add RCS-only user to iMessage
|
|
83
|
+
group)
|
|
84
|
+
- For cross-service scenarios, create a new chat instead
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
handle: Phone number (E.164 format) or email address of the participant to add
|
|
88
|
+
|
|
89
|
+
extra_headers: Send extra headers
|
|
90
|
+
|
|
91
|
+
extra_query: Add additional query parameters to the request
|
|
92
|
+
|
|
93
|
+
extra_body: Add additional JSON properties to the request
|
|
94
|
+
|
|
95
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
96
|
+
"""
|
|
97
|
+
if not chat_id:
|
|
98
|
+
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
|
|
99
|
+
return self._post(
|
|
100
|
+
path_template("/v3/chats/{chat_id}/participants", chat_id=chat_id),
|
|
101
|
+
body=maybe_transform({"handle": handle}, participant_add_params.ParticipantAddParams),
|
|
102
|
+
options=make_request_options(
|
|
103
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
104
|
+
),
|
|
105
|
+
cast_to=ParticipantAddResponse,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
def remove(
|
|
109
|
+
self,
|
|
110
|
+
chat_id: str,
|
|
111
|
+
*,
|
|
112
|
+
handle: str,
|
|
113
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
114
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
115
|
+
extra_headers: Headers | None = None,
|
|
116
|
+
extra_query: Query | None = None,
|
|
117
|
+
extra_body: Body | None = None,
|
|
118
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
119
|
+
) -> ParticipantRemoveResponse:
|
|
120
|
+
"""
|
|
121
|
+
Remove a participant from an existing group chat.
|
|
122
|
+
|
|
123
|
+
**Requirements:**
|
|
124
|
+
|
|
125
|
+
- Group chats only
|
|
126
|
+
- Must have 3+ participants after removal
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
handle: Phone number (E.164 format) or email address of the participant to remove
|
|
130
|
+
|
|
131
|
+
extra_headers: Send extra headers
|
|
132
|
+
|
|
133
|
+
extra_query: Add additional query parameters to the request
|
|
134
|
+
|
|
135
|
+
extra_body: Add additional JSON properties to the request
|
|
136
|
+
|
|
137
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
138
|
+
"""
|
|
139
|
+
if not chat_id:
|
|
140
|
+
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
|
|
141
|
+
return self._delete(
|
|
142
|
+
path_template("/v3/chats/{chat_id}/participants", chat_id=chat_id),
|
|
143
|
+
body=maybe_transform({"handle": handle}, participant_remove_params.ParticipantRemoveParams),
|
|
144
|
+
options=make_request_options(
|
|
145
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
146
|
+
),
|
|
147
|
+
cast_to=ParticipantRemoveResponse,
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class AsyncParticipantsResource(AsyncAPIResource):
|
|
152
|
+
"""A Chat is a conversation thread with one or more participants.
|
|
153
|
+
|
|
154
|
+
To begin a chat, you must create a Chat with at least one recipient handle.
|
|
155
|
+
Including multiple handles creates a group chat.
|
|
156
|
+
|
|
157
|
+
When creating a chat, the `from` field specifies which of your
|
|
158
|
+
authorized phone numbers the message originates from. Your authentication token grants
|
|
159
|
+
access to one or more phone numbers, but the `from` field determines the actual sender.
|
|
160
|
+
|
|
161
|
+
**Handle Format:**
|
|
162
|
+
- Handles can be phone numbers or email addresses
|
|
163
|
+
- Phone numbers MUST be in E.164 format (starting with +)
|
|
164
|
+
- Phone format: `+[country code][subscriber number]`
|
|
165
|
+
- Example phone: `+12223334444` (US), `+442071234567` (UK), `+81312345678` (Japan)
|
|
166
|
+
- Example email: `user@example.com`
|
|
167
|
+
- No spaces, dashes, or parentheses in phone numbers
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
@cached_property
|
|
171
|
+
def with_raw_response(self) -> AsyncParticipantsResourceWithRawResponse:
|
|
172
|
+
"""
|
|
173
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
174
|
+
the raw response object instead of the parsed content.
|
|
175
|
+
|
|
176
|
+
For more information, see https://www.github.com/linq-team/linq-python#accessing-raw-response-data-eg-headers
|
|
177
|
+
"""
|
|
178
|
+
return AsyncParticipantsResourceWithRawResponse(self)
|
|
179
|
+
|
|
180
|
+
@cached_property
|
|
181
|
+
def with_streaming_response(self) -> AsyncParticipantsResourceWithStreamingResponse:
|
|
182
|
+
"""
|
|
183
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
184
|
+
|
|
185
|
+
For more information, see https://www.github.com/linq-team/linq-python#with_streaming_response
|
|
186
|
+
"""
|
|
187
|
+
return AsyncParticipantsResourceWithStreamingResponse(self)
|
|
188
|
+
|
|
189
|
+
async def add(
|
|
190
|
+
self,
|
|
191
|
+
chat_id: str,
|
|
192
|
+
*,
|
|
193
|
+
handle: str,
|
|
194
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
195
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
196
|
+
extra_headers: Headers | None = None,
|
|
197
|
+
extra_query: Query | None = None,
|
|
198
|
+
extra_body: Body | None = None,
|
|
199
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
200
|
+
) -> ParticipantAddResponse:
|
|
201
|
+
"""
|
|
202
|
+
Add a new participant to an existing group chat.
|
|
203
|
+
|
|
204
|
+
**Requirements:**
|
|
205
|
+
|
|
206
|
+
- Group chats only (3+ existing participants)
|
|
207
|
+
- New participant must support the same messaging service as the group
|
|
208
|
+
- Cross-service additions not allowed (e.g., can't add RCS-only user to iMessage
|
|
209
|
+
group)
|
|
210
|
+
- For cross-service scenarios, create a new chat instead
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
handle: Phone number (E.164 format) or email address of the participant to add
|
|
214
|
+
|
|
215
|
+
extra_headers: Send extra headers
|
|
216
|
+
|
|
217
|
+
extra_query: Add additional query parameters to the request
|
|
218
|
+
|
|
219
|
+
extra_body: Add additional JSON properties to the request
|
|
220
|
+
|
|
221
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
222
|
+
"""
|
|
223
|
+
if not chat_id:
|
|
224
|
+
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
|
|
225
|
+
return await self._post(
|
|
226
|
+
path_template("/v3/chats/{chat_id}/participants", chat_id=chat_id),
|
|
227
|
+
body=await async_maybe_transform({"handle": handle}, participant_add_params.ParticipantAddParams),
|
|
228
|
+
options=make_request_options(
|
|
229
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
230
|
+
),
|
|
231
|
+
cast_to=ParticipantAddResponse,
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
async def remove(
|
|
235
|
+
self,
|
|
236
|
+
chat_id: str,
|
|
237
|
+
*,
|
|
238
|
+
handle: str,
|
|
239
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
240
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
241
|
+
extra_headers: Headers | None = None,
|
|
242
|
+
extra_query: Query | None = None,
|
|
243
|
+
extra_body: Body | None = None,
|
|
244
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
245
|
+
) -> ParticipantRemoveResponse:
|
|
246
|
+
"""
|
|
247
|
+
Remove a participant from an existing group chat.
|
|
248
|
+
|
|
249
|
+
**Requirements:**
|
|
250
|
+
|
|
251
|
+
- Group chats only
|
|
252
|
+
- Must have 3+ participants after removal
|
|
253
|
+
|
|
254
|
+
Args:
|
|
255
|
+
handle: Phone number (E.164 format) or email address of the participant to remove
|
|
256
|
+
|
|
257
|
+
extra_headers: Send extra headers
|
|
258
|
+
|
|
259
|
+
extra_query: Add additional query parameters to the request
|
|
260
|
+
|
|
261
|
+
extra_body: Add additional JSON properties to the request
|
|
262
|
+
|
|
263
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
264
|
+
"""
|
|
265
|
+
if not chat_id:
|
|
266
|
+
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
|
|
267
|
+
return await self._delete(
|
|
268
|
+
path_template("/v3/chats/{chat_id}/participants", chat_id=chat_id),
|
|
269
|
+
body=await async_maybe_transform({"handle": handle}, participant_remove_params.ParticipantRemoveParams),
|
|
270
|
+
options=make_request_options(
|
|
271
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
272
|
+
),
|
|
273
|
+
cast_to=ParticipantRemoveResponse,
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
class ParticipantsResourceWithRawResponse:
|
|
278
|
+
def __init__(self, participants: ParticipantsResource) -> None:
|
|
279
|
+
self._participants = participants
|
|
280
|
+
|
|
281
|
+
self.add = to_raw_response_wrapper(
|
|
282
|
+
participants.add,
|
|
283
|
+
)
|
|
284
|
+
self.remove = to_raw_response_wrapper(
|
|
285
|
+
participants.remove,
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
class AsyncParticipantsResourceWithRawResponse:
|
|
290
|
+
def __init__(self, participants: AsyncParticipantsResource) -> None:
|
|
291
|
+
self._participants = participants
|
|
292
|
+
|
|
293
|
+
self.add = async_to_raw_response_wrapper(
|
|
294
|
+
participants.add,
|
|
295
|
+
)
|
|
296
|
+
self.remove = async_to_raw_response_wrapper(
|
|
297
|
+
participants.remove,
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
class ParticipantsResourceWithStreamingResponse:
|
|
302
|
+
def __init__(self, participants: ParticipantsResource) -> None:
|
|
303
|
+
self._participants = participants
|
|
304
|
+
|
|
305
|
+
self.add = to_streamed_response_wrapper(
|
|
306
|
+
participants.add,
|
|
307
|
+
)
|
|
308
|
+
self.remove = to_streamed_response_wrapper(
|
|
309
|
+
participants.remove,
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
class AsyncParticipantsResourceWithStreamingResponse:
|
|
314
|
+
def __init__(self, participants: AsyncParticipantsResource) -> None:
|
|
315
|
+
self._participants = participants
|
|
316
|
+
|
|
317
|
+
self.add = async_to_streamed_response_wrapper(
|
|
318
|
+
participants.add,
|
|
319
|
+
)
|
|
320
|
+
self.remove = async_to_streamed_response_wrapper(
|
|
321
|
+
participants.remove,
|
|
322
|
+
)
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ..._types import Body, Query, Headers, NoneType, NotGiven, not_given
|
|
8
|
+
from ..._utils import path_template
|
|
9
|
+
from ..._compat import cached_property
|
|
10
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
11
|
+
from ..._response import (
|
|
12
|
+
to_raw_response_wrapper,
|
|
13
|
+
to_streamed_response_wrapper,
|
|
14
|
+
async_to_raw_response_wrapper,
|
|
15
|
+
async_to_streamed_response_wrapper,
|
|
16
|
+
)
|
|
17
|
+
from ..._base_client import make_request_options
|
|
18
|
+
|
|
19
|
+
__all__ = ["TypingResource", "AsyncTypingResource"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TypingResource(SyncAPIResource):
|
|
23
|
+
"""A Chat is a conversation thread with one or more participants.
|
|
24
|
+
|
|
25
|
+
To begin a chat, you must create a Chat with at least one recipient handle.
|
|
26
|
+
Including multiple handles creates a group chat.
|
|
27
|
+
|
|
28
|
+
When creating a chat, the `from` field specifies which of your
|
|
29
|
+
authorized phone numbers the message originates from. Your authentication token grants
|
|
30
|
+
access to one or more phone numbers, but the `from` field determines the actual sender.
|
|
31
|
+
|
|
32
|
+
**Handle Format:**
|
|
33
|
+
- Handles can be phone numbers or email addresses
|
|
34
|
+
- Phone numbers MUST be in E.164 format (starting with +)
|
|
35
|
+
- Phone format: `+[country code][subscriber number]`
|
|
36
|
+
- Example phone: `+12223334444` (US), `+442071234567` (UK), `+81312345678` (Japan)
|
|
37
|
+
- Example email: `user@example.com`
|
|
38
|
+
- No spaces, dashes, or parentheses in phone numbers
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
@cached_property
|
|
42
|
+
def with_raw_response(self) -> TypingResourceWithRawResponse:
|
|
43
|
+
"""
|
|
44
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
45
|
+
the raw response object instead of the parsed content.
|
|
46
|
+
|
|
47
|
+
For more information, see https://www.github.com/linq-team/linq-python#accessing-raw-response-data-eg-headers
|
|
48
|
+
"""
|
|
49
|
+
return TypingResourceWithRawResponse(self)
|
|
50
|
+
|
|
51
|
+
@cached_property
|
|
52
|
+
def with_streaming_response(self) -> TypingResourceWithStreamingResponse:
|
|
53
|
+
"""
|
|
54
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
55
|
+
|
|
56
|
+
For more information, see https://www.github.com/linq-team/linq-python#with_streaming_response
|
|
57
|
+
"""
|
|
58
|
+
return TypingResourceWithStreamingResponse(self)
|
|
59
|
+
|
|
60
|
+
def start(
|
|
61
|
+
self,
|
|
62
|
+
chat_id: str,
|
|
63
|
+
*,
|
|
64
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
65
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
66
|
+
extra_headers: Headers | None = None,
|
|
67
|
+
extra_query: Query | None = None,
|
|
68
|
+
extra_body: Body | None = None,
|
|
69
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
70
|
+
) -> None:
|
|
71
|
+
"""
|
|
72
|
+
Send a typing indicator to show that someone is typing in the chat.
|
|
73
|
+
|
|
74
|
+
**Note:** Group chat typing indicators are not currently supported. Attempting
|
|
75
|
+
to start a typing indicator in a group chat will return a `403` error.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
extra_headers: Send extra headers
|
|
79
|
+
|
|
80
|
+
extra_query: Add additional query parameters to the request
|
|
81
|
+
|
|
82
|
+
extra_body: Add additional JSON properties to the request
|
|
83
|
+
|
|
84
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
85
|
+
"""
|
|
86
|
+
if not chat_id:
|
|
87
|
+
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
|
|
88
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
89
|
+
return self._post(
|
|
90
|
+
path_template("/v3/chats/{chat_id}/typing", chat_id=chat_id),
|
|
91
|
+
options=make_request_options(
|
|
92
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
93
|
+
),
|
|
94
|
+
cast_to=NoneType,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def stop(
|
|
98
|
+
self,
|
|
99
|
+
chat_id: str,
|
|
100
|
+
*,
|
|
101
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
102
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
103
|
+
extra_headers: Headers | None = None,
|
|
104
|
+
extra_query: Query | None = None,
|
|
105
|
+
extra_body: Body | None = None,
|
|
106
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
107
|
+
) -> None:
|
|
108
|
+
"""
|
|
109
|
+
Stop the typing indicator for the chat.
|
|
110
|
+
|
|
111
|
+
**Note:** Typing indicators are automatically stopped when a message is sent, so
|
|
112
|
+
calling this endpoint after sending a message is unnecessary.
|
|
113
|
+
|
|
114
|
+
**Note:** Group chat typing indicators are not currently supported. Attempting
|
|
115
|
+
to stop a typing indicator in a group chat will return a `403` error.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
extra_headers: Send extra headers
|
|
119
|
+
|
|
120
|
+
extra_query: Add additional query parameters to the request
|
|
121
|
+
|
|
122
|
+
extra_body: Add additional JSON properties to the request
|
|
123
|
+
|
|
124
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
125
|
+
"""
|
|
126
|
+
if not chat_id:
|
|
127
|
+
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
|
|
128
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
129
|
+
return self._delete(
|
|
130
|
+
path_template("/v3/chats/{chat_id}/typing", chat_id=chat_id),
|
|
131
|
+
options=make_request_options(
|
|
132
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
133
|
+
),
|
|
134
|
+
cast_to=NoneType,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class AsyncTypingResource(AsyncAPIResource):
|
|
139
|
+
"""A Chat is a conversation thread with one or more participants.
|
|
140
|
+
|
|
141
|
+
To begin a chat, you must create a Chat with at least one recipient handle.
|
|
142
|
+
Including multiple handles creates a group chat.
|
|
143
|
+
|
|
144
|
+
When creating a chat, the `from` field specifies which of your
|
|
145
|
+
authorized phone numbers the message originates from. Your authentication token grants
|
|
146
|
+
access to one or more phone numbers, but the `from` field determines the actual sender.
|
|
147
|
+
|
|
148
|
+
**Handle Format:**
|
|
149
|
+
- Handles can be phone numbers or email addresses
|
|
150
|
+
- Phone numbers MUST be in E.164 format (starting with +)
|
|
151
|
+
- Phone format: `+[country code][subscriber number]`
|
|
152
|
+
- Example phone: `+12223334444` (US), `+442071234567` (UK), `+81312345678` (Japan)
|
|
153
|
+
- Example email: `user@example.com`
|
|
154
|
+
- No spaces, dashes, or parentheses in phone numbers
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
@cached_property
|
|
158
|
+
def with_raw_response(self) -> AsyncTypingResourceWithRawResponse:
|
|
159
|
+
"""
|
|
160
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
161
|
+
the raw response object instead of the parsed content.
|
|
162
|
+
|
|
163
|
+
For more information, see https://www.github.com/linq-team/linq-python#accessing-raw-response-data-eg-headers
|
|
164
|
+
"""
|
|
165
|
+
return AsyncTypingResourceWithRawResponse(self)
|
|
166
|
+
|
|
167
|
+
@cached_property
|
|
168
|
+
def with_streaming_response(self) -> AsyncTypingResourceWithStreamingResponse:
|
|
169
|
+
"""
|
|
170
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
171
|
+
|
|
172
|
+
For more information, see https://www.github.com/linq-team/linq-python#with_streaming_response
|
|
173
|
+
"""
|
|
174
|
+
return AsyncTypingResourceWithStreamingResponse(self)
|
|
175
|
+
|
|
176
|
+
async def start(
|
|
177
|
+
self,
|
|
178
|
+
chat_id: str,
|
|
179
|
+
*,
|
|
180
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
181
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
182
|
+
extra_headers: Headers | None = None,
|
|
183
|
+
extra_query: Query | None = None,
|
|
184
|
+
extra_body: Body | None = None,
|
|
185
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
186
|
+
) -> None:
|
|
187
|
+
"""
|
|
188
|
+
Send a typing indicator to show that someone is typing in the chat.
|
|
189
|
+
|
|
190
|
+
**Note:** Group chat typing indicators are not currently supported. Attempting
|
|
191
|
+
to start a typing indicator in a group chat will return a `403` error.
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
extra_headers: Send extra headers
|
|
195
|
+
|
|
196
|
+
extra_query: Add additional query parameters to the request
|
|
197
|
+
|
|
198
|
+
extra_body: Add additional JSON properties to the request
|
|
199
|
+
|
|
200
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
201
|
+
"""
|
|
202
|
+
if not chat_id:
|
|
203
|
+
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
|
|
204
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
205
|
+
return await self._post(
|
|
206
|
+
path_template("/v3/chats/{chat_id}/typing", chat_id=chat_id),
|
|
207
|
+
options=make_request_options(
|
|
208
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
209
|
+
),
|
|
210
|
+
cast_to=NoneType,
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
async def stop(
|
|
214
|
+
self,
|
|
215
|
+
chat_id: str,
|
|
216
|
+
*,
|
|
217
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
218
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
219
|
+
extra_headers: Headers | None = None,
|
|
220
|
+
extra_query: Query | None = None,
|
|
221
|
+
extra_body: Body | None = None,
|
|
222
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
223
|
+
) -> None:
|
|
224
|
+
"""
|
|
225
|
+
Stop the typing indicator for the chat.
|
|
226
|
+
|
|
227
|
+
**Note:** Typing indicators are automatically stopped when a message is sent, so
|
|
228
|
+
calling this endpoint after sending a message is unnecessary.
|
|
229
|
+
|
|
230
|
+
**Note:** Group chat typing indicators are not currently supported. Attempting
|
|
231
|
+
to stop a typing indicator in a group chat will return a `403` error.
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
extra_headers: Send extra headers
|
|
235
|
+
|
|
236
|
+
extra_query: Add additional query parameters to the request
|
|
237
|
+
|
|
238
|
+
extra_body: Add additional JSON properties to the request
|
|
239
|
+
|
|
240
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
241
|
+
"""
|
|
242
|
+
if not chat_id:
|
|
243
|
+
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
|
|
244
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
245
|
+
return await self._delete(
|
|
246
|
+
path_template("/v3/chats/{chat_id}/typing", chat_id=chat_id),
|
|
247
|
+
options=make_request_options(
|
|
248
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
249
|
+
),
|
|
250
|
+
cast_to=NoneType,
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
class TypingResourceWithRawResponse:
|
|
255
|
+
def __init__(self, typing: TypingResource) -> None:
|
|
256
|
+
self._typing = typing
|
|
257
|
+
|
|
258
|
+
self.start = to_raw_response_wrapper(
|
|
259
|
+
typing.start,
|
|
260
|
+
)
|
|
261
|
+
self.stop = to_raw_response_wrapper(
|
|
262
|
+
typing.stop,
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
class AsyncTypingResourceWithRawResponse:
|
|
267
|
+
def __init__(self, typing: AsyncTypingResource) -> None:
|
|
268
|
+
self._typing = typing
|
|
269
|
+
|
|
270
|
+
self.start = async_to_raw_response_wrapper(
|
|
271
|
+
typing.start,
|
|
272
|
+
)
|
|
273
|
+
self.stop = async_to_raw_response_wrapper(
|
|
274
|
+
typing.stop,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
class TypingResourceWithStreamingResponse:
|
|
279
|
+
def __init__(self, typing: TypingResource) -> None:
|
|
280
|
+
self._typing = typing
|
|
281
|
+
|
|
282
|
+
self.start = to_streamed_response_wrapper(
|
|
283
|
+
typing.start,
|
|
284
|
+
)
|
|
285
|
+
self.stop = to_streamed_response_wrapper(
|
|
286
|
+
typing.stop,
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class AsyncTypingResourceWithStreamingResponse:
|
|
291
|
+
def __init__(self, typing: AsyncTypingResource) -> None:
|
|
292
|
+
self._typing = typing
|
|
293
|
+
|
|
294
|
+
self.start = async_to_streamed_response_wrapper(
|
|
295
|
+
typing.start,
|
|
296
|
+
)
|
|
297
|
+
self.stop = async_to_streamed_response_wrapper(
|
|
298
|
+
typing.stop,
|
|
299
|
+
)
|