feat(repository): implement Kiota OpenAPI repositories and contracts
This commit is contained in:
parent
ea17c0950a
commit
0d9e89f919
12 changed files with 854 additions and 35 deletions
152
src/Repository/AbstractApiRepository.php
Normal file
152
src/Repository/AbstractApiRepository.php
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Microsoft\Kiota\Abstractions\ApiException;
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Error\AuthenticationError;
|
||||
use Uwil\ArcadiaApiPhpClient\Error\NetworkError;
|
||||
use Uwil\ArcadiaApiPhpClient\Error\RateLimitError;
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ServerError;
|
||||
use Uwil\ArcadiaApiPhpClient\Error\UnexpectedApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ValidationError;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PaginationDto;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Models\PaginationMeta;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Models\ProblemDetails;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Models\ValidationErrorProblemDetails;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract class AbstractApiRepository implements Repository
|
||||
{
|
||||
public function __construct(
|
||||
protected readonly ApiClient $apiClient,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @param callable(): T $callback
|
||||
* @return T|ApiError
|
||||
*/
|
||||
protected function executeApiCall(callable $callback): mixed
|
||||
{
|
||||
try {
|
||||
return $callback();
|
||||
} catch (\Throwable $e) {
|
||||
return $this->toApiError($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @param callable(): (T|null) $callback
|
||||
* @return T|null|ApiError
|
||||
*/
|
||||
protected function catchNotFound(callable $callback): mixed
|
||||
{
|
||||
try {
|
||||
return $callback();
|
||||
} catch (ProblemDetails | ApiException $e) {
|
||||
$status = $e instanceof ProblemDetails ? $e->getStatus() : $e->getResponseStatusCode();
|
||||
|
||||
return $status === 404 ? null : $this->toApiError($e);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->toApiError($e);
|
||||
}
|
||||
}
|
||||
|
||||
protected function toApiError(\Throwable $e): ApiError
|
||||
{
|
||||
return match (true) {
|
||||
$e instanceof ValidationErrorProblemDetails => $this->mapValidationError($e),
|
||||
$e instanceof ProblemDetails => $this->mapStatusToError(
|
||||
(int) ($e->getStatus() ?? 0),
|
||||
$e->getDetail() ?? $e->getTitle() ?? $e->getMessage(),
|
||||
$e
|
||||
),
|
||||
$e instanceof ApiException => $this->mapStatusToError(
|
||||
(int) ($e->getResponseStatusCode() ?? 0),
|
||||
$e->getMessage(),
|
||||
$e
|
||||
),
|
||||
$e instanceof ConnectException || $e instanceof GuzzleException => new NetworkError(
|
||||
message: $e->getMessage(),
|
||||
previous: $e,
|
||||
),
|
||||
default => new UnexpectedApiError(
|
||||
message: $e->getMessage(),
|
||||
statusCode: (int) $e->getCode(),
|
||||
previous: $e,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
private function mapValidationError(ValidationErrorProblemDetails $e): ValidationError
|
||||
{
|
||||
$violations = [];
|
||||
foreach ($e->getInvalidParams() ?? [] as $param) {
|
||||
$name = $param->getName();
|
||||
if ($name !== null) {
|
||||
$violations[$name] = $param->getReason() ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
return new ValidationError(
|
||||
message: $e->getDetail() ?? $e->getMessage(),
|
||||
violations: $violations,
|
||||
previous: $e,
|
||||
);
|
||||
}
|
||||
|
||||
private function mapStatusToError(int $status, string $message, \Throwable $e): ApiError
|
||||
{
|
||||
return match (true) {
|
||||
$status === 401 || $status === 403 => new AuthenticationError($message, $status, $e),
|
||||
$status === 429 => new RateLimitError($message, null, $e),
|
||||
$status >= 500 && $status <= 599 => new ServerError($message, $status, $e),
|
||||
default => new UnexpectedApiError($message, $status, $e),
|
||||
};
|
||||
}
|
||||
|
||||
protected function toDateTime(?\DateTimeInterface $date): ?\DateTime
|
||||
{
|
||||
if ($date === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($date instanceof \DateTime) {
|
||||
return $date;
|
||||
}
|
||||
|
||||
return new \DateTime($date->format(\DateTimeInterface::RFC3339));
|
||||
}
|
||||
|
||||
protected function toPaginationDto(?PaginationMeta $meta, Pagination $requestedPagination): PaginationDto
|
||||
{
|
||||
if ($meta !== null) {
|
||||
return new PaginationDto(
|
||||
page: $meta->getPage() ?? $requestedPagination->pageNumber(),
|
||||
pageSize: $meta->getPageSize() ?? $requestedPagination->pageSize(),
|
||||
totalItems: $meta->getTotalItems() ?? 0,
|
||||
totalPages: $meta->getTotalPages() ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
return new PaginationDto(
|
||||
page: $requestedPagination->pageNumber(),
|
||||
pageSize: $requestedPagination->pageSize(),
|
||||
totalItems: 0,
|
||||
totalPages: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
70
src/Repository/BrandApiRepository.php
Normal file
70
src/Repository/BrandApiRepository.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\BrandHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Brand;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Brands\BrandsRequestBuilderGetQueryParameters;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Brands\BrandsRequestBuilderGetRequestConfiguration;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class BrandApiRepository extends AbstractApiRepository implements BrandRepository
|
||||
{
|
||||
public function __construct(
|
||||
ApiClient $apiClient,
|
||||
private readonly BrandHydrator $hydrator,
|
||||
) {
|
||||
parent::__construct($apiClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PageOf<Brand>|ApiError
|
||||
*/
|
||||
public function selectAll(
|
||||
Pagination $pagination
|
||||
): PageOf | ApiError {
|
||||
$config = new BrandsRequestBuilderGetRequestConfiguration();
|
||||
$params = new BrandsRequestBuilderGetQueryParameters();
|
||||
$params->page = $pagination->pageNumber();
|
||||
$params->pageSize = $pagination->pageSize();
|
||||
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\BrandListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->brands()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
public function find(BrandCode $code): Brand | null | ApiError
|
||||
{
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\BrandItemResponse|null|ApiError $response */
|
||||
$response = $this->catchNotFound(
|
||||
fn () => $this->apiClient->brands()->byBrandCode($code->value)->get()->wait()
|
||||
);
|
||||
|
||||
if ($response instanceof ApiError || $response === null) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$brandModel = $response->getBrand();
|
||||
if ($brandModel === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->hydrator->toDto($brandModel);
|
||||
}
|
||||
}
|
||||
26
src/Repository/BrandRepository.php
Normal file
26
src/Repository/BrandRepository.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Brand;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface BrandRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* @return PageOf<Brand>|ApiError
|
||||
*/
|
||||
public function selectAll(
|
||||
Pagination $pagination
|
||||
): PageOf | ApiError;
|
||||
|
||||
public function find(BrandCode $code): Brand | null | ApiError;
|
||||
}
|
||||
185
src/Repository/EmployeeApiRepository.php
Normal file
185
src/Repository/EmployeeApiRepository.php
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\EmployeeHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Employee;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\EmployeeSortColumn;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\EmployeeSorter;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\ArcadiaEmployeeId;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\SiteId;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Employees\EmployeesRequestBuilderGetQueryParameters;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Employees\EmployeesRequestBuilderGetRequestConfiguration;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Employees\GetSortByQueryParameterType;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Employees\GetSortDirectionQueryParameterType;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class EmployeeApiRepository extends AbstractApiRepository implements EmployeeRepository
|
||||
{
|
||||
public function __construct(
|
||||
ApiClient $apiClient,
|
||||
private readonly EmployeeHydrator $hydrator,
|
||||
) {
|
||||
parent::__construct($apiClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PageOf<Employee>|ApiError
|
||||
*/
|
||||
public function selectAll(
|
||||
Pagination $pagination,
|
||||
?EmployeeSorter $sorter = null
|
||||
): PageOf | ApiError {
|
||||
$config = new EmployeesRequestBuilderGetRequestConfiguration();
|
||||
$params = new EmployeesRequestBuilderGetQueryParameters();
|
||||
$params->page = $pagination->pageNumber();
|
||||
$params->pageSize = $pagination->pageSize();
|
||||
|
||||
if ($sorter !== null) {
|
||||
$params->sortBy = $this->mapSortBy($sorter->sortBy);
|
||||
$params->sortDirection = $this->mapSortDirection($sorter->direction);
|
||||
}
|
||||
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\EmployeeListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->employees()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PageOf<Employee>|ApiError
|
||||
*/
|
||||
public function selectAllSince(
|
||||
Pagination $pagination,
|
||||
\DateTimeInterface $since,
|
||||
\SortDirection $sortDirection = \SortDirection::Descending
|
||||
): PageOf | ApiError {
|
||||
$config = new EmployeesRequestBuilderGetRequestConfiguration();
|
||||
$params = new EmployeesRequestBuilderGetQueryParameters();
|
||||
$params->page = $pagination->pageNumber();
|
||||
$params->pageSize = $pagination->pageSize();
|
||||
$params->since = $this->toDateTime($since);
|
||||
$params->sortBy = new GetSortByQueryParameterType(GetSortByQueryParameterType::UPDATED_AT);
|
||||
$params->sortDirection = $this->mapSortDirection($sortDirection);
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\EmployeeListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->employees()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SiteId[] $sites
|
||||
* @return PageOf<Employee>|ApiError
|
||||
*/
|
||||
public function selectAllHavingSitesSince(
|
||||
Pagination $pagination,
|
||||
\DateTimeInterface $since,
|
||||
array $sites,
|
||||
\SortDirection $sortDirection = \SortDirection::Descending
|
||||
): PageOf | ApiError {
|
||||
$config = new EmployeesRequestBuilderGetRequestConfiguration();
|
||||
$params = new EmployeesRequestBuilderGetQueryParameters();
|
||||
$params->page = $pagination->pageNumber();
|
||||
$params->pageSize = $pagination->pageSize();
|
||||
$params->since = $this->toDateTime($since);
|
||||
$params->siteIds = array_map(fn (SiteId $site): string => $site->value, $sites);
|
||||
$params->sortBy = new GetSortByQueryParameterType(GetSortByQueryParameterType::UPDATED_AT);
|
||||
$params->sortDirection = $this->mapSortDirection($sortDirection);
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\EmployeeListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->employees()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SiteId[] $sites
|
||||
* @return PageOf<Employee>|ApiError
|
||||
*/
|
||||
public function selectAllHavingSites(
|
||||
Pagination $pagination,
|
||||
array $sites,
|
||||
?EmployeeSorter $sorter = null
|
||||
): PageOf | ApiError {
|
||||
$config = new EmployeesRequestBuilderGetRequestConfiguration();
|
||||
$params = new EmployeesRequestBuilderGetQueryParameters();
|
||||
$params->page = $pagination->pageNumber();
|
||||
$params->pageSize = $pagination->pageSize();
|
||||
$params->siteIds = array_map(fn (SiteId $site): string => $site->value, $sites);
|
||||
|
||||
if ($sorter !== null) {
|
||||
$params->sortBy = $this->mapSortBy($sorter->sortBy);
|
||||
$params->sortDirection = $this->mapSortDirection($sorter->direction);
|
||||
}
|
||||
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\EmployeeListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->employees()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
public function find(ArcadiaEmployeeId $id): Employee | null | ApiError
|
||||
{
|
||||
return $this->catchNotFound(function () use ($id): ?Employee {
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\EmployeeItemResponse|null $response */
|
||||
$response = $this->apiClient->employees()->byEmployeeId($id->value)->get()->wait();
|
||||
$employee = $response?->getEmployee();
|
||||
|
||||
return $employee !== null ? $this->hydrator->toDto($employee) : null;
|
||||
});
|
||||
}
|
||||
|
||||
private function mapSortBy(EmployeeSortColumn $column): GetSortByQueryParameterType
|
||||
{
|
||||
$val = match ($column) {
|
||||
EmployeeSortColumn::arcadiaId => GetSortByQueryParameterType::ARCADIA_ID,
|
||||
EmployeeSortColumn::startDate => GetSortByQueryParameterType::START_DATE,
|
||||
EmployeeSortColumn::endDate => GetSortByQueryParameterType::END_DATE,
|
||||
EmployeeSortColumn::plannedEndDate => GetSortByQueryParameterType::PLANNED_END_DATE,
|
||||
EmployeeSortColumn::createdAt => GetSortByQueryParameterType::CREATED_AT,
|
||||
EmployeeSortColumn::updatedAt => GetSortByQueryParameterType::UPDATED_AT,
|
||||
};
|
||||
|
||||
return new GetSortByQueryParameterType($val);
|
||||
}
|
||||
|
||||
private function mapSortDirection(\SortDirection $direction): GetSortDirectionQueryParameterType
|
||||
{
|
||||
$val = $direction === \SortDirection::Ascending
|
||||
? GetSortDirectionQueryParameterType::ASCENDING
|
||||
: GetSortDirectionQueryParameterType::DESCENDING;
|
||||
|
||||
return new GetSortDirectionQueryParameterType($val);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,52 +4,55 @@ declare(strict_types=1);
|
|||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Employee;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiQueryBuilder\Direction;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\EmployeeSorter;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\ArcadiaEmployeeId;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\EmployeeSorter;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface EmployeeRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* @return PageOf<Employee>
|
||||
* @return PageOf<Employee>|ApiError
|
||||
*/
|
||||
public function selectAll(
|
||||
Pagination $pagination,
|
||||
?EmployeeSorter $sorter = null
|
||||
): PageOf;
|
||||
): PageOf | ApiError;
|
||||
|
||||
/**
|
||||
* @return PageOf<Employee>
|
||||
* @return PageOf<Employee>|ApiError
|
||||
*/
|
||||
public function selectAllSince(
|
||||
Pagination $pagination,
|
||||
\DateTimeInterface $since,
|
||||
Direction $sortDirection = Direction::DESC
|
||||
): PageOf;
|
||||
\SortDirection $sortDirection = \SortDirection::Descending
|
||||
): PageOf | ApiError;
|
||||
|
||||
/**
|
||||
* @param \Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\SiteId[] $sites
|
||||
* @return PageOf<Employee>
|
||||
* @return PageOf<Employee>|ApiError
|
||||
*/
|
||||
public function selectAllHavingSitesSince(
|
||||
Pagination $pagination,
|
||||
\DateTimeInterface $since,
|
||||
array $sites,
|
||||
Direction $sortDirection = Direction::DESC
|
||||
): PageOf;
|
||||
\SortDirection $sortDirection = \SortDirection::Descending
|
||||
): PageOf | ApiError;
|
||||
|
||||
/**
|
||||
* @param \Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\SiteId[] $sites
|
||||
* @return PageOf<Employee>
|
||||
* @return PageOf<Employee>|ApiError
|
||||
*/
|
||||
public function selectAllHavingSites(
|
||||
Pagination $pagination,
|
||||
array $sites,
|
||||
?EmployeeSorter $sorter = null
|
||||
): PageOf;
|
||||
): PageOf | ApiError;
|
||||
|
||||
public function find(ArcadiaEmployeeId $id): ?Employee;
|
||||
public function find(ArcadiaEmployeeId $id): Employee | null | ApiError;
|
||||
}
|
||||
|
|
|
|||
215
src/Repository/IncoApiRepository.php
Normal file
215
src/Repository/IncoApiRepository.php
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Inco;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\IncoSortColumn;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\IncoSorter;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\IncoId;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\GetSortByQueryParameterType;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\GetSortDirectionQueryParameterType;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\IncoSheetsRequestBuilderGetQueryParameters;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\IncoSheetsRequestBuilderGetRequestConfiguration;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\Search\SearchRequestBuilderGetQueryParameters;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\Search\SearchRequestBuilderGetRequestConfiguration;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class IncoApiRepository extends AbstractApiRepository implements IncoRepository
|
||||
{
|
||||
public function __construct(
|
||||
ApiClient $apiClient,
|
||||
private readonly IncoHydrator $hydrator,
|
||||
) {
|
||||
parent::__construct($apiClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PageOf<Inco>|ApiError
|
||||
*/
|
||||
public function selectAll(
|
||||
Pagination $pagination,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf | ApiError {
|
||||
$config = new IncoSheetsRequestBuilderGetRequestConfiguration();
|
||||
$params = new IncoSheetsRequestBuilderGetQueryParameters();
|
||||
$params->page = $pagination->pageNumber();
|
||||
$params->pageSize = $pagination->pageSize();
|
||||
$params->short = false;
|
||||
|
||||
if ($sorter !== null) {
|
||||
$params->sortBy = $this->mapSortBy($sorter->sortBy);
|
||||
$params->sortDirection = $this->mapSortDirection($sorter->direction);
|
||||
}
|
||||
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\IncoListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->incoSheets()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PageOf<Inco>|ApiError
|
||||
*/
|
||||
public function selectAllSince(
|
||||
Pagination $pagination,
|
||||
\DateTimeInterface $since,
|
||||
\SortDirection $sortDirection = \SortDirection::Descending
|
||||
): PageOf | ApiError {
|
||||
$config = new IncoSheetsRequestBuilderGetRequestConfiguration();
|
||||
$params = new IncoSheetsRequestBuilderGetQueryParameters();
|
||||
$params->page = $pagination->pageNumber();
|
||||
$params->pageSize = $pagination->pageSize();
|
||||
$params->since = $this->toDateTime($since);
|
||||
$params->short = false;
|
||||
$params->sortBy = new GetSortByQueryParameterType(GetSortByQueryParameterType::UPDATED_AT);
|
||||
$params->sortDirection = $this->mapSortDirection($sortDirection);
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\IncoListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->incoSheets()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BrandCode[] $brands
|
||||
* @return PageOf<Inco>|ApiError
|
||||
*/
|
||||
public function selectAllHavingBrandsSince(
|
||||
Pagination $pagination,
|
||||
\DateTimeInterface $since,
|
||||
array $brands,
|
||||
\SortDirection $sortDirection = \SortDirection::Descending,
|
||||
): PageOf | ApiError {
|
||||
$config = new IncoSheetsRequestBuilderGetRequestConfiguration();
|
||||
$params = new IncoSheetsRequestBuilderGetQueryParameters();
|
||||
$params->page = $pagination->pageNumber();
|
||||
$params->pageSize = $pagination->pageSize();
|
||||
$params->since = $this->toDateTime($since);
|
||||
$params->brands = array_map(fn (BrandCode $brand): string => (string) $brand->value, $brands);
|
||||
$params->short = false;
|
||||
$params->sortBy = new GetSortByQueryParameterType(GetSortByQueryParameterType::UPDATED_AT);
|
||||
$params->sortDirection = $this->mapSortDirection($sortDirection);
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\IncoListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->incoSheets()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BrandCode[] $brands
|
||||
* @return PageOf<Inco>|ApiError
|
||||
*/
|
||||
public function selectAllHavingBrands(
|
||||
Pagination $pagination,
|
||||
array $brands,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf | ApiError {
|
||||
$config = new IncoSheetsRequestBuilderGetRequestConfiguration();
|
||||
$params = new IncoSheetsRequestBuilderGetQueryParameters();
|
||||
$params->page = $pagination->pageNumber();
|
||||
$params->pageSize = $pagination->pageSize();
|
||||
$params->brands = array_map(fn (BrandCode $brand): string => (string) $brand->value, $brands);
|
||||
$params->short = false;
|
||||
|
||||
if ($sorter !== null) {
|
||||
$params->sortBy = $this->mapSortBy($sorter->sortBy);
|
||||
$params->sortDirection = $this->mapSortDirection($sorter->direction);
|
||||
}
|
||||
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\IncoListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->incoSheets()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BrandCode[] $inBrands
|
||||
* @return PageOf<Inco>|ApiError
|
||||
*/
|
||||
public function findWhere(
|
||||
string $incoIdLike,
|
||||
array $inBrands,
|
||||
Pagination $pagination,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf | ApiError {
|
||||
$config = new SearchRequestBuilderGetRequestConfiguration();
|
||||
$params = new SearchRequestBuilderGetQueryParameters();
|
||||
$params->incoIdLike = $incoIdLike;
|
||||
$params->brands = $inBrands !== [] ? array_map(fn (BrandCode $brand): string => (string) $brand->value, $inBrands) : null;
|
||||
$params->short = false;
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\IncoListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->incoSheets()->search()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
public function find(IncoId $id): Inco | null | ApiError
|
||||
{
|
||||
return $this->catchNotFound(function () use ($id): ?Inco {
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\IncoItemResponse|null $response */
|
||||
$response = $this->apiClient->incoSheets()->byIncoId($id->value)->get()->wait();
|
||||
$sheet = $response?->getIncoSheet();
|
||||
|
||||
return $sheet !== null ? $this->hydrator->toDto($sheet) : null;
|
||||
});
|
||||
}
|
||||
|
||||
private function mapSortBy(IncoSortColumn $column): GetSortByQueryParameterType
|
||||
{
|
||||
$val = match ($column) {
|
||||
IncoSortColumn::id => GetSortByQueryParameterType::INCO_SHEET_ID,
|
||||
IncoSortColumn::createdAt => GetSortByQueryParameterType::CREATED_AT,
|
||||
IncoSortColumn::updatedAt => GetSortByQueryParameterType::UPDATED_AT,
|
||||
};
|
||||
|
||||
return new GetSortByQueryParameterType($val);
|
||||
}
|
||||
|
||||
private function mapSortDirection(\SortDirection $direction): GetSortDirectionQueryParameterType
|
||||
{
|
||||
$val = $direction === \SortDirection::Ascending
|
||||
? GetSortDirectionQueryParameterType::ASCENDING
|
||||
: GetSortDirectionQueryParameterType::DESCENDING;
|
||||
|
||||
return new GetSortDirectionQueryParameterType($val);
|
||||
}
|
||||
}
|
||||
41
src/Repository/IncoCompoApiRepository.php
Normal file
41
src/Repository/IncoCompoApiRepository.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoCompoHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoCompo;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\IncoCompoId;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\IncoId;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class IncoCompoApiRepository extends AbstractApiRepository implements IncoCompoRepository
|
||||
{
|
||||
public function __construct(
|
||||
ApiClient $apiClient,
|
||||
private readonly IncoCompoHydrator $hydrator,
|
||||
) {
|
||||
parent::__construct($apiClient);
|
||||
}
|
||||
|
||||
public function find(IncoCompoId $id): IncoCompo | null | ApiError
|
||||
{
|
||||
return $this->findFor(new IncoId($id->value));
|
||||
}
|
||||
|
||||
public function findFor(IncoId $id): IncoCompo | null | ApiError
|
||||
{
|
||||
return $this->catchNotFound(function () use ($id): ?IncoCompo {
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\IncoCompoItemResponse|null $response */
|
||||
$response = $this->apiClient->incoSheets()->byIncoId($id->value)->composition()->get()->wait();
|
||||
$composition = $response?->getComposition();
|
||||
|
||||
return $composition !== null ? $this->hydrator->toDto($composition) : null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -4,13 +4,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoCompo;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\IncoCompoId;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\IncoId;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface IncoCompoRepository extends Repository
|
||||
{
|
||||
public function find(IncoCompoId $id): ?IncoCompo;
|
||||
public function find(IncoCompoId $id): IncoCompo | null | ApiError;
|
||||
|
||||
public function findFor(IncoId $id): ?IncoCompo;
|
||||
public function findFor(IncoId $id): IncoCompo | null | ApiError;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,63 +4,66 @@ declare(strict_types=1);
|
|||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Inco;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiQueryBuilder\Direction;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\IncoSorter;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\IncoId;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\IncoSorter;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface IncoRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* @return PageOf<Inco>
|
||||
* @return PageOf<Inco>|ApiError
|
||||
*/
|
||||
public function selectAll(
|
||||
Pagination $pagination,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf;
|
||||
): PageOf | ApiError;
|
||||
|
||||
/**
|
||||
* @return PageOf<Inco>
|
||||
* @return PageOf<Inco>|ApiError
|
||||
*/
|
||||
public function selectAllSince(
|
||||
Pagination $pagination,
|
||||
\DateTimeInterface $since,
|
||||
Direction $sortDirection = Direction::DESC
|
||||
): PageOf;
|
||||
\SortDirection $sortDirection = \SortDirection::Descending
|
||||
): PageOf | ApiError;
|
||||
|
||||
/**
|
||||
* @param \Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode[] $brands
|
||||
* @return PageOf<Inco>
|
||||
* @return PageOf<Inco>|ApiError
|
||||
*/
|
||||
public function selectAllHavingBrandsSince(
|
||||
Pagination $pagination,
|
||||
\DateTimeInterface $since,
|
||||
array $brands,
|
||||
Direction $sortDirection = Direction::DESC,
|
||||
): PageOf;
|
||||
\SortDirection $sortDirection = \SortDirection::Descending,
|
||||
): PageOf | ApiError;
|
||||
|
||||
/**
|
||||
* @param \Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode[] $brands
|
||||
* @return PageOf<Inco>
|
||||
* @return PageOf<Inco>|ApiError
|
||||
*/
|
||||
public function selectAllHavingBrands(
|
||||
Pagination $pagination,
|
||||
array $brands,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf;
|
||||
): PageOf | ApiError;
|
||||
|
||||
/**
|
||||
* @param \Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode[] $inBrands
|
||||
* @return PageOf<Inco>
|
||||
* @return PageOf<Inco>|ApiError
|
||||
*/
|
||||
public function findWhere(
|
||||
string $incoIdLike,
|
||||
array $inBrands,
|
||||
Pagination $pagination,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf;
|
||||
): PageOf | ApiError;
|
||||
|
||||
public function find(IncoId $id): ?Inco;
|
||||
public function find(IncoId $id): Inco | null | ApiError;
|
||||
}
|
||||
|
|
|
|||
113
src/Repository/IncoShortApiRepository.php
Normal file
113
src/Repository/IncoShortApiRepository.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoShortHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\IncoSortColumn;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\IncoSorter;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\GetSortByQueryParameterType;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\GetSortDirectionQueryParameterType;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\IncoSheetsRequestBuilderGetQueryParameters;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\IncoSheetsRequestBuilderGetRequestConfiguration;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\Search\SearchRequestBuilderGetQueryParameters;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\Search\SearchRequestBuilderGetRequestConfiguration;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class IncoShortApiRepository extends AbstractApiRepository implements IncoShortRepository
|
||||
{
|
||||
public function __construct(
|
||||
ApiClient $apiClient,
|
||||
private readonly IncoShortHydrator $hydrator,
|
||||
) {
|
||||
parent::__construct($apiClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BrandCode[] $brands
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError
|
||||
*/
|
||||
public function selectAllHavingBrands(
|
||||
Pagination $pagination,
|
||||
array $brands,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf | ApiError {
|
||||
$config = new IncoSheetsRequestBuilderGetRequestConfiguration();
|
||||
$params = new IncoSheetsRequestBuilderGetQueryParameters();
|
||||
$params->page = $pagination->pageNumber();
|
||||
$params->pageSize = $pagination->pageSize();
|
||||
$params->brands = array_map(fn (BrandCode $brand): string => (string) $brand->value, $brands);
|
||||
$params->short = true;
|
||||
|
||||
if ($sorter !== null) {
|
||||
$params->sortBy = $this->mapSortBy($sorter->sortBy);
|
||||
$params->sortDirection = $this->mapSortDirection($sorter->direction);
|
||||
}
|
||||
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\IncoListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->incoSheets()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BrandCode[] $inBrands
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError
|
||||
*/
|
||||
public function findWhere(
|
||||
string $incoIdLike,
|
||||
array $inBrands,
|
||||
Pagination $pagination,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf | ApiError {
|
||||
$config = new SearchRequestBuilderGetRequestConfiguration();
|
||||
$params = new SearchRequestBuilderGetQueryParameters();
|
||||
$params->incoIdLike = $incoIdLike;
|
||||
$params->brands = $inBrands !== [] ? array_map(fn (BrandCode $brand): string => (string) $brand->value, $inBrands) : null;
|
||||
$params->short = true;
|
||||
$config->queryParameters = $params;
|
||||
|
||||
/** @var \Uwil\ArcadiaKiotaOpenApiClient\Models\IncoListResponse|ApiError $response */
|
||||
$response = $this->executeApiCall(fn () => $this->apiClient->incoSheets()->search()->get($config)->wait());
|
||||
|
||||
if ($response instanceof ApiError) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
private function mapSortBy(IncoSortColumn $column): GetSortByQueryParameterType
|
||||
{
|
||||
$val = match ($column) {
|
||||
IncoSortColumn::id => GetSortByQueryParameterType::INCO_SHEET_ID,
|
||||
IncoSortColumn::createdAt => GetSortByQueryParameterType::CREATED_AT,
|
||||
IncoSortColumn::updatedAt => GetSortByQueryParameterType::UPDATED_AT,
|
||||
};
|
||||
|
||||
return new GetSortByQueryParameterType($val);
|
||||
}
|
||||
|
||||
private function mapSortDirection(\SortDirection $direction): GetSortDirectionQueryParameterType
|
||||
{
|
||||
$val = $direction === \SortDirection::Ascending
|
||||
? GetSortDirectionQueryParameterType::ASCENDING
|
||||
: GetSortDirectionQueryParameterType::DESCENDING;
|
||||
|
||||
return new GetSortDirectionQueryParameterType($val);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,30 +4,34 @@ declare(strict_types=1);
|
|||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\IncoSorter;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\IncoSorter;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface IncoShortRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* @param \Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode[] $inBrands
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError
|
||||
*/
|
||||
public function findWhere(
|
||||
string $incoIdLike,
|
||||
array $inBrands,
|
||||
Pagination $pagination,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf;
|
||||
): PageOf | ApiError;
|
||||
|
||||
/**
|
||||
* @param \Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode[] $brands
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError
|
||||
*/
|
||||
public function selectAllHavingBrands(
|
||||
Pagination $pagination,
|
||||
array $brands,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf;
|
||||
): PageOf | ApiError;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface Repository
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue