44
55namespace BeeperDesktop \Accounts ;
66
7+ use BeeperDesktop \Accounts \Account \Bridge ;
78use BeeperDesktop \Core \Attributes \Required ;
89use BeeperDesktop \Core \Concerns \SdkModel ;
910use BeeperDesktop \Core \Contracts \BaseModel ;
1213/**
1314 * A chat account added to Beeper.
1415 *
16+ * @phpstan-import-type BridgeShape from \BeeperDesktop\Accounts\Account\Bridge
1517 * @phpstan-import-type UserShape from \BeeperDesktop\User
1618 *
17- * @phpstan-type AccountShape = array{accountID: string, user: User|UserShape}
19+ * @phpstan-type AccountShape = array{
20+ * accountID: string,
21+ * bridge: Bridge|BridgeShape,
22+ * network: string,
23+ * user: User|UserShape,
24+ * }
1825 */
1926final class Account implements BaseModel
2027{
@@ -27,6 +34,18 @@ final class Account implements BaseModel
2734 #[Required]
2835 public string $ accountID ;
2936
37+ /**
38+ * Bridge metadata for the account. Available from Beeper Desktop v.4.2.719+.
39+ */
40+ #[Required]
41+ public Bridge $ bridge ;
42+
43+ /**
44+ * Human-friendly network name for the account.
45+ */
46+ #[Required]
47+ public string $ network ;
48+
3049 /**
3150 * User the account belongs to.
3251 */
@@ -38,13 +57,17 @@ final class Account implements BaseModel
3857 *
3958 * To enforce required parameters use
4059 * ```
41- * Account::with(accountID: ..., user: ...)
60+ * Account::with(accountID: ..., bridge: ..., network: ..., user: ...)
4261 * ```
4362 *
4463 * Otherwise ensure the following setters are called
4564 *
4665 * ```
47- * (new Account)->withAccountID(...)->withUser(...)
66+ * (new Account)
67+ * ->withAccountID(...)
68+ * ->withBridge(...)
69+ * ->withNetwork(...)
70+ * ->withUser(...)
4871 * ```
4972 */
5073 public function __construct ()
@@ -57,13 +80,20 @@ public function __construct()
5780 *
5881 * You must use named parameters to construct any parameters with a default value.
5982 *
83+ * @param Bridge|BridgeShape $bridge
6084 * @param User|UserShape $user
6185 */
62- public static function with (string $ accountID , User |array $ user ): self
63- {
86+ public static function with (
87+ string $ accountID ,
88+ Bridge |array $ bridge ,
89+ string $ network ,
90+ User |array $ user
91+ ): self {
6492 $ self = new self ;
6593
6694 $ self ['accountID ' ] = $ accountID ;
95+ $ self ['bridge ' ] = $ bridge ;
96+ $ self ['network ' ] = $ network ;
6797 $ self ['user ' ] = $ user ;
6898
6999 return $ self ;
@@ -80,6 +110,30 @@ public function withAccountID(string $accountID): self
80110 return $ self ;
81111 }
82112
113+ /**
114+ * Bridge metadata for the account. Available from Beeper Desktop v.4.2.719+.
115+ *
116+ * @param Bridge|BridgeShape $bridge
117+ */
118+ public function withBridge (Bridge |array $ bridge ): self
119+ {
120+ $ self = clone $ this ;
121+ $ self ['bridge ' ] = $ bridge ;
122+
123+ return $ self ;
124+ }
125+
126+ /**
127+ * Human-friendly network name for the account.
128+ */
129+ public function withNetwork (string $ network ): self
130+ {
131+ $ self = clone $ this ;
132+ $ self ['network ' ] = $ network ;
133+
134+ return $ self ;
135+ }
136+
83137 /**
84138 * User the account belongs to.
85139 *
0 commit comments