Skip to content

Commit 8b25044

Browse files
feat(api): add network, bridge fields to accounts
1 parent 44ea2d6 commit 8b25044

18 files changed

Lines changed: 661 additions & 320 deletions

File tree

.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-5a8ac7b545c48dc892e5c680303e305254921554dabee848e40a808659dbcf1e.yml
3-
openapi_spec_hash: 0103975601aac1445d3a4ef418c5d17a
4-
config_hash: 7d85c0b454fc78a59db6474c5c4d73c6
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-611aa7641fbca8cf31d626bf86f9efd3c2b92778e897ebbb25c6ea44185ed1ed.yml
3+
openapi_spec_hash: d6c0a1776048dab04f6c5625c9893c9c
4+
config_hash: 39ed0717b5f415499aaace2468346e1a

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
The Beeper Desktop PHP library provides convenient access to the Beeper Desktop REST API from any PHP 8.1.0+ application.
44

5-
It is generated with [Stainless](https://www.stainless.com/).
6-
75
## Documentation
86

97
The REST API documentation can be found on [developers.beeper.com](https://developers.beeper.com/desktop-api/).
@@ -40,7 +38,9 @@ Parameters with a default value must be set by name.
4038

4139
use BeeperDesktop\Client;
4240

43-
$client = new Client();
41+
$client = new Client(
42+
accessToken: getenv('BEEPER_ACCESS_TOKEN') ?: 'My Access Token'
43+
);
4444

4545
$page = $client->chats->search(includeMuted: true, limit: 3, type: 'single');
4646

@@ -65,7 +65,9 @@ This library provides auto-paginating iterators with each list response, so you
6565

6666
use BeeperDesktop\Client;
6767

68-
$client = new Client();
68+
$client = new Client(
69+
accessToken: getenv('BEEPER_ACCESS_TOKEN') ?: 'My Access Token'
70+
);
6971

7072
$page = $client->messages->search(
7173
accountIDs: ['local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI'],

src/Accounts/Account.php

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace BeeperDesktop\Accounts;
66

7+
use BeeperDesktop\Accounts\Account\Bridge;
78
use BeeperDesktop\Core\Attributes\Required;
89
use BeeperDesktop\Core\Concerns\SdkModel;
910
use BeeperDesktop\Core\Contracts\BaseModel;
@@ -12,9 +13,15 @@
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
*/
1926
final 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
*

src/Accounts/Account/Bridge.php

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace BeeperDesktop\Accounts\Account;
6+
7+
use BeeperDesktop\Accounts\Account\Bridge\Provider;
8+
use BeeperDesktop\Core\Attributes\Required;
9+
use BeeperDesktop\Core\Concerns\SdkModel;
10+
use BeeperDesktop\Core\Contracts\BaseModel;
11+
12+
/**
13+
* Bridge metadata for the account. Available from Beeper Desktop v.4.2.719+.
14+
*
15+
* @phpstan-type BridgeShape = array{
16+
* id: string, provider: Provider|value-of<Provider>, type: string
17+
* }
18+
*/
19+
final class Bridge implements BaseModel
20+
{
21+
/** @use SdkModel<BridgeShape> */
22+
use SdkModel;
23+
24+
/**
25+
* Bridge instance identifier.
26+
*/
27+
#[Required]
28+
public string $id;
29+
30+
/**
31+
* Bridge provider for the account.
32+
*
33+
* @var value-of<Provider> $provider
34+
*/
35+
#[Required(enum: Provider::class)]
36+
public string $provider;
37+
38+
/**
39+
* Bridge type.
40+
*/
41+
#[Required]
42+
public string $type;
43+
44+
/**
45+
* `new Bridge()` is missing required properties by the API.
46+
*
47+
* To enforce required parameters use
48+
* ```
49+
* Bridge::with(id: ..., provider: ..., type: ...)
50+
* ```
51+
*
52+
* Otherwise ensure the following setters are called
53+
*
54+
* ```
55+
* (new Bridge)->withID(...)->withProvider(...)->withType(...)
56+
* ```
57+
*/
58+
public function __construct()
59+
{
60+
$this->initialize();
61+
}
62+
63+
/**
64+
* Construct an instance from the required parameters.
65+
*
66+
* You must use named parameters to construct any parameters with a default value.
67+
*
68+
* @param Provider|value-of<Provider> $provider
69+
*/
70+
public static function with(
71+
string $id,
72+
Provider|string $provider,
73+
string $type
74+
): self {
75+
$self = new self;
76+
77+
$self['id'] = $id;
78+
$self['provider'] = $provider;
79+
$self['type'] = $type;
80+
81+
return $self;
82+
}
83+
84+
/**
85+
* Bridge instance identifier.
86+
*/
87+
public function withID(string $id): self
88+
{
89+
$self = clone $this;
90+
$self['id'] = $id;
91+
92+
return $self;
93+
}
94+
95+
/**
96+
* Bridge provider for the account.
97+
*
98+
* @param Provider|value-of<Provider> $provider
99+
*/
100+
public function withProvider(Provider|string $provider): self
101+
{
102+
$self = clone $this;
103+
$self['provider'] = $provider;
104+
105+
return $self;
106+
}
107+
108+
/**
109+
* Bridge type.
110+
*/
111+
public function withType(string $type): self
112+
{
113+
$self = clone $this;
114+
$self['type'] = $type;
115+
116+
return $self;
117+
}
118+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace BeeperDesktop\Accounts\Account\Bridge;
6+
7+
/**
8+
* Bridge provider for the account.
9+
*/
10+
enum Provider: string
11+
{
12+
case CLOUD = 'cloud';
13+
14+
case SELF_HOSTED = 'self-hosted';
15+
16+
case LOCAL = 'local';
17+
18+
case PLATFORM_SDK = 'platform-sdk';
19+
}

0 commit comments

Comments
 (0)