Skip to content

Commit

Permalink
Merge pull request #572 from php-api-clients/GitHubEnterprise-3.4/fro…
Browse files Browse the repository at this point in the history
…m-1.1.4-8491d07e4903341efa2424ac8af7c5ec-from-1.1.4-8491d07e4903341efa2424ac8af7c5ec
  • Loading branch information
WyriHaximus authored Aug 22, 2023
2 parents 9c447da + 1c90990 commit ae4f13f
Show file tree
Hide file tree
Showing 860 changed files with 49,288 additions and 3,378 deletions.
4,664 changes: 4,213 additions & 451 deletions clients/GitHubEnterprise-3.4/README.md

Large diffs are not rendered by default.

2,608 changes: 2,194 additions & 414 deletions clients/GitHubEnterprise-3.4/etc/openapi-client-generator.state

Large diffs are not rendered by default.

67 changes: 66 additions & 1 deletion clients/GitHubEnterprise-3.4/src/Client.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/GitHubEnterprise-3.4/src/ClientInterface.php

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions clients/GitHubEnterprise-3.4/src/Operation/Activity.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

declare(strict_types=1);

namespace ApiClients\Client\GitHubEnterprise\Operation\Activity;

use ApiClients\Client\GitHubEnterprise\Hydrator;
use ApiClients\Client\GitHubEnterprise\Schema;
use cebe\openapi\Reader;
use League\OpenAPIValidation\Schema\SchemaValidator;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use RingCentral\Psr7\Request;
use RuntimeException;
use Rx\Observable;
use Rx\Scheduler\ImmediateScheduler;
use Throwable;

use function explode;
use function json_decode;
use function str_replace;

final class ListEventsForAuthenticatedUserListing
{
public const OPERATION_ID = 'activity/list-events-for-authenticated-user';
public const OPERATION_MATCH = 'LIST /users/{username}/events';
private const METHOD = 'GET';
private const PATH = '/users/{username}/events';
/**The handle for the GitHub user account. **/
private string $username;
/**The number of results per page (max 100). **/
private int $perPage;
/**Page number of the results to fetch. **/
private int $page;

public function __construct(private readonly SchemaValidator $responseSchemaValidator, private readonly Hydrator\Operation\Users\Username\Events $hydrator, string $username, int $perPage = 30, int $page = 1)
{
$this->username = $username;
$this->perPage = $perPage;
$this->page = $page;
}

public function createRequest(): RequestInterface
{
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}'));
}

/** @return Observable<Schema\Event> */
public function createResponse(ResponseInterface $response): Observable
{
$code = $response->getStatusCode();
[$contentType] = explode(';', $response->getHeaderLine('Content-Type'));
switch ($contentType) {
case 'application/json':
$body = json_decode($response->getBody()->getContents(), true);
switch ($code) {
/**
* Response
**/
case 200:
return Observable::fromArray($body, new ImmediateScheduler())->map(function (array $body): Schema\Event {
$error = new RuntimeException();
try {
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\Event::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema'));

return $this->hydrator->hydrateObject(Schema\Event::class, $body);
} catch (Throwable $error) {
goto items_application_json_two_hundred_aaaaa;
}

items_application_json_two_hundred_aaaaa:
throw $error;
});
}

break;
}

throw new RuntimeException('Unable to find matching response code and content type');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

declare(strict_types=1);

namespace ApiClients\Client\GitHubEnterprise\Operation\Activity;

use ApiClients\Client\GitHubEnterprise\Error as ErrorSchemas;
use ApiClients\Client\GitHubEnterprise\Hydrator;
use ApiClients\Client\GitHubEnterprise\Schema;
use cebe\openapi\Reader;
use League\OpenAPIValidation\Schema\SchemaValidator;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use RingCentral\Psr7\Request;
use RuntimeException;
use Rx\Observable;
use Rx\Scheduler\ImmediateScheduler;
use Throwable;

use function explode;
use function json_decode;
use function str_replace;

final class ListNotificationsForAuthenticatedUserListing
{
public const OPERATION_ID = 'activity/list-notifications-for-authenticated-user';
public const OPERATION_MATCH = 'LIST /notifications';
private const METHOD = 'GET';
private const PATH = '/notifications';
/**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`. **/
private string $since;
/**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`. **/
private string $before;
/**If `true`, show notifications marked as read. **/
private bool $all;
/**If `true`, only shows notifications in which the user is directly participating or mentioned. **/
private bool $participating;
/**Page number of the results to fetch. **/
private int $page;
/**The number of results per page (max 50). **/
private int $perPage;

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)
{
$this->since = $since;
$this->before = $before;
$this->all = $all;
$this->participating = $participating;
$this->page = $page;
$this->perPage = $perPage;
}

public function createRequest(): RequestInterface
{
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}'));
}

