Skip to content

Commit 0c8a0ee

Browse files
feat(api): manual updates
1 parent 1db6811 commit 0c8a0ee

File tree

3 files changed

+68
-6
lines changed

3 files changed

+68
-6
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-ee25e67fc85ccc86cedb2ca0865385709877582132103e0afa68d7b43551784a.yml
3-
openapi_spec_hash: d41fd99c9a8645a1fd69c519cd25a637
4-
config_hash: 07a9227b2e53d5bf022c964ac30d72fa
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-1b8324f05cd39e88cfc36b9b86a868b6f7e0c9e0827bb30d70a6d875c151ae52.yml
3+
openapi_spec_hash: 41410e315f6a3d0be787ece9e4fcb96a
4+
config_hash: abdcaeff62a619bdf25d727cdeacf3b0

pkg/cmd/chat.go

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,63 @@ import (
1515
"github.com/urfave/cli/v3"
1616
)
1717

18-
var chatsCreate = cli.Command{
18+
var chatsCreate = requestflag.WithInnerFlags(cli.Command{
1919
Name: "create",
2020
Usage: "Create a single/group chat (mode='create') or start a direct chat from merged\nuser data (mode='start').",
2121
Suggest: true,
2222
Flags: []cli.Flag{
2323
&requestflag.Flag[map[string]any]{
2424
Name: "chat",
25+
Required: true,
2526
BodyRoot: true,
2627
},
2728
},
2829
Action: handleChatsCreate,
2930
HideHelpCommand: true,
30-
}
31+
}, map[string][]requestflag.HasOuterFlag{
32+
"chat": {
33+
&requestflag.InnerFlag[string]{
34+
Name: "chat.account-id",
35+
Usage: "Account to create or start the chat on.",
36+
InnerField: "accountID",
37+
},
38+
&requestflag.InnerFlag[bool]{
39+
Name: "chat.allow-invite",
40+
Usage: "Whether invite-based DM creation is allowed when required by the platform. Used for mode='start'.",
41+
InnerField: "allowInvite",
42+
},
43+
&requestflag.InnerFlag[string]{
44+
Name: "chat.message-text",
45+
Usage: "Optional first message content if the platform requires it to create the chat.",
46+
InnerField: "messageText",
47+
},
48+
&requestflag.InnerFlag[string]{
49+
Name: "chat.mode",
50+
Usage: "Operation mode. Defaults to 'create' when omitted.",
51+
InnerField: "mode",
52+
},
53+
&requestflag.InnerFlag[[]string]{
54+
Name: "chat.participant-ids",
55+
Usage: "Required when mode='create'. User IDs to include in the new chat.",
56+
InnerField: "participantIDs",
57+
},
58+
&requestflag.InnerFlag[string]{
59+
Name: "chat.title",
60+
Usage: "Optional title for group chats when mode='create'; ignored for single chats on most platforms.",
61+
InnerField: "title",
62+
},
63+
&requestflag.InnerFlag[string]{
64+
Name: "chat.type",
65+
Usage: "Required when mode='create'. 'single' requires exactly one participantID; 'group' supports multiple participants and optional title.",
66+
InnerField: "type",
67+
},
68+
&requestflag.InnerFlag[map[string]any]{
69+
Name: "chat.user",
70+
Usage: "Required when mode='start'. Merged user-like contact payload used to resolve the best identifier.",
71+
InnerField: "user",
72+
},
73+
},
74+
})
3175

3276
var chatsRetrieve = cli.Command{
3377
Name: "retrieve",

pkg/cmd/chat_test.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,31 @@ import (
66
"testing"
77

88
"github.com/beeper/desktop-api-cli/internal/mocktest"
9+
"github.com/beeper/desktop-api-cli/internal/requestflag"
910
)
1011

1112
func TestChatsCreate(t *testing.T) {
1213
mocktest.TestRunMockTestWithFlags(
1314
t,
1415
"chats", "create",
15-
"--chat", "{accountID: accountID, participantIDs: [string], type: single, messageText: messageText, mode: create, title: title}",
16+
"--chat", "{accountID: accountID, allowInvite: true, messageText: messageText, mode: create, participantIDs: [string], title: title, type: single, user: {id: id, email: email, fullName: fullName, phoneNumber: phoneNumber, username: username}}",
17+
)
18+
19+
// Check that inner flags have been set up correctly
20+
requestflag.CheckInnerFlags(chatsCreate)
21+
22+
// Alternative argument passing style using inner flags
23+
mocktest.TestRunMockTestWithFlags(
24+
t,
25+
"chats", "create",
26+
"--chat.account-id", "accountID",
27+
"--chat.allow-invite=true",
28+
"--chat.message-text", "messageText",
29+
"--chat.mode", "create",
30+
"--chat.participant-ids", "[string]",
31+
"--chat.title", "title",
32+
"--chat.type", "single",
33+
"--chat.user", "{id: id, email: email, fullName: fullName, phoneNumber: phoneNumber, username: username}",
1634
)
1735
}
1836

0 commit comments

Comments
 (0)