47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Apoloz\AlfaBank\Requests\Escrow;
|
|
|
|
use Apoloz\AlfaBank\Data\Escrow\EscrowOrderData;
|
|
use Apoloz\AlfaBank\Traits\HasAlfaPagination;
|
|
use Saloon\Enums\Method;
|
|
use Saloon\Http\Request;
|
|
use Saloon\Http\Response;
|
|
use Saloon\PaginationPlugin\Contracts\Paginatable;
|
|
use Spatie\LaravelData\DataCollection;
|
|
|
|
class GetEscrowOrdersRequest extends Request implements Paginatable
|
|
{
|
|
use HasAlfaPagination;
|
|
|
|
protected Method $method = Method::GET;
|
|
|
|
public function __construct(
|
|
protected string $filterFromDate,
|
|
protected string $filterToDate,
|
|
?int $limit = 10,
|
|
?int $offset = 0
|
|
) {
|
|
$this->limit = $limit;
|
|
$this->offset = $offset;
|
|
}
|
|
|
|
public function resolveEndpoint(): string
|
|
{
|
|
return '/api/escrow-orders';
|
|
}
|
|
|
|
protected function defaultQuery(): array
|
|
{
|
|
return array_merge([
|
|
'filterFromDate' => $this->filterFromDate,
|
|
'filterToDate' => $this->filterToDate,
|
|
], $this->getPaginationQuery());
|
|
}
|
|
|
|
public function createDtoFromResponse(Response $response): DataCollection
|
|
{
|
|
return EscrowOrderData::collect($response->json('orders') ?? [], DataCollection::class);
|
|
}
|
|
}
|