/** @return Observable<Schema\Thread>|array{code: int} */
public function createResponse(ResponseInterface $response): Observable|array
{
$code = $response->getStatusCode();
[$contentType] = explode(';', $response->getHeaderLine('Content-Type'));
switch ($contentType) {
case 'application/json':
$body = json_decode($response->getBody()->getContents(), true);
switch ($code) {
/**
* Response
**/
case 200:
return Observable::fromArray($body, new ImmediateScheduler())->map(function (array $body): Schema\Thread {
$error = new RuntimeException();
try {
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\Thread::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema'));

return $this->hydrator->hydrateObject(Schema\Thread::class, $body);
} catch (Throwable $error) {
goto items_application_json_two_hundred_aaaaa;
}

items_application_json_two_hundred_aaaaa:
throw $error;
});
/**
* Forbidden
**/

case 403:
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\BasicError::SCHEMA_JSON, \cebe\openapi\spec\Schema::class));

throw new ErrorSchemas\BasicError(403, $this->hydrator->hydrateObject(Schema\BasicError::class, $body));
/**
* Requires authentication
**/

case 401:
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\BasicError::SCHEMA_JSON, \cebe\openapi\spec\Schema::class));

throw new ErrorSchemas\BasicError(401, $this->hydrator->hydrateObject(Schema\BasicError::class, $body));
/**
* Validation failed, or the endpoint has been spammed.
**/

case 422:
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\ValidationError::SCHEMA_JSON, \cebe\openapi\spec\Schema::class));

throw new ErrorSchemas\ValidationError(422, $this->hydrator->hydrateObject(Schema\ValidationError::class, $body));
}

break;
}

switch ($code) {
/**
* Not modified
**/
case 304:
return ['code' => 304];
}

throw new RuntimeException('Unable to find matching response code and content type');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

declare(strict_types=1);

namespace ApiClients\Client\GitHubEnterprise\Operation\Activity;

use ApiClients\Client\GitHubEnterprise\Hydrator;
use ApiClients\Client\GitHubEnterprise\Schema;
use cebe\openapi\Reader;
use League\OpenAPIValidation\Schema\SchemaValidator;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use RingCentral\Psr7\Request;
use RuntimeException;
use Rx\Observable;
use Rx\Scheduler\ImmediateScheduler;
use Throwable;

use function explode;
use function json_decode;
use function str_replace;

final class ListOrgEventsForAuthenticatedUserListing
{
public const OPERATION_ID = 'activity/list-org-events-for-authenticated-user';
public const OPERATION_MATCH = 'LIST /users/{username}/events/orgs/{org}';
private const METHOD = 'GET';
private const PATH = '/users/{username}/events/orgs/{org}';
/**The handle for the GitHub user account. **/
private string $username;
/**The organization name. The name is not case sensitive. **/
private string $org;
/**The number of results per page (max 100). **/
private int $perPage;
/**Page number of the results to fetch. **/
private int $page;

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)
{
$this->username = $username;
$this->org = $org;
$this->perPage = $perPage;
$this->page = $page;
}

public function createRequest(): RequestInterface
{
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}'));
}

/** @return Observable<Schema\Event> */
public function createResponse(ResponseInterface $response): Observable
{
$code = $response->getStatusCode();
[$contentType] = explode(';', $response->getHeaderLine('Content-Type'));
switch ($contentType) {
case 'application/json':
$body = json_decode($response->getBody()->getContents(), true);
switch ($code) {
/**
* Response
**/
case 200:
return Observable::fromArray($body, new ImmediateScheduler())->map(function (array $body): Schema\Event {
$error = new RuntimeException();
try {
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\Event::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema'));

return $this->hydrator->hydrateObject(Schema\Event::class, $body);
} catch (Throwable $error) {
goto items_application_json_two_hundred_aaaaa;
}

items_application_json_two_hundred_aaaaa:
throw $error;
});
}

break;
}

throw new RuntimeException('Unable to find matching response code and content type');
}
}
Loading

0 comments on commit ae4f13f

Please sign in to comment.