Skip to content

Commit 720439a

Browse files
authored
Merge pull request #915 from php-api-clients/GitHub/from-1.1.4-ed5550c2efb9457d295e9fdc8af6d2c7-from-1.1.4-ed5550c2efb9457d295e9fdc8af6d2c7
2 parents cf1f165 + 6c2175c commit 720439a

File tree

17 files changed

+253
-61
lines changed

17 files changed

+253
-61
lines changed

clients/GitHub/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,6 +2192,26 @@ $client->operations()->activity()->getThread( thread_id: 9,
21922192
You can find more about this operation over at the [API method documentation](https://docs.github.com/rest/activity/notifications#get-a-thread).
21932193

21942194

2195+
### activity/mark-thread-as-done
2196+
2197+
Mark a thread as done
2198+
2199+
Using the `call` method:
2200+
```php
2201+
$client->call('DELETE /notifications/threads/{thread_id}', [
2202+
'thread_id' => 9,
2203+
]);
2204+
```
2205+
2206+
Operations method:
2207+
```php
2208+
$client->operations()->activity()->markThreadAsDone( thread_id: 9,
2209+
);
2210+
```
2211+
2212+
You can find more about this operation over at the [API method documentation](https://docs.github.com/rest/activity/notifications#mark-a-thread-as-done).
2213+
2214+
21952215
### activity/mark-thread-as-read
21962216

21972217
Mark a thread as read

clients/GitHub/etc/openapi-client-generator.state

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"specHash": "d934eed2382f2e3ae89ee32d3f556f88",
2+
"specHash": "ed5550c2efb9457d295e9fdc8af6d2c7",
33
"generatedFiles": {
44
"files": [
55
{
@@ -5760,7 +5760,7 @@
57605760
},
57615761
{
57625762
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Operation\/Activity.php",
5763-
"hash": "9e09768fd10f79e669ca84551ce05b13"
5763+
"hash": "46703b4491236bb2c9d2833e5fd08d41"
57645764
},
57655765
{
57665766
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Operation\/Gists.php",
@@ -5820,7 +5820,7 @@
58205820
},
58215821
{
58225822
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Operation\/Repos.php",
5823-
"hash": "b325ece86abb6889940ad14b2a0d9cbe"
5823+
"hash": "29f2ee9b73113f29b3dd608e30611b5c"
58245824
},
58255825
{
58265826
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Operation\/Billing.php",
@@ -22840,11 +22840,11 @@
2284022840
},
2284122841
{
2284222842
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Operation\/Repos\/GetRelease.php",
22843-
"hash": "77c0df99f9ec66b9bc69555e288acd9a"
22843+
"hash": "59e713147834b00917bd836e18b2a0f8"
2284422844
},
2284522845
{
2284622846
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Operator\/Repos\/GetRelease.php",
22847-
"hash": "a795e9d5080ae4065b9d573395b0646f"
22847+
"hash": "93c72ba70124239391b48c7449bd028f"
2284822848
},
2284922849
{
2285022850
"name": ".\/clients\/GitHub\/etc\/..\/\/tests\/\/Internal\/Operation\/Repos\/GetReleaseTest.php",
@@ -26424,7 +26424,7 @@
2642426424
},
2642526425
{
2642626426
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Get\/Repos.php",
26427-
"hash": "f1304f5e15e4c86b5b8a3ce624c99048"
26427+
"hash": "c88f4b78f81bbfeda2b1ff10f06c02e9"
2642826428
},
2642926429
{
2643026430
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Get\/Users.php",
@@ -26772,7 +26772,7 @@
2677226772
},
2677326773
{
2677426774
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Delete\/Activity.php",
26775-
"hash": "b5800edc0ce3cea2e75b461edc5bb945"
26775+
"hash": "cc518afdc9f432281102360dc30acf09"
2677626776
},
2677726777
{
2677826778
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Delete\/Orgs.php",
@@ -26920,7 +26920,7 @@
2692026920
},
2692126921
{
2692226922
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Get\/Six.php",
26923-
"hash": "fa2bdbb8035a1b940cc7c023119de3e3"
26923+
"hash": "8d552e2346dcbf0cd1d6e3458b03fda0"
2692426924
},
2692526925
{
2692626926
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Get\/Seven.php",
@@ -27044,7 +27044,7 @@
2704427044
},
2704527045
{
2704627046
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Delete\/Four.php",
27047-
"hash": "fef6b7c9d8e8a4a11c8f69001c625769"
27047+
"hash": "9d7447c34c1bfc0f5846fbdf721cb3bf"
2704827048
},
2704927049
{
2705027050
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Delete\/Five.php",
@@ -27120,11 +27120,11 @@
2712027120
},
2712127121
{
2712227122
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Routers.php",
27123-
"hash": "a402d7f5164236048b6e63c33aeb8829"
27123+
"hash": "4de6027b2dfe9d87873f4e58b746b608"
2712427124
},
2712527125
{
2712627126
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Operators.php",
27127-
"hash": "4242cb30e69e8a9cf8eacc005c4834cf"
27127+
"hash": "310c433f89e61b19a0af102c2dd27242"
2712827128
},
2712927129
{
2713027130
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Hydrator\/Operation\/Root.php",
@@ -29780,11 +29780,11 @@
2978029780
},
2978129781
{
2978229782
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/PHPStan\/ClientCallReturnTypes.php",
29783-
"hash": "f0424d1d9a1c4bb18ffc2284e2b13871"
29783+
"hash": "650329959f8e800ee206236de033be90"
2978429784
},
2978529785
{
2978629786
"name": ".\/clients\/GitHub\/etc\/..\/\/tests\/\/Types\/ClientCallReturnTypes.php",
29787-
"hash": "855a6f905b32db01cb0ed2b1f6a20d48"
29787+
"hash": "5650b17f152d0578bf98f5be878ec961"
2978829788
},
2978929789
{
2979029790
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/..\/etc\/phpstan-extension.neon",
@@ -30625,6 +30625,14 @@
3062530625
{
3062630626
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Schema\/AliasAbstract\/Tiet1558BE01\/Tiet18FBFF80\/Tiet13044ADE\/TietAA645731.php",
3062730627
"hash": "a0d57de6922911c867029ef26f642be4"
30628+
},
30629+
{
30630+
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Operation\/Activity\/MarkThreadAsDone.php",
30631+
"hash": "701245fe0d8d4ecd34a23dfeab814968"
30632+
},
30633+
{
30634+
"name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Operator\/Activity\/MarkThreadAsDone.php",
30635+
"hash": "9334b59da8c3c3784450f140258fb92f"
3062830636
}
3062930637
]
3063030638
},
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ApiClients\Client\GitHub\Internal\Operation\Activity;
6+
7+
use ApiClients\Tools\OpenApiClient\Utils\Response\WithoutBody;
8+
use Psr\Http\Message\RequestInterface;
9+
use Psr\Http\Message\ResponseInterface;
10+
use RingCentral\Psr7\Request;
11+
use RuntimeException;
12+
13+
use function str_replace;
14+
15+
final class MarkThreadAsDone
16+
{
17+
public const OPERATION_ID = 'activity/mark-thread-as-done';
18+
public const OPERATION_MATCH = 'DELETE /notifications/threads/{thread_id}';
19+
/**The unique identifier of the notification thread. This corresponds to the value returned in the `id` field when you retrieve notifications (for example with the [`GET /notifications` operation](https://docs.github.com/rest/activity/notifications#list-notifications-for-the-authenticated-user)). **/
20+
private int $threadId;
21+
22+
public function __construct(int $threadId)
23+
{
24+
$this->threadId = $threadId;
25+
}
26+
27+
public function createRequest(): RequestInterface
28+
{
29+
return new Request('DELETE', str_replace(['{thread_id}'], [$this->threadId], '/notifications/threads/{thread_id}'));
30+
}
31+
32+
public function createResponse(ResponseInterface $response): WithoutBody
33+
{
34+
$code = $response->getStatusCode();
35+
switch ($code) {
36+
/**
37+
* No content
38+
**/
39+
case 204:
40+
return new WithoutBody(204, []);
41+
}
42+
43+
throw new RuntimeException('Unable to find matching response code and content type');
44+
}
45+
}

clients/GitHub/src/Internal/Operation/Repos/GetRelease.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function createResponse(ResponseInterface $response): Schema\Release|With
5050
$body = json_decode($response->getBody()->getContents(), true);
5151
switch ($code) {
5252
/**
53-
* **Note:** This returns an `upload_url` key corresponding to the endpoint for uploading release assets. This key is a [hypermedia resource](https://docs.github.com/rest/overview/resources-in-the-rest-api#hypermedia).
53+
* **Note:** This returns an `upload_url` key corresponding to the endpoint for uploading release assets. This key is a hypermedia resource. For more information, see "[Getting started with the REST API](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#hypermedia)."
5454
**/
5555
case 200:
5656
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\Release::SCHEMA_JSON, \cebe\openapi\spec\Schema::class));
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ApiClients\Client\GitHub\Internal\Operator\Activity;
6+
7+
use ApiClients\Contracts\HTTP\Headers\AuthenticationInterface;
8+
use ApiClients\Tools\OpenApiClient\Utils\Response\WithoutBody;
9+
use Psr\Http\Message\ResponseInterface;
10+
use React\Http\Browser;
11+
use Rx\Observable;
12+
13+
use function React\Async\await;
14+
use function WyriHaximus\React\awaitObservable;
15+
16+
final readonly class MarkThreadAsDone
17+
{
18+
public const OPERATION_ID = 'activity/mark-thread-as-done';
19+
public const OPERATION_MATCH = 'DELETE /notifications/threads/{thread_id}';
20+
21+
public function __construct(private Browser $browser, private AuthenticationInterface $authentication)
22+
{
23+
}
24+
25+
public function call(int $threadId): WithoutBody
26+
{
27+
$operation = new \ApiClients\Client\GitHub\Internal\Operation\Activity\MarkThreadAsDone($threadId);
28+
$request = $operation->createRequest();
29+
$result = await($this->browser->request($request->getMethod(), (string) $request->getUri(), $request->withHeader('Authorization', $this->authentication->authHeader())->getHeaders(), (string) $request->getBody())->then(static function (ResponseInterface $response) use ($operation): WithoutBody {
30+
return $operation->createResponse($response);
31+
}));
32+
if ($result instanceof Observable) {
33+
$result = awaitObservable($result);
34+
}
35+
36+
return $result;
37+
}
38+
}

clients/GitHub/src/Internal/Operator/Repos/GetRelease.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public function __construct(private Browser $browser, private AuthenticationInte
2525
{
2626
}
2727

28-
/** @return */
2928
public function call(string $owner, string $repo, int $releaseId): Release|WithoutBody
3029
{
3130
$operation = new \ApiClients\Client\GitHub\Internal\Operation\Repos\GetRelease($this->responseSchemaValidator, $this->hydrator, $owner, $repo, $releaseId);

clients/GitHub/src/Internal/Operators.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ final class Operators
106106
private Internal\Operator\Activity\ListNotificationsForAuthenticatedUserListing|null $activity👷ListNotificationsForAuthenticatedUserListing = null;
107107
private Internal\Operator\Activity\MarkNotificationsAsRead|null $activity👷MarkNotificationsAsRead = null;
108108
private Internal\Operator\Activity\GetThread|null $activity👷GetThread = null;
109+
private Internal\Operator\Activity\MarkThreadAsDone|null $activity👷MarkThreadAsDone = null;
109110
private Internal\Operator\Activity\MarkThreadAsRead|null $activity👷MarkThreadAsRead = null;
110111
private Internal\Operator\Activity\GetThreadSubscriptionForAuthenticatedUser|null $activity👷GetThreadSubscriptionForAuthenticatedUser = null;
111112
private Internal\Operator\Activity\SetThreadSubscription|null $activity👷SetThreadSubscription = null;
@@ -1969,6 +1970,15 @@ public function activity👷GetThread(): Internal\Operator\Activity\GetThread
19691970
return $this->activity👷GetThread;
19701971
}
19711972

1973+
public function activity👷MarkThreadAsDone(): Internal\Operator\Activity\MarkThreadAsDone
1974+
{
1975+
if ($this->activity👷MarkThreadAsDone instanceof Internal\Operator\Activity\MarkThreadAsDone === false) {
1976+
$this->activity👷MarkThreadAsDone = new Internal\Operator\Activity\MarkThreadAsDone($this->browser, $this->authentication);
1977+
}
1978+
1979+
return $this->activity👷MarkThreadAsDone;
1980+
}
1981+
19721982
public function activity👷MarkThreadAsRead(): Internal\Operator\Activity\MarkThreadAsRead
19731983
{
19741984
if ($this->activity👷MarkThreadAsRead instanceof Internal\Operator\Activity\MarkThreadAsRead === false) {

clients/GitHub/src/Internal/Router/Delete/Activity.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ public function __construct(private SchemaValidator $requestSchemaValidator, pri
1919
{
2020
}
2121

22+
public function markThreadAsDone(array $params): WithoutBody
23+
{
24+
$arguments = [];
25+
if (array_key_exists('thread_id', $params) === false) {
26+
throw new InvalidArgumentException('Missing mandatory field: thread_id');
27+
}
28+
29+
$arguments['thread_id'] = $params['thread_id'];
30+
unset($params['thread_id']);
31+
$operator = new Internal\Operator\Activity\MarkThreadAsDone($this->browser, $this->authentication);
32+
33+
return $operator->call($arguments['thread_id']);
34+
}
35+
2236
/** @return */
2337
public function deleteThreadSubscription(array $params): WithoutBody
2438
{

clients/GitHub/src/Internal/Router/Delete/Four.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function __construct(private Routers $routers)
1616
{
1717
}
1818

19+
/** @return |\ApiClients\Tools\OpenApiClient\Utils\Response\WithoutBody */
1920
public function call(string $call, array $params, array $pathChunks): WithoutBody|BasicError|Json
2021
{
2122
if ($pathChunks[0] === '') {
@@ -47,6 +48,14 @@ public function call(string $call, array $params, array $pathChunks): WithoutBod
4748
}
4849
}
4950
}
51+
} elseif ($pathChunks[1] === 'notifications') {
52+
if ($pathChunks[2] === 'threads') {
53+
if ($pathChunks[3] === '{thread_id}') {
54+
if ($call === 'DELETE /notifications/threads/{thread_id}') {
55+
return $this->routers->internal🔀Router🔀Delete🔀Activity()->markThreadAsDone($params);
56+
}
57+
}
58+
}
5059
} elseif ($pathChunks[1] === 'orgs') {
5160
if ($pathChunks[2] === '{org}') {
5261
if ($pathChunks[3] === 'interaction-limits') {

clients/GitHub/src/Internal/Router/Get/Repos.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,6 @@ public function getLatestRelease(array $params): Release
17301730
return $operator->call($arguments['owner'], $arguments['repo']);
17311731
}
17321732

1733-
/** @return */
17341733
public function getRelease(array $params): Release|WithoutBody
17351734
{
17361735
$arguments = [];

0 commit comments

Comments
 (0)