Files
alfa-bank-sdk/src/Requests/NominalAccounts/Payouts/GetPayoffsRequest.php
Anatoliy Poloz 3437cba042 payoff list
2026-06-16 22:25:04 +03:00

97 lines
3.6 KiB
PHP

<?php
declare(strict_types=1);
/*
// MODULE_CONTRACT: Represents the API call to retrieve a list of payoffs by account number.
// RESPONSIBILITY: To define the GET request for fetching a paginated list of payoffs with optional filters.
// INPUTS: accountNumber (required), limit, offset, channel, status, createdDateFrom/To, updatedDateFrom/To.
// OUTPUTS: PayOffsListResponseData (DTO).
// LINKS: Data/NominalAccounts/Payouts/PayOffsListResponseData.php
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts;
use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\PayOffsListResponseData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
/**
* Request to list payoffs by account number (GET /api/na/jp/v1/payoffs).
*
* Supports filtering by status, date range, and pagination.
*/
class GetPayoffsRequest extends Request
{
protected Method $method = Method::GET;
/**
* @param string $accountNumber Номер номинального счёта (required, 20 digits)
* @param int|null $limit Количество объектов на странице (1-100, default 100)
* @param int|null $offset Количество объектов, которые необходимо пропустить (default 0)
* @param string|null $channel Направление платежа: EXTERNAL|INTERNAL
* @param string|null $status Статус платежа: NEW|IN_PROGRESS|FAILED|AWAIT_EXTERNAL|READY
* @param string|null $createdDateFrom Начало выборки по дате создания (YYYY-MM-DD)
* @param string|null $createdDateTo Конец выборки по дате создания (YYYY-MM-DD)
* @param string|null $updatedDateFrom Начало выборки по дате обновления (YYYY-MM-DD)
* @param string|null $updatedDateTo Конец выборки по дате обновления (YYYY-MM-DD)
*/
public function __construct(
protected string $accountNumber,
protected ?int $limit = 100,
protected ?int $offset = 0,
protected ?string $channel = null,
protected ?string $status = null,
protected ?string $createdDateFrom = null,
protected ?string $createdDateTo = null,
protected ?string $updatedDateFrom = null,
protected ?string $updatedDateTo = null,
) {}
public function resolveEndpoint(): string
{
$params = [];
$params['accountNumber'] = $this->accountNumber;
if ($this->limit !== null) {
$params['limit'] = $this->limit;
}
if ($this->offset !== null) {
$params['offset'] = $this->offset;
}
if ($this->channel !== null) {
$params['channel'] = $this->channel;
}
if ($this->status !== null) {
$params['status'] = $this->status;
}
if ($this->createdDateFrom !== null) {
$params['createdDateFrom'] = $this->createdDateFrom;
}
if ($this->createdDateTo !== null) {
$params['createdDateTo'] = $this->createdDateTo;
}
if ($this->updatedDateFrom !== null) {
$params['updatedDateFrom'] = $this->updatedDateFrom;
}
if ($this->updatedDateTo !== null) {
$params['updatedDateTo'] = $this->updatedDateTo;
}
return '/api/na/jp/v1/payoffs?' . http_build_query($params);
}
public function createDtoFromResponse(Response $response): PayOffsListResponseData
{
return PayOffsListResponseData::from($response->json());
}
}