Skip to content

Commit 4f6c268

Browse files
feat(api): api update
1 parent c77412c commit 4f6c268

File tree

5 files changed

+141
-70
lines changed

5 files changed

+141
-70
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 23
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-4acef56b00be513f305543096fdd407e6947f0a5ad268ab2e627ff30b37a75db.yml
33
openapi_spec_hash: e876d796b6c25f18577f6be3944bf7d9
4-
config_hash: b5ac0c1579dfe6257bcdb84cfd1002fc
4+
config_hash: 659111d4e28efa599b5f800619ed79c2

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ from beeper_desktop_api import BeeperDesktop
219219
client = BeeperDesktop()
220220

221221
chat = client.chats.create(
222-
chat={"account_id": "accountID"},
222+
account_id="accountID",
223+
user={},
223224
)
224225
print(chat.user)
225226
```

src/beeper_desktop_api/resources/chats/chats.py

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,14 @@ def with_streaming_response(self) -> ChatsResourceWithStreamingResponse:
7979
def create(
8080
self,
8181
*,
82-
chat: chat_create_params.Chat,
82+
account_id: str,
83+
allow_invite: bool | Omit = omit,
84+
message_text: str | Omit = omit,
85+
mode: Literal["create", "start"] | Omit = omit,
86+
participant_ids: SequenceNotStr[str] | Omit = omit,
87+
title: str | Omit = omit,
88+
type: Literal["single", "group"] | Omit = omit,
89+
user: chat_create_params.User | Omit = omit,
8390
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
8491
# The extra values given here take precedence over values defined on the client or passed to this method.
8592
extra_headers: Headers | None = None,
@@ -92,6 +99,26 @@ def create(
9299
user data (mode='start').
93100
94101
Args:
102+
account_id: Account to create or start the chat on.
103+
104+
allow_invite: Whether invite-based DM creation is allowed when required by the platform. Used
105+
for mode='start'.
106+
107+
message_text: Optional first message content if the platform requires it to create the chat.
108+
109+
mode: Operation mode. Defaults to 'create' when omitted.
110+
111+
participant_ids: Required when mode='create'. User IDs to include in the new chat.
112+
113+
title: Optional title for group chats when mode='create'; ignored for single chats on
114+
most platforms.
115+
116+
type: Required when mode='create'. 'single' requires exactly one participantID;
117+
'group' supports multiple participants and optional title.
118+
119+
user: Required when mode='start'. Merged user-like contact payload used to resolve the
120+
best identifier.
121+
95122
extra_headers: Send extra headers
96123
97124
extra_query: Add additional query parameters to the request
@@ -102,7 +129,19 @@ def create(
102129
"""
103130
return self._post(
104131
"/v1/chats",
105-
body=maybe_transform(chat, chat_create_params.ChatCreateParams),
132+
body=maybe_transform(
133+
{
134+
"account_id": account_id,
135+
"allow_invite": allow_invite,
136+
"message_text": message_text,
137+
"mode": mode,
138+
"participant_ids": participant_ids,
139+
"title": title,
140+
"type": type,
141+
"user": user,
142+
},
143+
chat_create_params.ChatCreateParams,
144+
),
106145
options=make_request_options(
107146
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
108147
),
@@ -383,7 +422,14 @@ def with_streaming_response(self) -> AsyncChatsResourceWithStreamingResponse:
383422
async def create(
384423
self,
385424
*,
386-
chat: chat_create_params.Chat,
425+
account_id: str,
426+
allow_invite: bool | Omit = omit,
427+
message_text: str | Omit = omit,
428+
mode: Literal["create", "start"] | Omit = omit,
429+
participant_ids: SequenceNotStr[str] | Omit = omit,
430+
title: str | Omit = omit,
431+
type: Literal["single", "group"] | Omit = omit,
432+
user: chat_create_params.User | Omit = omit,
387433
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
388434
# The extra values given here take precedence over values defined on the client or passed to this method.
389435
extra_headers: Headers | None = None,
@@ -396,6 +442,26 @@ async def create(
396442
user data (mode='start').
397443
398444
Args:
445+
account_id: Account to create or start the chat on.
446+
447+
allow_invite: Whether invite-based DM creation is allowed when required by the platform. Used
448+
for mode='start'.
449+
450+
message_text: Optional first message content if the platform requires it to create the chat.
451+
452+
mode: Operation mode. Defaults to 'create' when omitted.
453+
454+
participant_ids: Required when mode='create'. User IDs to include in the new chat.
455+
456+
title: Optional title for group chats when mode='create'; ignored for single chats on
457+
most platforms.
458+
459+
type: Required when mode='create'. 'single' requires exactly one participantID;
460+
'group' supports multiple participants and optional title.
461+
462+
user: Required when mode='start'. Merged user-like contact payload used to resolve the
463+
best identifier.
464+
399465
extra_headers: Send extra headers
400466
401467
extra_query: Add additional query parameters to the request
@@ -406,7 +472,19 @@ async def create(
406472
"""
407473
return await self._post(
408474
"/v1/chats",
409-
body=await async_maybe_transform(chat, chat_create_params.ChatCreateParams),
475+
body=await async_maybe_transform(
476+
{
477+
"account_id": account_id,
478+
"allow_invite": allow_invite,
479+
"message_text": message_text,
480+
"mode": mode,
481+
"participant_ids": participant_ids,
482+
"title": title,
483+
"type": type,
484+
"user": user,
485+
},
486+
chat_create_params.ChatCreateParams,
487+
),
410488
options=make_request_options(
411489
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
412490
),

src/beeper_desktop_api/types/chat_create_params.py

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,10 @@
77
from .._types import SequenceNotStr
88
from .._utils import PropertyInfo
99

10-
__all__ = ["ChatCreateParams", "Chat", "ChatUser"]
10+
__all__ = ["ChatCreateParams", "User"]
1111

1212

1313
class ChatCreateParams(TypedDict, total=False):
14-
chat: Required[Chat]
15-
16-
17-
class ChatUser(TypedDict, total=False):
18-
"""Required when mode='start'.
19-
20-
Merged user-like contact payload used to resolve the best identifier.
21-
"""
22-
23-
id: str
24-
"""Known user ID when available."""
25-
26-
email: str
27-
"""Email candidate."""
28-
29-
full_name: Annotated[str, PropertyInfo(alias="fullName")]
30-
"""Display name hint used for ranking only."""
31-
32-
phone_number: Annotated[str, PropertyInfo(alias="phoneNumber")]
33-
"""Phone number candidate (E.164 preferred)."""
34-
35-
username: str
36-
"""Username/handle candidate."""
37-
38-
39-
class Chat(TypedDict, total=False):
4014
account_id: Required[Annotated[str, PropertyInfo(alias="accountID")]]
4115
"""Account to create or start the chat on."""
4216

@@ -68,8 +42,30 @@ class Chat(TypedDict, total=False):
6842
participants and optional title.
6943
"""
7044

71-
user: ChatUser
45+
user: User
7246
"""Required when mode='start'.
7347
7448
Merged user-like contact payload used to resolve the best identifier.
7549
"""
50+
51+
52+
class User(TypedDict, total=False):
53+
"""Required when mode='start'.
54+
55+
Merged user-like contact payload used to resolve the best identifier.
56+
"""
57+
58+
id: str
59+
"""Known user ID when available."""
60+
61+
email: str
62+
"""Email candidate."""
63+
64+
full_name: Annotated[str, PropertyInfo(alias="fullName")]
65+
"""Display name hint used for ranking only."""
66+
67+
phone_number: Annotated[str, PropertyInfo(alias="phoneNumber")]
68+
"""Phone number candidate (E.164 preferred)."""
69+
70+
username: str
71+
"""Username/handle candidate."""

tests/api_resources/test_chats.py

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,34 @@ class TestChats:
2626
@parametrize
2727
def test_method_create(self, client: BeeperDesktop) -> None:
2828
chat = client.chats.create(
29-
chat={"account_id": "accountID"},
29+
account_id="accountID",
3030
)
3131
assert_matches_type(ChatCreateResponse, chat, path=["response"])
3232

3333
@parametrize
3434
def test_method_create_with_all_params(self, client: BeeperDesktop) -> None:
3535
chat = client.chats.create(
36-
chat={
37-
"account_id": "accountID",
38-
"allow_invite": True,
39-
"message_text": "messageText",
40-
"mode": "create",
41-
"participant_ids": ["string"],
42-
"title": "title",
43-
"type": "single",
44-
"user": {
45-
"id": "id",
46-
"email": "email",
47-
"full_name": "fullName",
48-
"phone_number": "phoneNumber",
49-
"username": "username",
50-
},
36+
account_id="accountID",
37+
allow_invite=True,
38+
message_text="messageText",
39+
mode="create",
40+
participant_ids=["string"],
41+
title="title",
42+
type="single",
43+
user={
44+
"id": "id",
45+
"email": "email",
46+
"full_name": "fullName",
47+
"phone_number": "phoneNumber",
48+
"username": "username",
5149
},
5250
)
5351
assert_matches_type(ChatCreateResponse, chat, path=["response"])
5452

5553
@parametrize
5654
def test_raw_response_create(self, client: BeeperDesktop) -> None:
5755
response = client.chats.with_raw_response.create(
58-
chat={"account_id": "accountID"},
56+
account_id="accountID",
5957
)
6058

6159
assert response.is_closed is True
@@ -66,7 +64,7 @@ def test_raw_response_create(self, client: BeeperDesktop) -> None:
6664
@parametrize
6765
def test_streaming_response_create(self, client: BeeperDesktop) -> None:
6866
with client.chats.with_streaming_response.create(
69-
chat={"account_id": "accountID"},
67+
account_id="accountID",
7068
) as response:
7169
assert not response.is_closed
7270
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -260,36 +258,34 @@ class TestAsyncChats:
260258
@parametrize
261259
async def test_method_create(self, async_client: AsyncBeeperDesktop) -> None:
262260
chat = await async_client.chats.create(
263-
chat={"account_id": "accountID"},
261+
account_id="accountID",
264262
)
265263
assert_matches_type(ChatCreateResponse, chat, path=["response"])
266264

267265
@parametrize
268266
async def test_method_create_with_all_params(self, async_client: AsyncBeeperDesktop) -> None:
269267
chat = await async_client.chats.create(
270-
chat={
271-
"account_id": "accountID",
272-
"allow_invite": True,
273-
"message_text": "messageText",
274-
"mode": "create",
275-
"participant_ids": ["string"],
276-
"title": "title",
277-
"type": "single",
278-
"user": {
279-
"id": "id",
280-
"email": "email",
281-
"full_name": "fullName",
282-
"phone_number": "phoneNumber",
283-
"username": "username",
284-
},
268+
account_id="accountID",
269+
allow_invite=True,
270+
message_text="messageText",
271+
mode="create",
272+
participant_ids=["string"],
273+
title="title",
274+
type="single",
275+
user={
276+
"id": "id",
277+
"email": "email",
278+
"full_name": "fullName",
279+
"phone_number": "phoneNumber",
280+
"username": "username",
285281
},
286282
)
287283
assert_matches_type(ChatCreateResponse, chat, path=["response"])
288284

289285
@parametrize
290286
async def test_raw_response_create(self, async_client: AsyncBeeperDesktop) -> None:
291287
response = await async_client.chats.with_raw_response.create(
292-
chat={"account_id": "accountID"},
288+
account_id="accountID",
293289
)
294290

295291
assert response.is_closed is True
@@ -300,7 +296,7 @@ async def test_raw_response_create(self, async_client: AsyncBeeperDesktop) -> No
300296
@parametrize
301297
async def test_streaming_response_create(self, async_client: AsyncBeeperDesktop) -> None:
302298
async with async_client.chats.with_streaming_response.create(
303-
chat={"account_id": "accountID"},
299+
account_id="accountID",
304300
) as response:
305301
assert not response.is_closed
306302
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

0 commit comments

Comments
 (0)