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,686 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing_extensions import Literal
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ..types import message_update_params, message_add_reaction_params, message_list_messages_thread_params
|
|
10
|
+
from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given
|
|
11
|
+
from .._utils import path_template, 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 ..pagination import SyncListMessagesPagination, AsyncListMessagesPagination
|
|
21
|
+
from .._base_client import AsyncPaginator, make_request_options
|
|
22
|
+
from ..types.message import Message
|
|
23
|
+
from ..types.shared.reaction_type import ReactionType
|
|
24
|
+
from ..types.message_add_reaction_response import MessageAddReactionResponse
|
|
25
|
+
|
|
26
|
+
__all__ = ["MessagesResource", "AsyncMessagesResource"]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class MessagesResource(SyncAPIResource):
|
|
30
|
+
"""Messages are individual communications within a chat thread.
|
|
31
|
+
|
|
32
|
+
Messages can include text, media attachments, rich link previews, special effects
|
|
33
|
+
(like confetti or fireworks), and reactions. All messages are associated with a
|
|
34
|
+
specific chat and sent from a phone number you own.
|
|
35
|
+
|
|
36
|
+
Messages support delivery status tracking, read receipts, and editing capabilities.
|
|
37
|
+
|
|
38
|
+
## Rich Link Previews
|
|
39
|
+
|
|
40
|
+
Send a URL as a `link` part to deliver it with a rich preview card showing the
|
|
41
|
+
page's title, description, and image (when available). A `link` part must be the
|
|
42
|
+
**only** part in the message — it cannot be combined with text or media parts.
|
|
43
|
+
To send a URL without a preview card, include it in a `text` part instead.
|
|
44
|
+
|
|
45
|
+
**Limitations:**
|
|
46
|
+
- A `link` part cannot be combined with other parts in the same message.
|
|
47
|
+
- Maximum URL length: 2,048 characters.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
@cached_property
|
|
51
|
+
def with_raw_response(self) -> MessagesResourceWithRawResponse:
|
|
52
|
+
"""
|
|
53
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
54
|
+
the raw response object instead of the parsed content.
|
|
55
|
+
|
|
56
|
+
For more information, see https://www.github.com/linq-team/linq-python#accessing-raw-response-data-eg-headers
|
|
57
|
+
"""
|
|
58
|
+
return MessagesResourceWithRawResponse(self)
|
|
59
|
+
|
|
60
|
+
@cached_property
|
|
61
|
+
def with_streaming_response(self) -> MessagesResourceWithStreamingResponse:
|
|
62
|
+
"""
|
|
63
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
64
|
+
|
|
65
|
+
For more information, see https://www.github.com/linq-team/linq-python#with_streaming_response
|
|
66
|
+
"""
|
|
67
|
+
return MessagesResourceWithStreamingResponse(self)
|
|
68
|
+
|
|
69
|
+
def retrieve(
|
|
70
|
+
self,
|
|
71
|
+
message_id: str,
|
|
72
|
+
*,
|
|
73
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
74
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
75
|
+
extra_headers: Headers | None = None,
|
|
76
|
+
extra_query: Query | None = None,
|
|
77
|
+
extra_body: Body | None = None,
|
|
78
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
79
|
+
) -> Message:
|
|
80
|
+
"""Retrieve a specific message by its ID.
|
|
81
|
+
|
|
82
|
+
This endpoint returns the full message
|
|
83
|
+
details including text, attachments, reactions, and metadata.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
extra_headers: Send extra headers
|
|
87
|
+
|
|
88
|
+
extra_query: Add additional query parameters to the request
|
|
89
|
+
|
|
90
|
+
extra_body: Add additional JSON properties to the request
|
|
91
|
+
|
|
92
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
93
|
+
"""
|
|
94
|
+
if not message_id:
|
|
95
|
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
96
|
+
return self._get(
|
|
97
|
+
path_template("/v3/messages/{message_id}", message_id=message_id),
|
|
98
|
+
options=make_request_options(
|
|
99
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
100
|
+
),
|
|
101
|
+
cast_to=Message,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
def update(
|
|
105
|
+
self,
|
|
106
|
+
message_id: str,
|
|
107
|
+
*,
|
|
108
|
+
text: str,
|
|
109
|
+
part_index: int | Omit = omit,
|
|
110
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
111
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
112
|
+
extra_headers: Headers | None = None,
|
|
113
|
+
extra_query: Query | None = None,
|
|
114
|
+
extra_body: Body | None = None,
|
|
115
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
116
|
+
) -> Message:
|
|
117
|
+
"""
|
|
118
|
+
Edit the text content of a specific part of a previously sent message.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
text: New text content for the message part
|
|
122
|
+
|
|
123
|
+
part_index: Index of the message part to edit. Defaults to 0.
|
|
124
|
+
|
|
125
|
+
extra_headers: Send extra headers
|
|
126
|
+
|
|
127
|
+
extra_query: Add additional query parameters to the request
|
|
128
|
+
|
|
129
|
+
extra_body: Add additional JSON properties to the request
|
|
130
|
+
|
|
131
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
132
|
+
"""
|
|
133
|
+
if not message_id:
|
|
134
|
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
135
|
+
return self._patch(
|
|
136
|
+
path_template("/v3/messages/{message_id}", message_id=message_id),
|
|
137
|
+
body=maybe_transform(
|
|
138
|
+
{
|
|
139
|
+
"text": text,
|
|
140
|
+
"part_index": part_index,
|
|
141
|
+
},
|
|
142
|
+
message_update_params.MessageUpdateParams,
|
|
143
|
+
),
|
|
144
|
+
options=make_request_options(
|
|
145
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
146
|
+
),
|
|
147
|
+
cast_to=Message,
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
def delete(
|
|
151
|
+
self,
|
|
152
|
+
message_id: str,
|
|
153
|
+
*,
|
|
154
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
155
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
156
|
+
extra_headers: Headers | None = None,
|
|
157
|
+
extra_query: Query | None = None,
|
|
158
|
+
extra_body: Body | None = None,
|
|
159
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
160
|
+
) -> None:
|
|
161
|
+
"""Deletes a message from the Linq API only.
|
|
162
|
+
|
|
163
|
+
This does NOT unsend or remove the
|
|
164
|
+
message from the actual chat — recipients will still see the message.
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
extra_headers: Send extra headers
|
|
168
|
+
|
|
169
|
+
extra_query: Add additional query parameters to the request
|
|
170
|
+
|
|
171
|
+
extra_body: Add additional JSON properties to the request
|
|
172
|
+
|
|
173
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
174
|
+
"""
|
|
175
|
+
if not message_id:
|
|
176
|
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
177
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
178
|
+
return self._delete(
|
|
179
|
+
path_template("/v3/messages/{message_id}", message_id=message_id),
|
|
180
|
+
options=make_request_options(
|
|
181
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
182
|
+
),
|
|
183
|
+
cast_to=NoneType,
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
def add_reaction(
|
|
187
|
+
self,
|
|
188
|
+
message_id: str,
|
|
189
|
+
*,
|
|
190
|
+
operation: Literal["add", "remove"],
|
|
191
|
+
type: ReactionType,
|
|
192
|
+
custom_emoji: str | Omit = omit,
|
|
193
|
+
part_index: int | Omit = omit,
|
|
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
|
+
) -> MessageAddReactionResponse:
|
|
201
|
+
"""Add or remove emoji reactions to messages.
|
|
202
|
+
|
|
203
|
+
Reactions let users express their
|
|
204
|
+
response to a message without sending a new message.
|
|
205
|
+
|
|
206
|
+
**Supported Reactions:**
|
|
207
|
+
|
|
208
|
+
- love ❤️
|
|
209
|
+
- like 👍
|
|
210
|
+
- dislike 👎
|
|
211
|
+
- laugh 😂
|
|
212
|
+
- emphasize ‼️
|
|
213
|
+
- question ❓
|
|
214
|
+
- custom - any emoji (use `custom_emoji` field to specify)
|
|
215
|
+
|
|
216
|
+
Args:
|
|
217
|
+
operation: Whether to add or remove the reaction
|
|
218
|
+
|
|
219
|
+
type: Type of reaction. Standard iMessage tapbacks are love, like, dislike, laugh,
|
|
220
|
+
emphasize, question. Custom emoji reactions have type "custom" with the actual
|
|
221
|
+
emoji in the custom_emoji field. Sticker reactions have type "sticker" with
|
|
222
|
+
sticker attachment details in the sticker field.
|
|
223
|
+
|
|
224
|
+
custom_emoji: Custom emoji string. Required when type is "custom".
|
|
225
|
+
|
|
226
|
+
part_index: Optional index of the message part to react to. If not provided, reacts to the
|
|
227
|
+
entire message (part 0).
|
|
228
|
+
|
|
229
|
+
extra_headers: Send extra headers
|
|
230
|
+
|
|
231
|
+
extra_query: Add additional query parameters to the request
|
|
232
|
+
|
|
233
|
+
extra_body: Add additional JSON properties to the request
|
|
234
|
+
|
|
235
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
236
|
+
"""
|
|
237
|
+
if not message_id:
|
|
238
|
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
239
|
+
return self._post(
|
|
240
|
+
path_template("/v3/messages/{message_id}/reactions", message_id=message_id),
|
|
241
|
+
body=maybe_transform(
|
|
242
|
+
{
|
|
243
|
+
"operation": operation,
|
|
244
|
+
"type": type,
|
|
245
|
+
"custom_emoji": custom_emoji,
|
|
246
|
+
"part_index": part_index,
|
|
247
|
+
},
|
|
248
|
+
message_add_reaction_params.MessageAddReactionParams,
|
|
249
|
+
),
|
|
250
|
+
options=make_request_options(
|
|
251
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
252
|
+
),
|
|
253
|
+
cast_to=MessageAddReactionResponse,
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
def list_messages_thread(
|
|
257
|
+
self,
|
|
258
|
+
message_id: str,
|
|
259
|
+
*,
|
|
260
|
+
cursor: str | Omit = omit,
|
|
261
|
+
limit: int | Omit = omit,
|
|
262
|
+
order: Literal["asc", "desc"] | Omit = omit,
|
|
263
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
264
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
265
|
+
extra_headers: Headers | None = None,
|
|
266
|
+
extra_query: Query | None = None,
|
|
267
|
+
extra_body: Body | None = None,
|
|
268
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
269
|
+
) -> SyncListMessagesPagination[Message]:
|
|
270
|
+
"""Retrieve all messages in a conversation thread.
|
|
271
|
+
|
|
272
|
+
Given any message ID in the
|
|
273
|
+
thread, returns the originator message and all replies in chronological order.
|
|
274
|
+
|
|
275
|
+
If the message is not part of a thread, returns just that single message.
|
|
276
|
+
|
|
277
|
+
Supports pagination and configurable ordering.
|
|
278
|
+
|
|
279
|
+
Args:
|
|
280
|
+
cursor: Pagination cursor from previous next_cursor response
|
|
281
|
+
|
|
282
|
+
limit: Maximum number of messages to return
|
|
283
|
+
|
|
284
|
+
order: Sort order for messages (asc = oldest first, desc = newest first)
|
|
285
|
+
|
|
286
|
+
extra_headers: Send extra headers
|
|
287
|
+
|
|
288
|
+
extra_query: Add additional query parameters to the request
|
|
289
|
+
|
|
290
|
+
extra_body: Add additional JSON properties to the request
|
|
291
|
+
|
|
292
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
293
|
+
"""
|
|
294
|
+
if not message_id:
|
|
295
|
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
296
|
+
return self._get_api_list(
|
|
297
|
+
path_template("/v3/messages/{message_id}/thread", message_id=message_id),
|
|
298
|
+
page=SyncListMessagesPagination[Message],
|
|
299
|
+
options=make_request_options(
|
|
300
|
+
extra_headers=extra_headers,
|
|
301
|
+
extra_query=extra_query,
|
|
302
|
+
extra_body=extra_body,
|
|
303
|
+
timeout=timeout,
|
|
304
|
+
query=maybe_transform(
|
|
305
|
+
{
|
|
306
|
+
"cursor": cursor,
|
|
307
|
+
"limit": limit,
|
|
308
|
+
"order": order,
|
|
309
|
+
},
|
|
310
|
+
message_list_messages_thread_params.MessageListMessagesThreadParams,
|
|
311
|
+
),
|
|
312
|
+
),
|
|
313
|
+
model=Message,
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
class AsyncMessagesResource(AsyncAPIResource):
|
|
318
|
+
"""Messages are individual communications within a chat thread.
|
|
319
|
+
|
|
320
|
+
Messages can include text, media attachments, rich link previews, special effects
|
|
321
|
+
(like confetti or fireworks), and reactions. All messages are associated with a
|
|
322
|
+
specific chat and sent from a phone number you own.
|
|
323
|
+
|
|
324
|
+
Messages support delivery status tracking, read receipts, and editing capabilities.
|
|
325
|
+
|
|
326
|
+
## Rich Link Previews
|
|
327
|
+
|
|
328
|
+
Send a URL as a `link` part to deliver it with a rich preview card showing the
|
|
329
|
+
page's title, description, and image (when available). A `link` part must be the
|
|
330
|
+
**only** part in the message — it cannot be combined with text or media parts.
|
|
331
|
+
To send a URL without a preview card, include it in a `text` part instead.
|
|
332
|
+
|
|
333
|
+
**Limitations:**
|
|
334
|
+
- A `link` part cannot be combined with other parts in the same message.
|
|
335
|
+
- Maximum URL length: 2,048 characters.
|
|
336
|
+
"""
|
|
337
|
+
|
|
338
|
+
@cached_property
|
|
339
|
+
def with_raw_response(self) -> AsyncMessagesResourceWithRawResponse:
|
|
340
|
+
"""
|
|
341
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
342
|
+
the raw response object instead of the parsed content.
|
|
343
|
+
|
|
344
|
+
For more information, see https://www.github.com/linq-team/linq-python#accessing-raw-response-data-eg-headers
|
|
345
|
+
"""
|
|
346
|
+
return AsyncMessagesResourceWithRawResponse(self)
|
|
347
|
+
|
|
348
|
+
@cached_property
|
|
349
|
+
def with_streaming_response(self) -> AsyncMessagesResourceWithStreamingResponse:
|
|
350
|
+
"""
|
|
351
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
352
|
+
|
|
353
|
+
For more information, see https://www.github.com/linq-team/linq-python#with_streaming_response
|
|
354
|
+
"""
|
|
355
|
+
return AsyncMessagesResourceWithStreamingResponse(self)
|
|
356
|
+
|
|
357
|
+
async def retrieve(
|
|
358
|
+
self,
|
|
359
|
+
message_id: str,
|
|
360
|
+
*,
|
|
361
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
362
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
363
|
+
extra_headers: Headers | None = None,
|
|
364
|
+
extra_query: Query | None = None,
|
|
365
|
+
extra_body: Body | None = None,
|
|
366
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
367
|
+
) -> Message:
|
|
368
|
+
"""Retrieve a specific message by its ID.
|
|
369
|
+
|
|
370
|
+
This endpoint returns the full message
|
|
371
|
+
details including text, attachments, reactions, and metadata.
|
|
372
|
+
|
|
373
|
+
Args:
|
|
374
|
+
extra_headers: Send extra headers
|
|
375
|
+
|
|
376
|
+
extra_query: Add additional query parameters to the request
|
|
377
|
+
|
|
378
|
+
extra_body: Add additional JSON properties to the request
|
|
379
|
+
|
|
380
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
381
|
+
"""
|
|
382
|
+
if not message_id:
|
|
383
|
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
384
|
+
return await self._get(
|
|
385
|
+
path_template("/v3/messages/{message_id}", message_id=message_id),
|
|
386
|
+
options=make_request_options(
|
|
387
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
388
|
+
),
|
|
389
|
+
cast_to=Message,
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
async def update(
|
|
393
|
+
self,
|
|
394
|
+
message_id: str,
|
|
395
|
+
*,
|
|
396
|
+
text: str,
|
|
397
|
+
part_index: int | Omit = omit,
|
|
398
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
399
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
400
|
+
extra_headers: Headers | None = None,
|
|
401
|
+
extra_query: Query | None = None,
|
|
402
|
+
extra_body: Body | None = None,
|
|
403
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
404
|
+
) -> Message:
|
|
405
|
+
"""
|
|
406
|
+
Edit the text content of a specific part of a previously sent message.
|
|
407
|
+
|
|
408
|
+
Args:
|
|
409
|
+
text: New text content for the message part
|
|
410
|
+
|
|
411
|
+
part_index: Index of the message part to edit. Defaults to 0.
|
|
412
|
+
|
|
413
|
+
extra_headers: Send extra headers
|
|
414
|
+
|
|
415
|
+
extra_query: Add additional query parameters to the request
|
|
416
|
+
|
|
417
|
+
extra_body: Add additional JSON properties to the request
|
|
418
|
+
|
|
419
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
420
|
+
"""
|
|
421
|
+
if not message_id:
|
|
422
|
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
423
|
+
return await self._patch(
|
|
424
|
+
path_template("/v3/messages/{message_id}", message_id=message_id),
|
|
425
|
+
body=await async_maybe_transform(
|
|
426
|
+
{
|
|
427
|
+
"text": text,
|
|
428
|
+
"part_index": part_index,
|
|
429
|
+
},
|
|
430
|
+
message_update_params.MessageUpdateParams,
|
|
431
|
+
),
|
|
432
|
+
options=make_request_options(
|
|
433
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
434
|
+
),
|
|
435
|
+
cast_to=Message,
|
|
436
|
+
)
|
|
437
|
+
|
|
438
|
+
async def delete(
|
|
439
|
+
self,
|
|
440
|
+
message_id: str,
|
|
441
|
+
*,
|
|
442
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
443
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
444
|
+
extra_headers: Headers | None = None,
|
|
445
|
+
extra_query: Query | None = None,
|
|
446
|
+
extra_body: Body | None = None,
|
|
447
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
448
|
+
) -> None:
|
|
449
|
+
"""Deletes a message from the Linq API only.
|
|
450
|
+
|
|
451
|
+
This does NOT unsend or remove the
|
|
452
|
+
message from the actual chat — recipients will still see the message.
|
|
453
|
+
|
|
454
|
+
Args:
|
|
455
|
+
extra_headers: Send extra headers
|
|
456
|
+
|
|
457
|
+
extra_query: Add additional query parameters to the request
|
|
458
|
+
|
|
459
|
+
extra_body: Add additional JSON properties to the request
|
|
460
|
+
|
|
461
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
462
|
+
"""
|
|
463
|
+
if not message_id:
|
|
464
|
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
465
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
466
|
+
return await self._delete(
|
|
467
|
+
path_template("/v3/messages/{message_id}", message_id=message_id),
|
|
468
|
+
options=make_request_options(
|
|
469
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
470
|
+
),
|
|
471
|
+
cast_to=NoneType,
|
|
472
|
+
)
|
|
473
|
+
|
|
474
|
+
async def add_reaction(
|
|
475
|
+
self,
|
|
476
|
+
message_id: str,
|
|
477
|
+
*,
|
|
478
|
+
operation: Literal["add", "remove"],
|
|
479
|
+
type: ReactionType,
|
|
480
|
+
custom_emoji: str | Omit = omit,
|
|
481
|
+
part_index: int | Omit = omit,
|
|
482
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
483
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
484
|
+
extra_headers: Headers | None = None,
|
|
485
|
+
extra_query: Query | None = None,
|
|
486
|
+
extra_body: Body | None = None,
|
|
487
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
488
|
+
) -> MessageAddReactionResponse:
|
|
489
|
+
"""Add or remove emoji reactions to messages.
|
|
490
|
+
|
|
491
|
+
Reactions let users express their
|
|
492
|
+
response to a message without sending a new message.
|
|
493
|
+
|
|
494
|
+
**Supported Reactions:**
|
|
495
|
+
|
|
496
|
+
- love ❤️
|
|
497
|
+
- like 👍
|
|
498
|
+
- dislike 👎
|
|
499
|
+
- laugh 😂
|
|
500
|
+
- emphasize ‼️
|
|
501
|
+
- question ❓
|
|
502
|
+
- custom - any emoji (use `custom_emoji` field to specify)
|
|
503
|
+
|
|
504
|
+
Args:
|
|
505
|
+
operation: Whether to add or remove the reaction
|
|
506
|
+
|
|
507
|
+
type: Type of reaction. Standard iMessage tapbacks are love, like, dislike, laugh,
|
|
508
|
+
emphasize, question. Custom emoji reactions have type "custom" with the actual
|
|
509
|
+
emoji in the custom_emoji field. Sticker reactions have type "sticker" with
|
|
510
|
+
sticker attachment details in the sticker field.
|
|
511
|
+
|
|
512
|
+
custom_emoji: Custom emoji string. Required when type is "custom".
|
|
513
|
+
|
|
514
|
+
part_index: Optional index of the message part to react to. If not provided, reacts to the
|
|
515
|
+
entire message (part 0).
|
|
516
|
+
|
|
517
|
+
extra_headers: Send extra headers
|
|
518
|
+
|
|
519
|
+
extra_query: Add additional query parameters to the request
|
|
520
|
+
|
|
521
|
+
extra_body: Add additional JSON properties to the request
|
|
522
|
+
|
|
523
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
524
|
+
"""
|
|
525
|
+
if not message_id:
|
|
526
|
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
527
|
+
return await self._post(
|
|
528
|
+
path_template("/v3/messages/{message_id}/reactions", message_id=message_id),
|
|
529
|
+
body=await async_maybe_transform(
|
|
530
|
+
{
|
|
531
|
+
"operation": operation,
|
|
532
|
+
"type": type,
|
|
533
|
+
"custom_emoji": custom_emoji,
|
|
534
|
+
"part_index": part_index,
|
|
535
|
+
},
|
|
536
|
+
message_add_reaction_params.MessageAddReactionParams,
|
|
537
|
+
),
|
|
538
|
+
options=make_request_options(
|
|
539
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
540
|
+
),
|
|
541
|
+
cast_to=MessageAddReactionResponse,
|
|
542
|
+
)
|
|
543
|
+
|
|
544
|
+
def list_messages_thread(
|
|
545
|
+
self,
|
|
546
|
+
message_id: str,
|
|
547
|
+
*,
|
|
548
|
+
cursor: str | Omit = omit,
|
|
549
|
+
limit: int | Omit = omit,
|
|
550
|
+
order: Literal["asc", "desc"] | Omit = omit,
|
|
551
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
552
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
553
|
+
extra_headers: Headers | None = None,
|
|
554
|
+
extra_query: Query | None = None,
|
|
555
|
+
extra_body: Body | None = None,
|
|
556
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
557
|
+
) -> AsyncPaginator[Message, AsyncListMessagesPagination[Message]]:
|
|
558
|
+
"""Retrieve all messages in a conversation thread.
|
|
559
|
+
|
|
560
|
+
Given any message ID in the
|
|
561
|
+
thread, returns the originator message and all replies in chronological order.
|
|
562
|
+
|
|
563
|
+
If the message is not part of a thread, returns just that single message.
|
|
564
|
+
|
|
565
|
+
Supports pagination and configurable ordering.
|
|
566
|
+
|
|
567
|
+
Args:
|
|
568
|
+
cursor: Pagination cursor from previous next_cursor response
|
|
569
|
+
|
|
570
|
+
limit: Maximum number of messages to return
|
|
571
|
+
|
|
572
|
+
order: Sort order for messages (asc = oldest first, desc = newest first)
|
|
573
|
+
|
|
574
|
+
extra_headers: Send extra headers
|
|
575
|
+
|
|
576
|
+
extra_query: Add additional query parameters to the request
|
|
577
|
+
|
|
578
|
+
extra_body: Add additional JSON properties to the request
|
|
579
|
+
|
|
580
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
581
|
+
"""
|
|
582
|
+
if not message_id:
|
|
583
|
+
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
584
|
+
return self._get_api_list(
|
|
585
|
+
path_template("/v3/messages/{message_id}/thread", message_id=message_id),
|
|
586
|
+
page=AsyncListMessagesPagination[Message],
|
|
587
|
+
options=make_request_options(
|
|
588
|
+
extra_headers=extra_headers,
|
|
589
|
+
extra_query=extra_query,
|
|
590
|
+
extra_body=extra_body,
|
|
591
|
+
timeout=timeout,
|
|
592
|
+
query=maybe_transform(
|
|
593
|
+
{
|
|
594
|
+
"cursor": cursor,
|
|
595
|
+
"limit": limit,
|
|
596
|
+
"order": order,
|
|
597
|
+
},
|
|
598
|
+
message_list_messages_thread_params.MessageListMessagesThreadParams,
|
|
599
|
+
),
|
|
600
|
+
),
|
|
601
|
+
model=Message,
|
|
602
|
+
)
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
class MessagesResourceWithRawResponse:
|
|
606
|
+
def __init__(self, messages: MessagesResource) -> None:
|
|
607
|
+
self._messages = messages
|
|
608
|
+
|
|
609
|
+
self.retrieve = to_raw_response_wrapper(
|
|
610
|
+
messages.retrieve,
|
|
611
|
+
)
|
|
612
|
+
self.update = to_raw_response_wrapper(
|
|
613
|
+
messages.update,
|
|
614
|
+
)
|
|
615
|
+
self.delete = to_raw_response_wrapper(
|
|
616
|
+
messages.delete,
|
|
617
|
+
)
|
|
618
|
+
self.add_reaction = to_raw_response_wrapper(
|
|
619
|
+
messages.add_reaction,
|
|
620
|
+
)
|
|
621
|
+
self.list_messages_thread = to_raw_response_wrapper(
|
|
622
|
+
messages.list_messages_thread,
|
|
623
|
+
)
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
class AsyncMessagesResourceWithRawResponse:
|
|
627
|
+
def __init__(self, messages: AsyncMessagesResource) -> None:
|
|
628
|
+
self._messages = messages
|
|
629
|
+
|
|
630
|
+
self.retrieve = async_to_raw_response_wrapper(
|
|
631
|
+
messages.retrieve,
|
|
632
|
+
)
|
|
633
|
+
self.update = async_to_raw_response_wrapper(
|
|
634
|
+
messages.update,
|
|
635
|
+
)
|
|
636
|
+
self.delete = async_to_raw_response_wrapper(
|
|
637
|
+
messages.delete,
|
|
638
|
+
)
|
|
639
|
+
self.add_reaction = async_to_raw_response_wrapper(
|
|
640
|
+
messages.add_reaction,
|
|
641
|
+
)
|
|
642
|
+
self.list_messages_thread = async_to_raw_response_wrapper(
|
|
643
|
+
messages.list_messages_thread,
|
|
644
|
+
)
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
class MessagesResourceWithStreamingResponse:
|
|
648
|
+
def __init__(self, messages: MessagesResource) -> None:
|
|
649
|
+
self._messages = messages
|
|
650
|
+
|
|
651
|
+
self.retrieve = to_streamed_response_wrapper(
|
|
652
|
+
messages.retrieve,
|
|
653
|
+
)
|
|
654
|
+
self.update = to_streamed_response_wrapper(
|
|
655
|
+
messages.update,
|
|
656
|
+
)
|
|
657
|
+
self.delete = to_streamed_response_wrapper(
|
|
658
|
+
messages.delete,
|
|
659
|
+
)
|
|
660
|
+
self.add_reaction = to_streamed_response_wrapper(
|
|
661
|
+
messages.add_reaction,
|
|
662
|
+
)
|
|
663
|
+
self.list_messages_thread = to_streamed_response_wrapper(
|
|
664
|
+
messages.list_messages_thread,
|
|
665
|
+
)
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
class AsyncMessagesResourceWithStreamingResponse:
|
|
669
|
+
def __init__(self, messages: AsyncMessagesResource) -> None:
|
|
670
|
+
self._messages = messages
|
|
671
|
+
|
|
672
|
+
self.retrieve = async_to_streamed_response_wrapper(
|
|
673
|
+
messages.retrieve,
|
|
674
|
+
)
|
|
675
|
+
self.update = async_to_streamed_response_wrapper(
|
|
676
|
+
messages.update,
|
|
677
|
+
)
|
|
678
|
+
self.delete = async_to_streamed_response_wrapper(
|
|
679
|
+
messages.delete,
|
|
680
|
+
)
|
|
681
|
+
self.add_reaction = async_to_streamed_response_wrapper(
|
|
682
|
+
messages.add_reaction,
|
|
683
|
+
)
|
|
684
|
+
self.list_messages_thread = async_to_streamed_response_wrapper(
|
|
685
|
+
messages.list_messages_thread,
|
|
686
|
+
)
|