Skip to content

Commit ae4f13f

Browse files
authored
Merge pull request #572 from php-api-clients/GitHubEnterprise-3.4/from-1.1.4-8491d07e4903341efa2424ac8af7c5ec-from-1.1.4-8491d07e4903341efa2424ac8af7c5ec
2 parents 9c447da + 1c90990 commit ae4f13f

File tree

860 files changed

+49288
-3378
lines changed

Some content is hidden

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

860 files changed

+49288
-3378
lines changed

clients/GitHubEnterprise-3.4/README.md

Lines changed: 4213 additions & 451 deletions
Large diffs are not rendered by default.

clients/GitHubEnterprise-3.4/etc/openapi-client-generator.state

Lines changed: 2194 additions & 414 deletions
Large diffs are not rendered by default.

clients/GitHubEnterprise-3.4/src/Client.php

Lines changed: 66 additions & 1 deletion
Large diffs are not rendered by default.

clients/GitHubEnterprise-3.4/src/ClientInterface.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

clients/GitHubEnterprise-3.4/src/Operation/Activity.php

Lines changed: 135 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ApiClients\Client\GitHubEnterprise\Operation\Activity;
6+
7+
use ApiClients\Client\GitHubEnterprise\Hydrator;
8+
use ApiClients\Client\GitHubEnterprise\Schema;
9+
use cebe\openapi\Reader;
10+
use League\OpenAPIValidation\Schema\SchemaValidator;
11+
use Psr\Http\Message\RequestInterface;
12+
use Psr\Http\Message\ResponseInterface;
13+
use RingCentral\Psr7\Request;
14+
use RuntimeException;
15+
use Rx\Observable;
16+
use Rx\Scheduler\ImmediateScheduler;
17+
use Throwable;
18+
19+
use function explode;
20+
use function json_decode;
21+
use function str_replace;
22+
23+
final class ListEventsForAuthenticatedUserListing
24+
{
25+
public const OPERATION_ID = 'activity/list-events-for-authenticated-user';
26+
public const OPERATION_MATCH = 'LIST /users/{username}/events';
27+
private const METHOD = 'GET';
28+
private const PATH = '/users/{username}/events';
29+
/**The handle for the GitHub user account. **/
30+
private string $username;
31+
/**The number of results per page (max 100). **/
32+
private int $perPage;
33+
/**Page number of the results to fetch. **/
34+
private int $page;
35+
36+
public function __construct(private readonly SchemaValidator $responseSchemaValidator, private readonly Hydrator\Operation\Users\Username\Events $hydrator, string $username, int $perPage = 30, int $page = 1)
37+
{
38+
$this->username = $username;
39+
$this->perPage = $perPage;
40+
$this->page = $page;
41+
}
42+
43+
public function createRequest(): RequestInterface
44+
{
45+
return new Request(self::METHOD, str_replace(['{username}', '{per_page}', '{page}'], [$this->username, $this->perPage, $this->page], self::PATH . '?per_page={per_page}&page={page}'));
46+
}
47+
48+
/** @return Observable<Schema\Event> */
49+
public function createResponse(ResponseInterface $response): Observable
50+
{
51+
$code = $response->getStatusCode();
52+
[$contentType] = explode(';', $response->getHeaderLine('Content-Type'));
53+
switch ($contentType) {
54+
case 'application/json':
55+
$body = json_decode($response->getBody()->getContents(), true);
56+
switch ($code) {
57+
/**
58+
* Response
59+
**/
60+
case 200:
61+
return Observable::fromArray($body, new ImmediateScheduler())->map(function (array $body): Schema\Event {
62+
$error = new RuntimeException();
63+
try {
64+
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\Event::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema'));
65+
66+
return $this->hydrator->hydrateObject(Schema\Event::class, $body);
67+
} catch (Throwable $error) {
68+
goto items_application_json_two_hundred_aaaaa;
69+
}
70+
71+
items_application_json_two_hundred_aaaaa:
72+
throw $error;
73+
});
74+
}
75+
76+
break;
77+
}
78+
79+
throw new RuntimeException('Unable to find matching response code and content type');
80+
}
81+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ApiClients\Client\GitHubEnterprise\Operation\Activity;
6+
7+
use ApiClients\Client\GitHubEnterprise\Error as ErrorSchemas;
8+
use ApiClients\Client\GitHubEnterprise\Hydrator;
9+
use ApiClients\Client\GitHubEnterprise\Schema;
10+
use cebe\openapi\Reader;
11+
use League\OpenAPIValidation\Schema\SchemaValidator;
12+
use Psr\Http\Message\RequestInterface;
13+
use Psr\Http\Message\ResponseInterface;
14+
use RingCentral\Psr7\Request;
15+
use RuntimeException;
16+
use Rx\Observable;
17+
use Rx\Scheduler\ImmediateScheduler;
18+
use Throwable;
19+
20+
use function explode;
21+
use function json_decode;
22+
use function str_replace;
23+
24+
final class ListNotificationsForAuthenticatedUserListing
25+
{
26+
public const OPERATION_ID = 'activity/list-notifications-for-authenticated-user';
27+
public const OPERATION_MATCH = 'LIST /notifications';
28+
private const METHOD = 'GET';
29+
private const PATH = '/notifications';
30+
/**Only show notifications updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. **/
31+
private string $since;
32+
/**Only show notifications updated before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. **/
33+
private string $before;
34+
/**If `true`, show notifications marked as read. **/
35+
private bool $all;
36+
/**If `true`, only shows notifications in which the user is directly participating or mentioned. **/
37+
private bool $participating;
38+
/**Page number of the results to fetch. **/
39+
private int $page;
40+
/**The number of results per page (max 50). **/
41+
private int $perPage;
42+
43+
public function __construct(private readonly SchemaValidator $responseSchemaValidator, private readonly Hydrator\Operation\Notifications $hydrator, string $since, string $before, bool $all = false, bool $participating = false, int $page = 1, int $perPage = 50)
44+
{
45+
$this->since = $since;
46+
$this->before = $before;
47+
$this->all = $all;
48+
$this->participating = $participating;
49+
$this->page = $page;
50+
$this->perPage = $perPage;
51+
}
52+
53+
public function createRequest(): RequestInterface
54+
{
55+
return new Request(self::METHOD, str_replace(['{since}', '{before}', '{all}', '{participating}', '{page}', '{per_page}'], [$this->since, $this->before, $this->all, $this->participating, $this->page, $this->perPage], self::PATH . '?since={since}&before={before}&all={all}&participating={participating}&page={page}&per_page={per_page}'));
56+
}
57+
58+
/** @return Observable<Schema\Thread>|array{code: int} */
59+
public function createResponse(ResponseInterface $response): Observable|array
60+
{
61+
$code = $response->getStatusCode();
62+
[$contentType] = explode(';', $response->getHeaderLine('Content-Type'));
63+
switch ($contentType) {
64+
case 'application/json':
65+
$body = json_decode($response->getBody()->getContents(), true);
66+
switch ($code) {
67+
/**
68+
* Response
69+
**/
70+
case 200:
71+
return Observable::fromArray($body, new ImmediateScheduler())->map(function (array $body): Schema\Thread {
72+
$error = new RuntimeException();
73+
try {
74+
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\Thread::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema'));
75+
76+
return $this->hydrator->hydrateObject(Schema\Thread::class, $body);
77+
} catch (Throwable $error) {
78+
goto items_application_json_two_hundred_aaaaa;
79+
}
80+
81+
items_application_json_two_hundred_aaaaa:
82+
throw $error;
83+
});
84+
/**
85+
* Forbidden
86+
**/
87+
88+
case 403:
89+
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\BasicError::SCHEMA_JSON, \cebe\openapi\spec\Schema::class));
90+
91+
throw new ErrorSchemas\BasicError(403, $this->hydrator->hydrateObject(Schema\BasicError::class, $body));
92+
/**
93+
* Requires authentication
94+
**/
95+
96+
case 401:
97+
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\BasicError::SCHEMA_JSON, \cebe\openapi\spec\Schema::class));
98+
99+
throw new ErrorSchemas\BasicError(401, $this->hydrator->hydrateObject(Schema\BasicError::class, $body));
100+
/**
101+
* Validation failed, or the endpoint has been spammed.
102+
**/
103+
104+
case 422:
105+
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\ValidationError::SCHEMA_JSON, \cebe\openapi\spec\Schema::class));
106+
107+
throw new ErrorSchemas\ValidationError(422, $this->hydrator->hydrateObject(Schema\ValidationError::class, $body));
108+
}
109+
110+
break;
111+
}
112+
113+
switch ($code) {
114+
/**
115+
* Not modified
116+
**/
117+
case 304:
118+
return ['code' => 304];
119+
}
120+
121+
throw new RuntimeException('Unable to find matching response code and content type');
122+
}
123+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ApiClients\Client\GitHubEnterprise\Operation\Activity;
6+
7+
use ApiClients\Client\GitHubEnterprise\Hydrator;
8+
use ApiClients\Client\GitHubEnterprise\Schema;
9+
use cebe\openapi\Reader;
10+
use League\OpenAPIValidation\Schema\SchemaValidator;
11+
use Psr\Http\Message\RequestInterface;
12+
use Psr\Http\Message\ResponseInterface;
13+
use RingCentral\Psr7\Request;
14+
use RuntimeException;
15+
use Rx\Observable;
16+
use Rx\Scheduler\ImmediateScheduler;
17+
use Throwable;
18+
19+
use function explode;
20+
use function json_decode;
21+
use function str_replace;
22+
23+
final class ListOrgEventsForAuthenticatedUserListing
24+
{
25+
public const OPERATION_ID = 'activity/list-org-events-for-authenticated-user';
26+
public const OPERATION_MATCH = 'LIST /users/{username}/events/orgs/{org}';
27+
private const METHOD = 'GET';
28+
private const PATH = '/users/{username}/events/orgs/{org}';
29+
/**The handle for the GitHub user account. **/
30+
private string $username;
31+
/**The organization name. The name is not case sensitive. **/
32+
private string $org;
33+
/**The number of results per page (max 100). **/
34+
private int $perPage;
35+
/**Page number of the results to fetch. **/
36+
private int $page;
37+
38+
public function __construct(private readonly SchemaValidator $responseSchemaValidator, private readonly Hydrator\Operation\Users\Username\Events\Orgs\Org $hydrator, string $username, string $org, int $perPage = 30, int $page = 1)
39+
{
40+
$this->username = $username;
41+
$this->org = $org;
42+
$this->perPage = $perPage;
43+
$this->page = $page;
44+
}
45+
46+
public function createRequest(): RequestInterface
47+
{
48+
return new Request(self::METHOD, str_replace(['{username}', '{org}', '{per_page}', '{page}'], [$this->username, $this->org, $this->perPage, $this->page], self::PATH . '?per_page={per_page}&page={page}'));
49+
}
50+
51+
/** @return Observable<Schema\Event> */
52+
public function createResponse(ResponseInterface $response): Observable
53+
{
54+
$code = $response->getStatusCode();
55+
[$contentType] = explode(';', $response->getHeaderLine('Content-Type'));
56+
switch ($contentType) {
57+
case 'application/json':
58+
$body = json_decode($response->getBody()->getContents(), true);
59+
switch ($code) {
60+
/**
61+
* Response
62+
**/
63+
case 200:
64+
return Observable::fromArray($body, new ImmediateScheduler())->map(function (array $body): Schema\Event {
65+
$error = new RuntimeException();
66+
try {
67+
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\Event::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema'));
68+
69+
return $this->hydrator->hydrateObject(Schema\Event::class, $body);
70+
} catch (Throwable $error) {
71+
goto items_application_json_two_hundred_aaaaa;
72+
}
73+
74+
items_application_json_two_hundred_aaaaa:
75+
throw $error;
76+
});
77+
}
78+
79+
break;
80+
}
81+
82+
throw new RuntimeException('Unable to find matching response code and content type');
83+
}
84+
}

0 commit comments

Comments
 (0)