Skip to content

Commit 1c754b3

Browse files
feat(api): api update
1 parent 1c4d0e7 commit 1c754b3

257 files changed

Lines changed: 19590 additions & 6969 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*.php diff=php
2+
3+
/.github export-ignore
4+
/bin export-ignore
5+
/scripts export-ignore
6+
/tests export-ignore
7+
8+
/.gitattributes export-ignore
9+
/.gitignore export-ignore
10+
/.php-cs-fixer.dist.php export-ignore
11+
/.phpactor.json export-ignore
12+
/.release-please-manifest.json export-ignore
13+
/.stats.yml export-ignore
14+
/phpstan.dist.neon export-ignore
15+
/phpunit.xml.dist export-ignore
16+
/release-please-config.json export-ignore

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
2121

2222
steps:
23-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v6
2424

2525
- name: Set up PHP
2626
uses: 'shivammathur/setup-php@v2'
@@ -38,7 +38,7 @@ jobs:
3838
runs-on: ${{ github.repository == 'stainless-sdks/beeper-desktop-api-php' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
3939
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
4040
steps:
41-
- uses: actions/checkout@v4
41+
- uses: actions/checkout@v6
4242

4343
- name: Set up PHP
4444
uses: 'shivammathur/setup-php@v2'

.github/workflows/publish-packagist.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release Doctor
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
8+
jobs:
9+
release_doctor:
10+
name: release doctor
11+
runs-on: ubuntu-latest
12+
if: github.repository == 'beeper/desktop-api-php' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
13+
14+
steps:
15+
- uses: actions/checkout@v6
16+
17+
- name: Check release environment
18+
run: |
19+
bash ./bin/check-release-environment
20+
env:
21+
PACKAGIST_USERNAME: ${{ secrets.BEEPER_DESKTOP_PACKAGIST_USERNAME || secrets.PACKAGIST_USERNAME }}
22+
PACKAGIST_SAFE_KEY: ${{ secrets.BEEPER_DESKTOP_PACKAGIST_SAFE_KEY || secrets.PACKAGIST_SAFE_KEY }}

.gitignore

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
*.swo
2-
*.swp
1+
docs/
32
.idea/
43
.php-cs-fixer.cache
54
.php-cs-fixer.php
6-
.phpdoc/
75
.phpunit.cache
8-
composer.lock
96
phpunit.xml
107
playground/
8+
*.swo
9+
*.swp
1110
vendor/
11+
12+
# do not edit! excludes generated files used internally
13+
.artifacts/

.php-cs-fixer.dist.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
use PhpCsFixer\Finder;
55
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
66

7-
return (new Config())
7+
ini_set('memory_limit', -1);
8+
9+
return (new Config)
810
->setParallelConfig(ParallelConfigFactory::detect())
911
->setFinder(Finder::create()->in([__DIR__.'/src', __DIR__.'/tests']))
1012
->setRules([

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 13
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-b81d5fe4f2baa8712e836253bbe1b2dac923e8cae22c8354725a7bbb80ac28bb.yml
3-
openapi_spec_hash: 147d897197c083303459f0973895e69f
4-
config_hash: 7069b7e0f261442a13c7367bdc04f880
1+
configured_endpoints: 23
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-774bb08472b6bb14c280fe5b767925675516b5c8ccc0b89b5abd7ac7bc30fe5a.yml
3+
openapi_spec_hash: ddd1ce1f334b45206ac008b0f5296842
4+
config_hash: b5ac0c1579dfe6257bcdb84cfd1002fc

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2025 beeperdesktop
1+
Copyright 2026 beeperdesktop
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

README.md

Lines changed: 84 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
# Beeper Desktop PHP API library
22

3-
> [!NOTE]
4-
> The Beeper Desktop PHP API Library is currently in **beta** and we're excited for you to experiment with it!
5-
>
6-
> This library has not yet been exhaustively tested in production environments and may be missing some features you'd expect in a stable release. As we continue development, there may be breaking changes that require updates to your code.
7-
>
8-
> **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/beeper/beeper-desktop-api-php/issues/new).
9-
103
The Beeper Desktop PHP library provides convenient access to the Beeper Desktop REST API from any PHP 8.1.0+ application.
114

12-
It is generated with [Stainless](https://www.stainless.com/).
13-
145
## Documentation
156

16-
The REST API documentation can be found on [www.beeper.com](https://www.beeper.com/desktop-api).
7+
The REST API documentation can be found on [developers.beeper.com](https://developers.beeper.com/desktop-api/).
178

189
## Installation
1910

11+
To use this package, install via Composer by adding the following to your application's `composer.json`:
12+
2013
<!-- x-release-please-start-version -->
2114

22-
```
23-
composer require "beeper/beeper-desktop-api 0.0.1"
15+
```json
16+
{
17+
"repositories": [
18+
{
19+
"type": "vcs",
20+
"url": "git@github.com:beeper/desktop-api-php.git"
21+
}
22+
],
23+
"require": {
24+
"beeper/desktop-api-php": "dev-main"
25+
}
26+
}
2427
```
2528

2629
<!-- x-release-please-end -->
@@ -36,10 +39,11 @@ Parameters with a default value must be set by name.
3639
use BeeperDesktop\Client;
3740

3841
$client = new Client(
39-
accessToken: getenv("BEEPER_ACCESS_TOKEN") ?: "My Access Token"
42+
accessToken: getenv('BEEPER_ACCESS_TOKEN') ?: 'My Access Token'
4043
);
4144

42-
$page = $client->chats->find();
45+
$page = $client->chats->search(includeMuted: true, limit: 3, type: 'single');
46+
4347
var_dump($page->id);
4448
```
4549

@@ -50,63 +54,97 @@ and named parameters to initialize value objects.
5054

5155
However, builders are also provided `(new Dog)->withName("Joey")`.
5256

57+
### Pagination
58+
59+
List methods in the Beeper Desktop API are paginated.
60+
61+
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
62+
63+
```php
64+
<?php
65+
66+
use BeeperDesktop\Client;
67+
68+
$client = new Client(
69+
accessToken: getenv('BEEPER_ACCESS_TOKEN') ?: 'My Access Token'
70+
);
71+
72+
$page = $client->messages->search(
73+
accountIDs: ['local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI'],
74+
limit: 10,
75+
query: 'deployment',
76+
);
77+
78+
var_dump($page);
79+
80+
// fetch items from the current page
81+
foreach ($page->getItems() as $item) {
82+
var_dump($item->id);
83+
}
84+
// make additional network requests to fetch items from all pages, including and after the current page
85+
foreach ($page->pagingEachItem() as $item) {
86+
var_dump($item->id);
87+
}
88+
```
89+
5390
### Handling errors
5491

55-
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `BeeperDesktop\Errors\APIError` will be thrown:
92+
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `BeeperDesktop\Core\Exceptions\APIException` will be thrown:
5693

5794
```php
5895
<?php
5996

60-
use BeeperDesktop\Errors\APIConnectionError;
97+
use BeeperDesktop\Core\Exceptions\APIConnectionException;
98+
use BeeperDesktop\Core\Exceptions\RateLimitException;
99+
use BeeperDesktop\Core\Exceptions\APIStatusException;
61100

62101
try {
63-
$sendResponse = $client->messages->send(chatID: "!invalid-chat-id");
64-
} catch (APIConnectionError $e) {
102+
$accounts = $client->accounts->list();
103+
} catch (APIConnectionException $e) {
65104
echo "The server could not be reached", PHP_EOL;
66105
var_dump($e->getPrevious());
67-
} catch (RateLimitError $_) {
106+
} catch (RateLimitException $e) {
68107
echo "A 429 status code was received; we should back off a bit.", PHP_EOL;
69-
} catch (APIStatusError $e) {
108+
} catch (APIStatusException $e) {
70109
echo "Another non-200-range status code was received", PHP_EOL;
71110
echo $e->getMessage();
72111
}
73112
```
74113

75114
Error codes are as follows:
76115

77-
| Cause | Error Type |
78-
| ---------------- | -------------------------- |
79-
| HTTP 400 | `BadRequestError` |
80-
| HTTP 401 | `AuthenticationError` |
81-
| HTTP 403 | `PermissionDeniedError` |
82-
| HTTP 404 | `NotFoundError` |
83-
| HTTP 409 | `ConflictError` |
84-
| HTTP 422 | `UnprocessableEntityError` |
85-
| HTTP 429 | `RateLimitError` |
86-
| HTTP >= 500 | `InternalServerError` |
87-
| Other HTTP error | `APIStatusError` |
88-
| Timeout | `APITimeoutError` |
89-
| Network error | `APIConnectionError` |
116+
| Cause | Error Type |
117+
| ---------------- | ------------------------------ |
118+
| HTTP 400 | `BadRequestException` |
119+
| HTTP 401 | `AuthenticationException` |
120+
| HTTP 403 | `PermissionDeniedException` |
121+
| HTTP 404 | `NotFoundException` |
122+
| HTTP 409 | `ConflictException` |
123+
| HTTP 422 | `UnprocessableEntityException` |
124+
| HTTP 429 | `RateLimitException` |
125+
| HTTP >= 500 | `InternalServerException` |
126+
| Other HTTP error | `APIStatusException` |
127+
| Timeout | `APITimeoutException` |
128+
| Network error | `APIConnectionException` |
90129

91130
### Retries
92131

93-
Certain errors will be automatically retried 3 times by default, with a short exponential backoff.
132+
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
94133

95134
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.
96135

97-
You can use the `max_retries` option to configure or disable this:
136+
You can use the `maxRetries` option to configure or disable this:
98137

99138
```php
100139
<?php
101140

102141
use BeeperDesktop\Client;
103-
use BeeperDesktop\RequestOptions;
104142

105143
// Configure the default for all requests:
106-
$client = new Client(maxRetries: 0);
144+
$client = new Client(requestOptions: ['maxRetries' => 0]);
107145

108146
// Or, configure per-request:
109-
$result = $client->accounts->list(new RequestOptions(maxRetries: 5));
147+
$result = $client->accounts->list(requestOptions: ['maxRetries' => 5]);
110148
```
111149

112150
## Advanced concepts
@@ -117,22 +155,18 @@ $result = $client->accounts->list(new RequestOptions(maxRetries: 5));
117155

118156
You can send undocumented parameters to any endpoint, and read undocumented response properties, like so:
119157

120-
Note: the `extra_` parameters of the same name overrides the documented parameters.
158+
Note: the `extra*` parameters of the same name overrides the documented parameters.
121159

122160
```php
123161
<?php
124162

125-
use BeeperDesktop\RequestOptions;
126-
127-
$accountsResponse = $client->accounts->list(
128-
new RequestOptions(
129-
extraQueryParams: ["my_query_parameter" => "value"],
130-
extraBodyParams: ["my_body_parameter" => "value"],
131-
extraHeaders: ["my-header" => "value"],
132-
),
163+
$accounts = $client->accounts->list(
164+
requestOptions: [
165+
'extraQueryParams' => ['my_query_parameter' => 'value'],
166+
'extraBodyParams' => ['my_body_parameter' => 'value'],
167+
'extraHeaders' => ['my-header' => 'value'],
168+
],
133169
);
134-
135-
var_dump($accountsResponse["my_undocumented_property"]);
136170
```
137171

138172
#### Undocumented request params
@@ -167,4 +201,4 @@ PHP 8.1.0 or higher.
167201

168202
## Contributing
169203

170-
See [the contributing documentation](https://github.com/beeper/beeper-desktop-api-php/tree/main/CONTRIBUTING.md).
204+
See [the contributing documentation](https://github.com/beeper/desktop-api-php/tree/main/CONTRIBUTING.md).

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ or products provided by Beeper Desktop, please follow the respective company's s
2020

2121
### Beeper Desktop Terms and Policies
2222

23-
Please contact help@beeper.com for any questions or concerns regarding the security of our services.
23+
Please contact security@beeper.com for any questions or concerns regarding the security of our services.
2424

2525
---
2626

0 commit comments

Comments
 (0)