Skip to content

Commit f8667a0

Browse files
stainless-app[bot]batuhan
authored andcommitted
feat(api): api update
1 parent 02a45b9 commit f8667a0

3 files changed

Lines changed: 77 additions & 44 deletions

File tree

.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

pkg/cmd/chat.go

Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,55 +20,77 @@ var chatsCreate = requestflag.WithInnerFlags(cli.Command{
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{
23-
&requestflag.Flag[map[string]any]{
24-
Name: "chat",
23+
&requestflag.Flag[string]{
24+
Name: "account-id",
25+
Usage: "Account to create or start the chat on.",
2526
Required: true,
26-
BodyRoot: true,
27+
BodyPath: "accountID",
28+
},
29+
&requestflag.Flag[bool]{
30+
Name: "allow-invite",
31+
Usage: "Whether invite-based DM creation is allowed when required by the platform. Used for mode='start'.",
32+
Default: true,
33+
BodyPath: "allowInvite",
34+
},
35+
&requestflag.Flag[string]{
36+
Name: "message-text",
37+
Usage: "Optional first message content if the platform requires it to create the chat.",
38+
BodyPath: "messageText",
39+
},
40+
&requestflag.Flag[string]{
41+
Name: "mode",
42+
Usage: "Operation mode. Defaults to 'create' when omitted.",
43+
BodyPath: "mode",
44+
},
45+
&requestflag.Flag[[]string]{
46+
Name: "participant-id",
47+
Usage: "Required when mode='create'. User IDs to include in the new chat.",
48+
BodyPath: "participantIDs",
49+
},
50+
&requestflag.Flag[string]{
51+
Name: "title",
52+
Usage: "Optional title for group chats when mode='create'; ignored for single chats on most platforms.",
53+
BodyPath: "title",
54+
},
55+
&requestflag.Flag[string]{
56+
Name: "type",
57+
Usage: "Required when mode='create'. 'single' requires exactly one participantID; 'group' supports multiple participants and optional title.",
58+
BodyPath: "type",
59+
},
60+
&requestflag.Flag[map[string]any]{
61+
Name: "user",
62+
Usage: "Required when mode='start'. Merged user-like contact payload used to resolve the best identifier.",
63+
BodyPath: "user",
2764
},
2865
},
2966
Action: handleChatsCreate,
3067
HideHelpCommand: true,
3168
}, map[string][]requestflag.HasOuterFlag{
32-
"chat": {
69+
"user": {
3370
&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",
71+
Name: "user.id",
72+
Usage: "Known user ID when available.",
73+
InnerField: "id",
4274
},
4375
&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",
76+
Name: "user.email",
77+
Usage: "Email candidate.",
78+
InnerField: "email",
4779
},
4880
&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",
81+
Name: "user.full-name",
82+
Usage: "Display name hint used for ranking only.",
83+
InnerField: "fullName",
5784
},
5885
&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",
86+
Name: "user.phone-number",
87+
Usage: "Phone number candidate (E.164 preferred).",
88+
InnerField: "phoneNumber",
6289
},
6390
&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",
91+
Name: "user.username",
92+
Usage: "Username/handle candidate.",
93+
InnerField: "username",
7294
},
7395
},
7496
})

pkg/cmd/chat_test.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ func TestChatsCreate(t *testing.T) {
1313
mocktest.TestRunMockTestWithFlags(
1414
t,
1515
"chats", "create",
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}}",
16+
"--account-id", "accountID",
17+
"--allow-invite=true",
18+
"--message-text", "messageText",
19+
"--mode", "create",
20+
"--participant-id", "string",
21+
"--title", "title",
22+
"--type", "single",
23+
"--user", "{id: id, email: email, fullName: fullName, phoneNumber: phoneNumber, username: username}",
1724
)
1825

1926
// Check that inner flags have been set up correctly
@@ -23,14 +30,18 @@ func TestChatsCreate(t *testing.T) {
2330
mocktest.TestRunMockTestWithFlags(
2431
t,
2532
"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}",
33+
"--account-id", "accountID",
34+
"--allow-invite=true",
35+
"--message-text", "messageText",
36+
"--mode", "create",
37+
"--participant-id", "string",
38+
"--title", "title",
39+
"--type", "single",
40+
"--user.id", "id",
41+
"--user.email", "email",
42+
"--user.full-name", "fullName",
43+
"--user.phone-number", "phoneNumber",
44+
"--user.username", "username",
3445
)
3546
}
3647

0 commit comments

Comments
 (0)