Skip to content

Commit fe6b606

Browse files
feat(api): api update
1 parent f813329 commit fe6b606

10 files changed

Lines changed: 280 additions & 302 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

src/Chats/ChatCreateParams.php

Lines changed: 177 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
namespace BeeperDesktop\Chats;
66

7-
use BeeperDesktop\Chats\ChatCreateParams\Chat;
7+
use BeeperDesktop\Chats\ChatCreateParams\Mode;
8+
use BeeperDesktop\Chats\ChatCreateParams\Type;
9+
use BeeperDesktop\Chats\ChatCreateParams\User;
10+
use BeeperDesktop\Core\Attributes\Optional;
811
use BeeperDesktop\Core\Attributes\Required;
912
use BeeperDesktop\Core\Concerns\SdkModel;
1013
use BeeperDesktop\Core\Concerns\SdkParams;
@@ -15,10 +18,17 @@
1518
*
1619
* @see BeeperDesktop\Services\ChatsService::create()
1720
*
18-
* @phpstan-import-type ChatShape from \BeeperDesktop\Chats\ChatCreateParams\Chat
21+
* @phpstan-import-type UserShape from \BeeperDesktop\Chats\ChatCreateParams\User
1922
*
2023
* @phpstan-type ChatCreateParamsShape = array{
21-
* chat: \BeeperDesktop\Chats\ChatCreateParams\Chat|ChatShape
24+
* accountID: string,
25+
* allowInvite?: bool|null,
26+
* messageText?: string|null,
27+
* mode?: null|Mode|value-of<Mode>,
28+
* participantIDs?: list<string>|null,
29+
* title?: string|null,
30+
* type?: null|Type|value-of<Type>,
31+
* user?: null|User|UserShape,
2232
* }
2333
*/
2434
final class ChatCreateParams implements BaseModel
@@ -27,21 +37,72 @@ final class ChatCreateParams implements BaseModel
2737
use SdkModel;
2838
use SdkParams;
2939

40+
/**
41+
* Account to create or start the chat on.
42+
*/
3043
#[Required]
31-
public Chat $chat;
44+
public string $accountID;
45+
46+
/**
47+
* Whether invite-based DM creation is allowed when required by the platform. Used for mode='start'.
48+
*/
49+
#[Optional]
50+
public ?bool $allowInvite;
51+
52+
/**
53+
* Optional first message content if the platform requires it to create the chat.
54+
*/
55+
#[Optional]
56+
public ?string $messageText;
57+
58+
/**
59+
* Operation mode. Defaults to 'create' when omitted.
60+
*
61+
* @var value-of<Mode>|null $mode
62+
*/
63+
#[Optional(enum: Mode::class)]
64+
public ?string $mode;
65+
66+
/**
67+
* Required when mode='create'. User IDs to include in the new chat.
68+
*
69+
* @var list<string>|null $participantIDs
70+
*/
71+
#[Optional(list: 'string')]
72+
public ?array $participantIDs;
73+
74+
/**
75+
* Optional title for group chats when mode='create'; ignored for single chats on most platforms.
76+
*/
77+
#[Optional]
78+
public ?string $title;
79+
80+
/**
81+
* Required when mode='create'. 'single' requires exactly one participantID; 'group' supports multiple participants and optional title.
82+
*
83+
* @var value-of<Type>|null $type
84+
*/
85+
#[Optional(enum: Type::class)]
86+
public ?string $type;
87+
88+
/**
89+
* Required when mode='start'. Merged user-like contact payload used to resolve the best identifier.
90+
*/
91+
#[Optional]
92+
public ?User $user;
3293

3394
/**
3495
* `new ChatCreateParams()` is missing required properties by the API.
3596
*
3697
* To enforce required parameters use
3798
* ```
38-
* ChatCreateParams::with(chat: ...)
99+
* ChatCreateParams::with(accountID: ...)
39100
* ```
40101
*
41102
* Otherwise ensure the following setters are called
42103
*
43104
* ```
44-
* (new ChatCreateParams)->withChat(...)
105+
* (new ChatCreateParams)->withAccountID(...)
45106
* ```
46107
*/
47108
public function __construct()
@@ -54,26 +115,128 @@ public function __construct()
54115
*
55116
* You must use named parameters to construct any parameters with a default value.
56117
*
57-
* @param Chat|ChatShape $chat
118+
* @param Mode|value-of<Mode>|null $mode
119+
* @param list<string>|null $participantIDs
120+
* @param Type|value-of<Type>|null $type
121+
* @param User|UserShape|null $user
58122
*/
59123
public static function with(
60-
Chat|array $chat
124+
string $accountID,
125+
?bool $allowInvite = null,
126+
?string $messageText = null,
127+
Mode|string|null $mode = null,
128+
?array $participantIDs = null,
129+
?string $title = null,
130+
Type|string|null $type = null,
131+
User|array|null $user = null,
61132
): self {
62133
$self = new self;
63134

64-
$self['chat'] = $chat;
135+
$self['accountID'] = $accountID;
136+
137+
null !== $allowInvite && $self['allowInvite'] = $allowInvite;
138+
null !== $messageText && $self['messageText'] = $messageText;
139+
null !== $mode && $self['mode'] = $mode;
140+
null !== $participantIDs && $self['participantIDs'] = $participantIDs;
141+
null !== $title && $self['title'] = $title;
142+
null !== $type && $self['type'] = $type;
143+
null !== $user && $self['user'] = $user;
65144

66145
return $self;
67146
}
68147

69148
/**
70-
* @param Chat|ChatShape $chat
149+
* Account to create or start the chat on.
71150
*/
72-
public function withChat(
73-
Chat|array $chat
74-
): self {
151+
public function withAccountID(string $accountID): self
152+
{
153+
$self = clone $this;
154+
$self['accountID'] = $accountID;
155+
156+
return $self;
157+
}
158+
159+
/**
160+
* Whether invite-based DM creation is allowed when required by the platform. Used for mode='start'.
161+
*/
162+
public function withAllowInvite(bool $allowInvite): self
163+
{
164+
$self = clone $this;
165+
$self['allowInvite'] = $allowInvite;
166+
167+
return $self;
168+
}
169+
170+
/**
171+
* Optional first message content if the platform requires it to create the chat.
172+
*/
173+
public function withMessageText(string $messageText): self
174+
{
175+
$self = clone $this;
176+
$self['messageText'] = $messageText;
177+
178+
return $self;
179+
}
180+
181+
/**
182+
* Operation mode. Defaults to 'create' when omitted.
183+
*
184+
* @param Mode|value-of<Mode> $mode
185+
*/
186+
public function withMode(Mode|string $mode): self
187+
{
188+
$self = clone $this;
189+
$self['mode'] = $mode;
190+
191+
return $self;
192+
}
193+
194+
/**
195+
* Required when mode='create'. User IDs to include in the new chat.
196+
*
197+
* @param list<string> $participantIDs
198+
*/
199+
public function withParticipantIDs(array $participantIDs): self
200+
{
201+
$self = clone $this;
202+
$self['participantIDs'] = $participantIDs;
203+
204+
return $self;
205+
}
206+
207+
/**
208+
* Optional title for group chats when mode='create'; ignored for single chats on most platforms.
209+
*/
210+
public function withTitle(string $title): self
211+
{
212+
$self = clone $this;
213+
$self['title'] = $title;
214+
215+
return $self;
216+
}
217+
218+
/**
219+
* Required when mode='create'. 'single' requires exactly one participantID; 'group' supports multiple participants and optional title.
220+
*
221+
* @param Type|value-of<Type> $type
222+
*/
223+
public function withType(Type|string $type): self
224+
{
225+
$self = clone $this;
226+
$self['type'] = $type;
227+
228+
return $self;
229+
}
230+
231+
/**
232+
* Required when mode='start'. Merged user-like contact payload used to resolve the best identifier.
233+
*
234+
* @param User|UserShape $user
235+
*/
236+
public function withUser(User|array $user): self
237+
{
75238
$self = clone $this;
76-
$self['chat'] = $chat;
239+
$self['user'] = $user;
77240

78241
return $self;
79242
}

0 commit comments

Comments
 (0)