Skip to content

Commit cb4b3e1

Browse files
feat(api): add reactions
1 parent 6af7922 commit cb4b3e1

File tree

9 files changed

+85
-95
lines changed

9 files changed

+85
-95
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 19
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-099d55ac0e749a64dacc1706d7d8276d1acbe52103f0419393c39e8911966cfe.yml
3-
openapi_spec_hash: 70a1b1d513b62c6d6caabbbf360220b4
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-3f6555bfea11258c6e8882455360ae08202067a270313716ee15571b83ada577.yml
3+
openapi_spec_hash: 020324a708981384284f8fad8ac8c66c
44
config_hash: 48ff2d23c2ebc82bd3c15787f0041684

account.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ type Account struct {
5252
// Chat account added to Beeper. Use this to route account-scoped actions.
5353
AccountID string `json:"accountID,required"`
5454
// Display-only human-readable network name (e.g., 'WhatsApp', 'Messenger').
55+
//
56+
// Deprecated: deprecated
5557
Network string `json:"network,required"`
5658
// User the account belongs to.
5759
User shared.User `json:"user,required"`

accountcontact.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ func NewAccountContactService(opts ...option.RequestOption) (r AccountContactSer
3939
return
4040
}
4141

42-
// Search contacts on a specific account using the network's search API. Only use
43-
// for creating new chats.
42+
// Search contacts on a specific account using merged account contacts, network
43+
// search, and exact identifier lookup.
4444
func (r *AccountContactService) Search(ctx context.Context, accountID string, query AccountContactSearchParams, opts ...option.RequestOption) (res *AccountContactSearchResponse, err error) {
4545
opts = slices.Concat(r.Options, opts)
4646
if accountID == "" {

api.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,21 @@ Response Types:
4444
- <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#Chat">Chat</a>
4545
- <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatNewResponse">ChatNewResponse</a>
4646
- <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatListResponse">ChatListResponse</a>
47-
- <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatArchiveResponse">ChatArchiveResponse</a>
4847

4948
Methods:
5049

5150
- <code title="post /v1/chats">client.Chats.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatNewParams">ChatNewParams</a>) (\*<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatNewResponse">ChatNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
5251
- <code title="get /v1/chats/{chatID}">client.Chats.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, chatID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatGetParams">ChatGetParams</a>) (\*<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#Chat">Chat</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
5352
- <code title="get /v1/chats">client.Chats.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatListParams">ChatListParams</a>) (\*<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go/packages/pagination#CursorNoLimit">CursorNoLimit</a>[<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatListResponse">ChatListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
54-
- <code title="post /v1/chats/{chatID}/archive">client.Chats.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatService.Archive">Archive</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, chatID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatArchiveParams">ChatArchiveParams</a>) (\*<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatArchiveResponse">ChatArchiveResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
53+
- <code title="post /v1/chats/{chatID}/archive">client.Chats.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatService.Archive">Archive</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, chatID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatArchiveParams">ChatArchiveParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
5554
- <code title="get /v1/chats/search">client.Chats.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatService.Search">Search</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatSearchParams">ChatSearchParams</a>) (\*<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go/packages/pagination#CursorSearch">CursorSearch</a>[<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#Chat">Chat</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
5655

5756
## Reminders
5857

59-
Response Types:
60-
61-
- <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatReminderNewResponse">ChatReminderNewResponse</a>
62-
- <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatReminderDeleteResponse">ChatReminderDeleteResponse</a>
63-
6458
Methods:
6559

66-
- <code title="post /v1/chats/{chatID}/reminders">client.Chats.Reminders.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatReminderService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, chatID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatReminderNewParams">ChatReminderNewParams</a>) (\*<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatReminderNewResponse">ChatReminderNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
67-
- <code title="delete /v1/chats/{chatID}/reminders">client.Chats.Reminders.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatReminderService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, chatID <a href="https://pkg.go.dev/builtin#string">string</a>) (\*<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatReminderDeleteResponse">ChatReminderDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
60+
- <code title="post /v1/chats/{chatID}/reminders">client.Chats.Reminders.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatReminderService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, chatID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/beeper/desktop-api-go">beeperdesktopapi</a>.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatReminderNewParams">ChatReminderNewParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
61+
- <code title="delete /v1/chats/{chatID}/reminders">client.Chats.Reminders.<a href="https://pkg.go.dev/github.com/beeper/desktop-api-go#ChatReminderService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, chatID <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
6862

6963
# Messages
7064

chat.go

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ func NewChatService(opts ...option.RequestOption) (r ChatService) {
4545
return
4646
}
4747

48-
// Create a single or group chat on a specific account using participant IDs and
49-
// optional title.
48+
// Create a single/group chat (mode='create') or start a direct chat from merged
49+
// user data (mode='start').
5050
func (r *ChatService) New(ctx context.Context, body ChatNewParams, opts ...option.RequestOption) (res *ChatNewResponse, err error) {
5151
opts = slices.Concat(r.Options, opts)
5252
path := "v1/chats"
@@ -93,14 +93,15 @@ func (r *ChatService) ListAutoPaging(ctx context.Context, query ChatListParams,
9393

9494
// Archive or unarchive a chat. Set archived=true to move to archive,
9595
// archived=false to move back to inbox
96-
func (r *ChatService) Archive(ctx context.Context, chatID string, body ChatArchiveParams, opts ...option.RequestOption) (res *ChatArchiveResponse, err error) {
96+
func (r *ChatService) Archive(ctx context.Context, chatID string, body ChatArchiveParams, opts ...option.RequestOption) (err error) {
9797
opts = slices.Concat(r.Options, opts)
98+
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
9899
if chatID == "" {
99100
err = errors.New("missing required chatID parameter")
100101
return
101102
}
102103
path := fmt.Sprintf("v1/chats/%s/archive", chatID)
103-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
104+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...)
104105
return
105106
}
106107

@@ -134,6 +135,10 @@ type Chat struct {
134135
ID string `json:"id,required"`
135136
// Account ID this chat belongs to.
136137
AccountID string `json:"accountID,required"`
138+
// Display-only human-readable network name (e.g., 'WhatsApp', 'Messenger').
139+
//
140+
// Deprecated: deprecated
141+
Network string `json:"network,required"`
137142
// Chat participants information.
138143
Participants ChatParticipants `json:"participants,required"`
139144
// Display title of the chat as computed by the client/server.
@@ -160,6 +165,7 @@ type Chat struct {
160165
JSON struct {
161166
ID respjson.Field
162167
AccountID respjson.Field
168+
Network respjson.Field
163169
Participants respjson.Field
164170
Title respjson.Field
165171
Type respjson.Field
@@ -216,9 +222,15 @@ const (
216222
type ChatNewResponse struct {
217223
// Newly created chat ID.
218224
ChatID string `json:"chatID,required"`
225+
// Only returned in start mode. 'existing' means an existing chat was reused;
226+
// 'created' means a new chat was created.
227+
//
228+
// Any of "existing", "created".
229+
Status ChatNewResponseStatus `json:"status"`
219230
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
220231
JSON struct {
221232
ChatID respjson.Field
233+
Status respjson.Field
222234
ExtraFields map[string]respjson.Field
223235
raw string
224236
} `json:"-"`
@@ -230,6 +242,15 @@ func (r *ChatNewResponse) UnmarshalJSON(data []byte) error {
230242
return apijson.UnmarshalRoot(data, r)
231243
}
232244

245+
// Only returned in start mode. 'existing' means an existing chat was reused;
246+
// 'created' means a new chat was created.
247+
type ChatNewResponseStatus string
248+
249+
const (
250+
ChatNewResponseStatusExisting ChatNewResponseStatus = "existing"
251+
ChatNewResponseStatusCreated ChatNewResponseStatus = "created"
252+
)
253+
233254
type ChatListResponse struct {
234255
// Last message preview for this chat, if available.
235256
Preview shared.Message `json:"preview"`
@@ -248,26 +269,29 @@ func (r *ChatListResponse) UnmarshalJSON(data []byte) error {
248269
return apijson.UnmarshalRoot(data, r)
249270
}
250271

251-
type ChatArchiveResponse struct {
252-
// Indicates the operation completed successfully
272+
type ChatNewParams struct {
273+
253274
//
254-
// Any of true.
255-
Success bool `json:"success,required"`
256-
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
257-
JSON struct {
258-
Success respjson.Field
259-
ExtraFields map[string]respjson.Field
260-
raw string
261-
} `json:"-"`
275+
// Request body variants
276+
//
277+
278+
// This field is a request body variant, only one variant field can be set.
279+
OfObject *ChatNewParamsBodyObject `json:",inline"`
280+
// This field is a request body variant, only one variant field can be set.
281+
OfChatNewsBodyObject *ChatNewParamsBodyObject `json:",inline"`
282+
283+
paramObj
262284
}
263285

264-
// Returns the unmodified JSON received from the API
265-
func (r ChatArchiveResponse) RawJSON() string { return r.JSON.raw }
266-
func (r *ChatArchiveResponse) UnmarshalJSON(data []byte) error {
286+
func (u ChatNewParams) MarshalJSON() ([]byte, error) {
287+
return param.MarshalUnion(u, u.OfObject, u.OfChatNewsBodyObject)
288+
}
289+
func (r *ChatNewParams) UnmarshalJSON(data []byte) error {
267290
return apijson.UnmarshalRoot(data, r)
268291
}
269292

270-
type ChatNewParams struct {
293+
// The properties AccountID, ParticipantIDs, Type are required.
294+
type ChatNewParamsBodyObject struct {
271295
// Account to create the chat on.
272296
AccountID string `json:"accountID,required"`
273297
// User IDs to include in the new chat.
@@ -276,30 +300,34 @@ type ChatNewParams struct {
276300
// supports multiple participants and optional title.
277301
//
278302
// Any of "single", "group".
279-
Type ChatNewParamsType `json:"type,omitzero,required"`
303+
Type string `json:"type,omitzero,required"`
280304
// Optional first message content if the platform requires it to create the chat.
281305
MessageText param.Opt[string] `json:"messageText,omitzero"`
282306
// Optional title for group chats; ignored for single chats on most platforms.
283307
Title param.Opt[string] `json:"title,omitzero"`
308+
// Create mode. Defaults to 'create' when omitted.
309+
//
310+
// Any of "create".
311+
Mode string `json:"mode,omitzero"`
284312
paramObj
285313
}
286314

287-
func (r ChatNewParams) MarshalJSON() (data []byte, err error) {
288-
type shadow ChatNewParams
315+
func (r ChatNewParamsBodyObject) MarshalJSON() (data []byte, err error) {
316+
type shadow ChatNewParamsBodyObject
289317
return param.MarshalObject(r, (*shadow)(&r))
290318
}
291-
func (r *ChatNewParams) UnmarshalJSON(data []byte) error {
319+
func (r *ChatNewParamsBodyObject) UnmarshalJSON(data []byte) error {
292320
return apijson.UnmarshalRoot(data, r)
293321
}
294322

295-
// Chat type to create: 'single' requires exactly one participantID; 'group'
296-
// supports multiple participants and optional title.
297-
type ChatNewParamsType string
298-
299-
const (
300-
ChatNewParamsTypeSingle ChatNewParamsType = "single"
301-
ChatNewParamsTypeGroup ChatNewParamsType = "group"
302-
)
323+
func init() {
324+
apijson.RegisterFieldValidator[ChatNewParamsBodyObject](
325+
"type", "single", "group",
326+
)
327+
apijson.RegisterFieldValidator[ChatNewParamsBodyObject](
328+
"mode", "create",
329+
)
330+
}
303331

304332
type ChatGetParams struct {
305333
// Maximum number of participants to return. Use -1 for all; otherwise 0–500.

chat_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ func TestChatNewWithOptionalParams(t *testing.T) {
2727
option.WithAccessToken("My Access Token"),
2828
)
2929
_, err := client.Chats.New(context.TODO(), beeperdesktopapi.ChatNewParams{
30-
AccountID: "accountID",
31-
ParticipantIDs: []string{"string"},
32-
Type: beeperdesktopapi.ChatNewParamsTypeSingle,
33-
MessageText: beeperdesktopapi.String("messageText"),
34-
Title: beeperdesktopapi.String("title"),
30+
OfObject: &beeperdesktopapi.ChatNewParamsBodyObject{
31+
AccountID: "accountID",
32+
ParticipantIDs: []string{"string"},
33+
Type: "single",
34+
MessageText: beeperdesktopapi.String("messageText"),
35+
Mode: "create",
36+
Title: beeperdesktopapi.String("title"),
37+
},
3538
})
3639
if err != nil {
3740
var apierr *beeperdesktopapi.Error
@@ -108,7 +111,7 @@ func TestChatArchiveWithOptionalParams(t *testing.T) {
108111
option.WithBaseURL(baseURL),
109112
option.WithAccessToken("My Access Token"),
110113
)
111-
_, err := client.Chats.Archive(
114+
err := client.Chats.Archive(
112115
context.TODO(),
113116
"!NCdzlIaMjZUmvmvyHU:beeper.com",
114117
beeperdesktopapi.ChatArchiveParams{

0 commit comments

Comments
 (0)