Skip to content

Commit af70fc9

Browse files
feat(api): add network, bridge fields to accounts
1 parent 69f6d11 commit af70fc9

File tree

6 files changed

+127
-179
lines changed

6 files changed

+127
-179
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 23
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-5a8ac7b545c48dc892e5c680303e305254921554dabee848e40a808659dbcf1e.yml
3-
openapi_spec_hash: 0103975601aac1445d3a4ef418c5d17a
4-
config_hash: 7d85c0b454fc78a59db6474c5c4d73c6
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-611aa7641fbca8cf31d626bf86f9efd3c2b92778e897ebbb25c6ea44185ed1ed.yml
3+
openapi_spec_hash: d6c0a1776048dab04f6c5625c9893c9c
4+
config_hash: 39ed0717b5f415499aaace2468346e1a

README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ The Beeper Desktop Python library provides convenient access to the Beeper Deskt
77
application. The library includes type definitions for all request params and response fields,
88
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
99

10-
It is generated with [Stainless](https://www.stainless.com/).
11-
1210
## MCP Server
1311

1412
Use the Beeper Desktop MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.
@@ -25,18 +23,24 @@ The REST API documentation can be found on [developers.beeper.com](https://devel
2523
## Installation
2624

2725
```sh
28-
# install from PyPI
29-
pip install beeper_desktop_api
26+
# install from the production repo
27+
pip install git+ssh://git@github.com/beeper/desktop-api-python.git
3028
```
3129

30+
> [!NOTE]
31+
> Once this package is [published to PyPI](https://www.stainless.com/docs/guides/publish), this will become: `pip install beeper_desktop_api`
32+
3233
## Usage
3334

3435
The full API of this library can be found in [api.md](api.md).
3536

3637
```python
38+
import os
3739
from beeper_desktop_api import BeeperDesktop
3840

39-
client = BeeperDesktop()
41+
client = BeeperDesktop(
42+
access_token=os.environ.get("BEEPER_ACCESS_TOKEN"), # This is the default and can be omitted
43+
)
4044

4145
page = client.chats.search(
4246
include_muted=True,
@@ -56,10 +60,13 @@ so that your Access Token is not stored in source control.
5660
Simply import `AsyncBeeperDesktop` instead of `BeeperDesktop` and use `await` with each API call:
5761

5862
```python
63+
import os
5964
import asyncio
6065
from beeper_desktop_api import AsyncBeeperDesktop
6166

62-
client = AsyncBeeperDesktop()
67+
client = AsyncBeeperDesktop(
68+
access_token=os.environ.get("BEEPER_ACCESS_TOKEN"), # This is the default and can be omitted
69+
)
6370

6471

6572
async def main() -> None:
@@ -83,20 +90,24 @@ By default, the async client uses `httpx` for HTTP requests. However, for improv
8390
You can enable this by installing `aiohttp`:
8491

8592
```sh
86-
# install from PyPI
87-
pip install beeper_desktop_api[aiohttp]
93+
# install from the production repo
94+
pip install 'beeper_desktop_api[aiohttp] @ git+ssh://git@github.com/beeper/desktop-api-python.git'
8895
```
8996

9097
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
9198

9299
```python
100+
import os
93101
import asyncio
94102
from beeper_desktop_api import DefaultAioHttpClient
95103
from beeper_desktop_api import AsyncBeeperDesktop
96104

97105

98106
async def main() -> None:
99107
async with AsyncBeeperDesktop(
108+
access_token=os.environ.get(
109+
"BEEPER_ACCESS_TOKEN"
110+
), # This is the default and can be omitted
100111
http_client=DefaultAioHttpClient(),
101112
) as client:
102113
page = await client.chats.search(
@@ -207,11 +218,10 @@ from beeper_desktop_api import BeeperDesktop
207218

208219
client = BeeperDesktop()
209220

210-
chat = client.chats.create(
211-
account_id="accountID",
212-
user={},
221+
client.chats.reminders.create(
222+
chat_id="!NCdzlIaMjZUmvmvyHU:beeper.com",
223+
reminder={"remind_at_ms": 0},
213224
)
214-
print(chat.user)
215225
```
216226

217227
## File uploads

src/beeper_desktop_api/resources/chats/chats.py

Lines changed: 4 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,7 @@ def with_streaming_response(self) -> ChatsResourceWithStreamingResponse:
7979
def create(
8080
self,
8181
*,
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,
82+
params: chat_create_params.Params | Omit = omit,
9083
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
9184
# The extra values given here take precedence over values defined on the client or passed to this method.
9285
extra_headers: Headers | None = None,
@@ -99,26 +92,6 @@ def create(
9992
user data (mode='start').
10093
10194
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-
12295
extra_headers: Send extra headers
12396
12497
extra_query: Add additional query parameters to the request
@@ -129,19 +102,7 @@ def create(
129102
"""
130103
return self._post(
131104
"/v1/chats",
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-
),
105+
body=maybe_transform(params, chat_create_params.ChatCreateParams),
145106
options=make_request_options(
146107
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
147108
),
@@ -422,14 +383,7 @@ def with_streaming_response(self) -> AsyncChatsResourceWithStreamingResponse:
422383
async def create(
423384
self,
424385
*,
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,
386+
params: chat_create_params.Params | Omit = omit,
433387
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
434388
# The extra values given here take precedence over values defined on the client or passed to this method.
435389
extra_headers: Headers | None = None,
@@ -442,26 +396,6 @@ async def create(
442396
user data (mode='start').
443397
444398
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-
465399
extra_headers: Send extra headers
466400
467401
extra_query: Add additional query parameters to the request
@@ -472,19 +406,7 @@ async def create(
472406
"""
473407
return await self._post(
474408
"/v1/chats",
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-
),
409+
body=await async_maybe_transform(params, chat_create_params.ChatCreateParams),
488410
options=make_request_options(
489411
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
490412
),
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
from typing_extensions import Literal
4+
35
from pydantic import Field as FieldInfo
46

57
from .._models import BaseModel
68
from .shared.user import User
79

8-
__all__ = ["Account"]
10+
__all__ = ["Account", "Bridge"]
11+
12+
13+
class Bridge(BaseModel):
14+
"""Bridge metadata for the account. Available from Beeper Desktop v.4.2.719+."""
15+
16+
id: str
17+
"""Bridge instance identifier."""
18+
19+
provider: Literal["cloud", "self-hosted", "local", "platform-sdk"]
20+
"""Bridge provider for the account."""
21+
22+
type: str
23+
"""Bridge type."""
924

1025

1126
class Account(BaseModel):
@@ -14,5 +29,11 @@ class Account(BaseModel):
1429
account_id: str = FieldInfo(alias="accountID")
1530
"""Chat account added to Beeper. Use this to route account-scoped actions."""
1631

32+
bridge: Bridge
33+
"""Bridge metadata for the account. Available from Beeper Desktop v.4.2.719+."""
34+
35+
network: str
36+
"""Human-friendly network name for the account."""
37+
1738
user: User
1839
"""User the account belongs to."""

src/beeper_desktop_api/types/chat_create_params.py

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,48 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Literal, Required, Annotated, TypedDict
5+
from typing import Union
6+
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
67

78
from .._types import SequenceNotStr
89
from .._utils import PropertyInfo
910

10-
__all__ = ["ChatCreateParams", "User"]
11+
__all__ = ["ChatCreateParams", "Params", "ParamsUnionMember0", "ParamsUnionMember0User", "ParamsUnionMember1"]
1112

1213

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

41+
mode: Required[Literal["start"]]
42+
"""Operation mode. Use 'start' to resolve a user/contact and start a direct chat."""
43+
44+
user: Required[ParamsUnionMember0User]
45+
"""Merged user-like contact payload used to resolve the best identifier."""
46+
1747
allow_invite: Annotated[bool, PropertyInfo(alias="allowInvite")]
1848
"""Whether invite-based DM creation is allowed when required by the platform.
1949
@@ -23,49 +53,28 @@ class ChatCreateParams(TypedDict, total=False):
2353
message_text: Annotated[str, PropertyInfo(alias="messageText")]
2454
"""Optional first message content if the platform requires it to create the chat."""
2555

26-
mode: Literal["create", "start"]
27-
"""Operation mode. Defaults to 'create' when omitted."""
28-
29-
participant_ids: Annotated[SequenceNotStr[str], PropertyInfo(alias="participantIDs")]
30-
"""Required when mode='create'. User IDs to include in the new chat."""
3156

32-
title: str
33-
"""
34-
Optional title for group chats when mode='create'; ignored for single chats on
35-
most platforms.
36-
"""
57+
class ParamsUnionMember1(TypedDict, total=False):
58+
account_id: Required[Annotated[str, PropertyInfo(alias="accountID")]]
59+
"""Account to create or start the chat on."""
3760

38-
type: Literal["single", "group"]
39-
"""Required when mode='create'.
61+
participant_ids: Required[Annotated[SequenceNotStr[str], PropertyInfo(alias="participantIDs")]]
62+
"""User IDs to include in the new chat."""
4063

64+
type: Required[Literal["single", "group"]]
65+
"""
4166
'single' requires exactly one participantID; 'group' supports multiple
4267
participants and optional title.
4368
"""
4469

45-
user: User
46-
"""Required when mode='start'.
47-
48-
Merged user-like contact payload used to resolve the best identifier.
49-
"""
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."""
70+
message_text: Annotated[str, PropertyInfo(alias="messageText")]
71+
"""Optional first message content if the platform requires it to create the chat."""
6072

61-
email: str
62-
"""Email candidate."""
73+
mode: Literal["create"]
74+
"""Operation mode. Defaults to 'create' when omitted."""
6375

64-
full_name: Annotated[str, PropertyInfo(alias="fullName")]
65-
"""Display name hint used for ranking only."""
76+
title: str
77+
"""Optional title for group chats; ignored for single chats on most platforms."""
6678

67-
phone_number: Annotated[str, PropertyInfo(alias="phoneNumber")]
68-
"""Phone number candidate (E.164 preferred)."""
6979

70-
username: str
71-
"""Username/handle candidate."""
80+
Params: TypeAlias = Union[ParamsUnionMember0, ParamsUnionMember1]

0 commit comments

Comments
 (0)