fix(formating)

This commit is contained in:
Anatoliy Poloz
2026-01-28 03:36:26 +03:00
parent 1723177949
commit b15d29f8e9
313 changed files with 1863 additions and 1533 deletions

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: CreateBeneficiaryRequestData DTO.
// OUTPUTS: CreateBeneficiaryResponseData DTO.
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries;
// <SECTION name="module_imports" intent="Import DTOs and Saloon components.">
@@ -18,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to create a new beneficiary.">
@@ -46,14 +48,6 @@ class CreateBeneficiaryRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method decouples the request from the DTO's internal structure.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `CreateBeneficiaryResponseData` DTO provides a type-safe object representing the result of the creation.">
public function createDtoFromResponse(Response $response): CreateBeneficiaryResponseData
@@ -61,4 +55,12 @@ class CreateBeneficiaryRequest extends Request implements HasBody
return CreateBeneficiaryResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method decouples the request from the DTO's internal structure.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Various filter and pagination parameters.
// OUTPUTS: BeneficiaryCollectionData DTO.
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -44,6 +45,14 @@ class GetBeneficiariesRequest extends Request implements Paginatable
{
return '/api/na/jp/v1/beneficiaries';
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a collection DTO.">
// <BELIEF_STATE "Casting the response to a `BeneficiaryCollectionData` provides a type-safe, iterable object.">
public function createDtoFromResponse(Response $response): BeneficiaryCollectionData
{
return BeneficiaryCollectionData::from($response->json());
}
protected function defaultQuery(): array
{
@@ -59,12 +68,4 @@ class GetBeneficiariesRequest extends Request implements Paginatable
], $this->getPaginationQuery());
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a collection DTO.">
// <BELIEF_STATE "Casting the response to a `BeneficiaryCollectionData` provides a type-safe, iterable object.">
public function createDtoFromResponse(Response $response): BeneficiaryCollectionData
{
return BeneficiaryCollectionData::from($response->json());
}
// </SECTION>
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Beneficiary ID, account number, and date.
// OUTPUTS: BeneficiaryBalanceData DTO.
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\BeneficiaryBalanceData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get a beneficiary's balance.">
@@ -43,6 +45,14 @@ class GetBeneficiaryBalanceRequest extends Request
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `BeneficiaryBalanceData` DTO provides a clear, type-safe result.">
public function createDtoFromResponse(Response $response): BeneficiaryBalanceData
{
return BeneficiaryBalanceData::from($response->json());
}
// </SECTION>
// <SECTION name="query_builder" intent="Construct the query string from constructor parameters.">
// <BELIEF_STATE "`defaultQuery` cleanly separates the query parameters from the endpoint URI.">
protected function defaultQuery(): array
@@ -53,12 +63,4 @@ class GetBeneficiaryBalanceRequest extends Request
];
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `BeneficiaryBalanceData` DTO provides a clear, type-safe result.">
public function createDtoFromResponse(Response $response): BeneficiaryBalanceData
{
return BeneficiaryBalanceData::from($response->json());
}
// </SECTION>
}

View File

@@ -17,6 +17,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\BeneficiaryTransactionCol
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request for fetching beneficiary transactions.">
@@ -47,6 +48,14 @@ class GetBeneficiaryTransactionsRequest extends Request
}
// </SECTION>
// <SECTION name="create_dto_from_response" intent="Transform the API response into a `BeneficiaryTransactionCollectionData` DTO.">
// <BELIEF_STATE "This method is responsible for taking the raw JSON response from the API and converting it into a type-safe `BeneficiaryTransactionCollectionData` object. This ensures that the data consumed by the application is structured, validated, and easy to work with, adhering to the principle of strong typing.">
public function createDtoFromResponse(Response $response): BeneficiaryTransactionCollectionData
{
return BeneficiaryTransactionCollectionData::from($response->json());
}
// </SECTION>
// <SECTION name="default_query_parameters" intent="Define the default query parameters for the request.">
// <BELIEF_STATE "This method specifies the query parameters (`dateFrom`, `dateTo`, `limit`, `offset`) that will be appended to the request URL. These parameters are crucial for filtering and paginating the transaction data, directly influencing the scope and volume of the API response.">
protected function defaultQuery(): array
@@ -59,13 +68,5 @@ class GetBeneficiaryTransactionsRequest extends Request
];
}
// </SECTION>
// <SECTION name="create_dto_from_response" intent="Transform the API response into a `BeneficiaryTransactionCollectionData` DTO.">
// <BELIEF_STATE "This method is responsible for taking the raw JSON response from the API and converting it into a type-safe `BeneficiaryTransactionCollectionData` object. This ensures that the data consumed by the application is structured, validated, and easy to work with, adhering to the principle of strong typing.">
public function createDtoFromResponse(Response $response): BeneficiaryTransactionCollectionData
{
return BeneficiaryTransactionCollectionData::from($response->json());
}
// </SECTION>
}
// </SECTION>

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to add a requisite to a beneficiary.">
@@ -48,14 +49,6 @@ class AddRequisiteRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a RequisiteData DTO.">
// <BELIEF_STATE "The API returns the newly created requisite object. Casting it to a DTO provides a clean, type-safe object for the user.">
public function createDtoFromResponse(Response $response): RequisiteData
@@ -63,4 +56,12 @@ class AddRequisiteRequest extends Request implements HasBody
return RequisiteData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
}

View File

@@ -17,6 +17,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Spatie\LaravelData\DataCollection;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get requisites for a beneficiary.">

View File

@@ -36,13 +36,13 @@ class UpdateRequisiteRequest extends Request implements HasBody
return "/api/na/jp/v1/beneficiaries/{$this->beneficiaryId}/requisites/{$this->requisiteId}";
}
protected function defaultBody(): array
{
return $this->data;
}
public function createDtoFromResponse(Response $response): GeneralStatusData
{
return GeneralStatusData::from(['success' => $response->successful()]);
}
protected function defaultBody(): array
{
return $this->data;
}
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Beneficiary ID (string).
// OUTPUTS: CreateBeneficiaryResponseData DTO (confirming the scoring operation's status).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\CreateBeneficiaryResponse
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to score a beneficiary.">

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Beneficiary ID and an UpdateBeneficiaryRequestData DTO.
// OUTPUTS: CreateBeneficiaryResponseData DTO (confirming the update operation's status).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries;
// <SECTION name="module_imports" intent="Import DTOs and Saloon components for a JSON body request.">
@@ -18,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to update a beneficiary.">
@@ -47,14 +49,6 @@ class UpdateBeneficiaryRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "The API returns a status for the update operation, mapped to `CreateBeneficiaryResponseData` for consistency, which includes a request ID and status.">
public function createDtoFromResponse(Response $response): CreateBeneficiaryResponseData
@@ -62,4 +56,12 @@ class UpdateBeneficiaryRequest extends Request implements HasBody
return CreateBeneficiaryResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Account number, expiration date, and a collection of digest signatures.
// OUTPUTS: DealData (DTO) of the newly created deal.
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals;
// <SECTION name="module_imports" intent="Import DTOs and Saloon components for a JSON body request.">
@@ -20,6 +21,7 @@ use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
use Spatie\LaravelData\Attributes\DataCollectionOf;
use Spatie\LaravelData\DataCollection;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to create a new deal.">
@@ -54,6 +56,14 @@ class AddDealRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DealData DTO.">
// <BELIEF_STATE "The API returns the newly created deal object. Casting it to a DTO provides a clean, type-safe object for the user.">
public function createDtoFromResponse(Response $response): DealData
{
return DealData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "This method maps the constructor properties to the expected JSON payload structure. The `toArray()` call on the data collection handles its serialization.">
protected function defaultBody(): array
@@ -65,12 +75,4 @@ class AddDealRequest extends Request implements HasBody
];
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DealData DTO.">
// <BELIEF_STATE "The API returns the newly created deal object. Casting it to a DTO provides a clean, type-safe object for the user.">
public function createDtoFromResponse(Response $response): DealData
{
return DealData::from($response->json());
}
// </SECTION>
}

View File

@@ -31,13 +31,13 @@ class DealActionRequest extends Request implements HasBody
return "/api/na/jp/v1/deals/{$this->dealId}/actions/{$this->action}";
}
protected function defaultBody(): array
{
return $this->data;
}
public function createDtoFromResponse(Response $response): GeneralStatusData
{
return GeneralStatusData::from(['success' => $response->successful()]);
}
protected function defaultBody(): array
{
return $this->data;
}
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Deal ID (string).
// OUTPUTS: A collection of DealPayoffData DTOs.
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals;
// <SECTION name="module_imports" intent="Import DTOs and Saloon components.">
@@ -16,6 +17,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Spatie\LaravelData\DataCollection;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get payoffs for a deal.">

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Deal ID (string).
// OUTPUTS: DealData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Deals\DealData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get a single deal.">

View File

@@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Deals\DealRequestStatusData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get the status of a deal request.">

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Account number, pagination parameters (limit, offset).
// OUTPUTS: DealCollectionData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Deals\DealCollectionData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get a list of deals.">
@@ -43,6 +45,14 @@ class GetDealsRequest extends Request
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DealCollectionData DTO.">
// <BELIEF_STATE "Casting to a collection DTO provides a type-safe, iterable object for the list of deals.">
public function createDtoFromResponse(Response $response): DealCollectionData
{
return DealCollectionData::from($response->json());
}
// </SECTION>
// <SECTION name="query_builder" intent="Construct the query string from constructor parameters.">
// <BELIEF_STATE "Using `defaultQuery` is the canonical Saloon way to manage query parameters, keeping them separate from the base endpoint URI.">
protected function defaultQuery(): array
@@ -54,12 +64,4 @@ class GetDealsRequest extends Request
];
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DealCollectionData DTO.">
// <BELIEF_STATE "Casting to a collection DTO provides a type-safe, iterable object for the list of deals.">
public function createDtoFromResponse(Response $response): DealCollectionData
{
return DealCollectionData::from($response->json());
}
// </SECTION>
}

View File

@@ -17,6 +17,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Spatie\LaravelData\DataCollection;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get contractors for a deal step.">
@@ -46,6 +47,14 @@ class GetStepContractorsRequest extends Request
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON array response to a collection of DTOs.">
// <BELIEF_STATE "The API returns a JSON array. Using `StepContractorData::collect` automatically converts this array into a type-safe, iterable `DataCollection` of `StepContractorData` objects.">
public function createDtoFromResponse(Response $response): DataCollection
{
return StepContractorData::collect($response->json(), DataCollection::class);
}
// </SECTION>
// <SECTION name="query_builder" intent="Construct the query string from the optional filters.">
// <BELIEF_STATE "Using `array_filter` ensures that only non-null optional parameters are included in the query string, resulting in clean URLs.">
protected function defaultQuery(): array
@@ -56,12 +65,4 @@ class GetStepContractorsRequest extends Request
]);
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON array response to a collection of DTOs.">
// <BELIEF_STATE "The API returns a JSON array. Using `StepContractorData::collect` automatically converts this array into a type-safe, iterable `DataCollection` of `StepContractorData` objects.">
public function createDtoFromResponse(Response $response): DataCollection
{
return StepContractorData::collect($response->json(), DataCollection::class);
}
// </SECTION>
}

View File

@@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps\StepData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get a single deal step.">

View File

@@ -17,6 +17,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Spatie\LaravelData\DataCollection;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get all steps for a deal.">
@@ -45,6 +46,14 @@ class GetStepsRequest extends Request
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON array response to a collection of DTOs.">
// <BELIEF_STATE "The API returns a JSON array. Using `StepData::collect` automatically converts this array into a type-safe, iterable `DataCollection` of `StepData` objects.">
public function createDtoFromResponse(Response $response): DataCollection
{
return StepData::collect($response->json(), DataCollection::class);
}
// </SECTION>
// <SECTION name="query_builder" intent="Construct the query string for pagination.">
// <BELIEF_STATE "The `defaultQuery` method properly assigns the pagination parameters to the query string.">
protected function defaultQuery(): array
@@ -55,12 +64,4 @@ class GetStepsRequest extends Request
];
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON array response to a collection of DTOs.">
// <BELIEF_STATE "The API returns a JSON array. Using `StepData::collect` automatically converts this array into a type-safe, iterable `DataCollection` of `StepData` objects.">
public function createDtoFromResponse(Response $response): DataCollection
{
return StepData::collect($response->json(), DataCollection::class);
}
// </SECTION>
}

View File

@@ -36,13 +36,13 @@ class ManageContractorRequest extends Request implements HasBody
return "/api/na/jp/v1/deals/{$this->dealId}/steps/{$this->stepId}/contractors";
}
protected function defaultBody(): array
{
return $this->data;
}
public function createDtoFromResponse(Response $response): GeneralStatusData
{
return GeneralStatusData::from(['success' => $response->successful()]);
}
protected function defaultBody(): array
{
return $this->data;
}
}

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to manage a deal step.">
@@ -47,14 +48,6 @@ class ManageStepRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the complex action payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a StepActionResponseData DTO.">
// <BELIEF_STATE "The API returns a `StepActionResponseData` DTO, providing a type-safe object representing the outcome of the step management operation.">
public function createDtoFromResponse(Response $response): StepActionResponseData
@@ -62,4 +55,12 @@ class ManageStepRequest extends Request implements HasBody
return StepActionResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the complex action payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Deal ID (string).
// OUTPUTS: ValidateDealResponseData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Deals\ValidateDealResponseData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to validate a deal.">

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Request ID (string).
// OUTPUTS: CounterpartyRequestStatusData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\CounterpartyRequestStatusData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get the status of a counterparty operation.">

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: None (implicitly uses connector's authentication).
// OUTPUTS: A collection of NominalAccountData DTOs.
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -37,16 +38,16 @@ class GetNominalAccountsRequest extends Request
return '/api/na/jp/v1/nominal-accounts';
}
protected function defaultQuery(): array
{
return $this->getPaginationQuery();
}
// <SECTION name="response_caster" intent="Map the JSON array response to a collection of DTOs.">
// <BELIEF_STATE "The API returns a JSON array of accounts. Using `NominalAccountData::collect` automatically converts this array into a type-safe, iterable `DataCollection` of `NominalAccountData` objects.">
public function createDtoFromResponse(Response $response): DataCollection
{
return NominalAccountData::collect($response->json(), DataCollection::class);
}
protected function defaultQuery(): array
{
return $this->getPaginationQuery();
}
// </SECTION>
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Unidentified transaction ID and the specific identification request ID.
// OUTPUTS: IdentifyResponseData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Identification;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Identification\IdentifyResponseData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get the status of an identification operation.">

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Account number, and optional pagination parameters.
// OUTPUTS: UnidentifiedTransactionCollectionData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Identification;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Identification\UnidentifiedTransactionC
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get a list of unidentified transactions.">
@@ -43,6 +45,14 @@ class GetUnidentifiedTransactionsRequest extends Request
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a collection DTO.">
// <BELIEF_STATE "Casting the response to an `UnidentifiedTransactionCollectionData` DTO provides a type-safe, iterable object for the list of transactions awaiting identification.">
public function createDtoFromResponse(Response $response): UnidentifiedTransactionCollectionData
{
return UnidentifiedTransactionCollectionData::from($response->json());
}
// </SECTION>
// <SECTION name="query_builder" intent="Construct the query string from the provided parameters.">
// <BELIEF_STATE "Using `array_filter` ensures that only non-null optional parameters are included in the query string, resulting in clean and valid API requests.">
protected function defaultQuery(): array
@@ -54,12 +64,4 @@ class GetUnidentifiedTransactionsRequest extends Request
]);
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a collection DTO.">
// <BELIEF_STATE "Casting the response to an `UnidentifiedTransactionCollectionData` DTO provides a type-safe, iterable object for the list of transactions awaiting identification.">
public function createDtoFromResponse(Response $response): UnidentifiedTransactionCollectionData
{
return UnidentifiedTransactionCollectionData::from($response->json());
}
// </SECTION>
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Unidentified transaction ID, and an IdentifyRequestData DTO.
// OUTPUTS: IdentifyResponseData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Identification;
// <SECTION name="module_imports" intent="Import DTOs and Saloon components for a JSON body request.">
@@ -18,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to identify an unidentified transaction.">
@@ -47,14 +49,6 @@ class IdentifyTransactionRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to an IdentifyResponseData DTO.">
// <BELIEF_STATE "The API returns an `IdentifyResponseData` DTO, providing a type-safe object representing the outcome of the identification process.">
public function createDtoFromResponse(Response $response): IdentifyResponseData
@@ -62,4 +56,12 @@ class IdentifyTransactionRequest extends Request implements HasBody
return IdentifyResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Unidentified transaction ID, and RefundUnidentifiedTransactionRequestData DTO.
// OUTPUTS: RefundUnidentifiedTransactionResponseData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Identification;
// <SECTION name="module_imports" intent="Import DTOs and Saloon components for a JSON body request.">
@@ -18,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to refund an unidentified transaction.">
@@ -47,14 +49,6 @@ class RefundUnidentifiedTransactionRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a RefundUnidentifiedTransactionResponseData DTO.">
// <BELIEF_STATE "The API returns a `RefundUnidentifiedTransactionResponseData` DTO, providing a type-safe object representing the outcome of the refund process.">
public function createDtoFromResponse(Response $response): RefundUnidentifiedTransactionResponseData
@@ -62,4 +56,12 @@ class RefundUnidentifiedTransactionRequest extends Request implements HasBody
return RefundUnidentifiedTransactionResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: PayoffRequestData DTO.
// OUTPUTS: PayoffResponseData DTO.
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts;
// <SECTION name="module_imports" intent="Import DTOs and Saloon components for a JSON body request.">
@@ -18,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to create a payoff.">
@@ -46,14 +48,6 @@ class CreatePayoffRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the complex payment payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a PayoffResponseData DTO.">
// <BELIEF_STATE "The API returns a `PayoffResponseData` DTO, providing a type-safe object representing the outcome of the payoff creation, typically including a request ID and status.">
public function createDtoFromResponse(Response $response): PayoffResponseData
@@ -61,4 +55,12 @@ class CreatePayoffRequest extends Request implements HasBody
return PayoffResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the complex payment payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: TaxRefundRequestData DTO.
// OUTPUTS: TaxRefundResponseData DTO.
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts;
// <SECTION name="module_imports" intent="Import DTOs and Saloon components for a JSON body request.">
@@ -18,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to create a tax refund.">
@@ -46,14 +48,6 @@ class CreateTaxRefundRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the complex refund payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a TaxRefundResponseData DTO.">
// <BELIEF_STATE "The API returns a `TaxRefundResponseData` DTO, providing a type-safe object representing the outcome of the tax refund creation, typically including a request ID and status.">
public function createDtoFromResponse(Response $response): TaxRefundResponseData
@@ -61,4 +55,12 @@ class CreateTaxRefundRequest extends Request implements HasBody
return TaxRefundResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the complex refund payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
}

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Payoff ID (string).
// OUTPUTS: DetailedPayoffData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DetailedPayoffData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get details of a payoff.">

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Payoff ID (string).
// OUTPUTS: PayoffResponseData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\PayoffResponseData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get the status of a payoff.">

View File

@@ -7,6 +7,7 @@ declare(strict_types=1);
// INPUTS: Tax refund ID (string).
// OUTPUTS: TaxRefundResponseData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\TaxRefundResponseData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get the status of a tax refund.">

View File

@@ -27,15 +27,15 @@ class PayoffAcceptRequest extends Request implements HasBody
return "/api/na/jp/v1/payoffs/{$this->payoffId}/accept";
}
public function createDtoFromResponse(Response $response): ResultResponseData
{
return ResultResponseData::from($response->json());
}
protected function defaultBody(): array
{
return [
'accept' => $this->accept,
];
}
public function createDtoFromResponse(Response $response): ResultResponseData
{
return ResultResponseData::from($response->json());
}
}
}

View File

@@ -27,15 +27,15 @@ class TaxRefundAcceptRequest extends Request implements HasBody
return "/api/na/jp/v1/tax-refund/{$this->taxRefundId}/accept";
}
public function createDtoFromResponse(Response $response): ResultResponseData
{
return ResultResponseData::from($response->json());
}
protected function defaultBody(): array
{
return [
'accept' => $this->accept,
];
}
public function createDtoFromResponse(Response $response): ResultResponseData
{
return ResultResponseData::from($response->json());
}
}
}

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to create a new universal recipient.">
@@ -47,14 +48,6 @@ class CreateUniversalRecipientRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method decouples the request from the DTO's internal structure.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `UniversalRecipientResponseData` DTO provides a type-safe object representing the result of the creation.">
public function createDtoFromResponse(Response $response): UniversalRecipientResponseData
@@ -62,4 +55,12 @@ class CreateUniversalRecipientRequest extends Request implements HasBody
return UniversalRecipientResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method decouples the request from the DTO's internal structure.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
}

View File

@@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\UniversalRecipients\UniversalRecipientD
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get a single universal recipient.">

View File

@@ -17,6 +17,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Spatie\LaravelData\DataCollection;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get a list of universal recipients.">
@@ -48,6 +49,14 @@ class GetUniversalRecipientsRequest extends Request
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a collection DTO.">
// <BELIEF_STATE "Casting the response to a `DataCollection` of `UniversalRecipientData` provides a type-safe, iterable object. The specific API response structure requires extracting from the `universalRecipients` key.">
public function createDtoFromResponse(Response $response): DataCollection
{
return UniversalRecipientData::collect($response->json('universalRecipients'), DataCollection::class);
}
// </SECTION>
// <SECTION name="query_builder" intent="Construct the query string from the provided filters.">
// <BELIEF_STATE "Using `array_filter` is a robust way to build the query array, as it automatically omits any optional parameters that were not provided (i.e., are `null`), resulting in a clean URL.">
protected function defaultQuery(): array
@@ -59,15 +68,7 @@ class GetUniversalRecipientsRequest extends Request
'offset' => $this->offset,
'isActive' => $this->isActive,
'date' => $this->date,
], fn($val) => $val !== null);
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a collection DTO.">
// <BELIEF_STATE "Casting the response to a `DataCollection` of `UniversalRecipientData` provides a type-safe, iterable object. The specific API response structure requires extracting from the `universalRecipients` key.">
public function createDtoFromResponse(Response $response): DataCollection
{
return UniversalRecipientData::collect($response->json('universalRecipients'), DataCollection::class);
], fn ($val) => $val !== null);
}
// </SECTION>
}

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to add a requisite to a universal recipient.">
@@ -48,14 +49,6 @@ class AddUniversalRecipientRequisiteRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a RequisiteData DTO.">
// <BELIEF_STATE "The API returns the newly created requisite object. Casting it to a DTO provides a clean, type-safe object for the user.">
public function createDtoFromResponse(Response $response): RequisiteData
@@ -63,4 +56,12 @@ class AddUniversalRecipientRequisiteRequest extends Request implements HasBody
return RequisiteData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Serialize the DTO for the request body.">
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the payload is correctly formatted for the API.">
protected function defaultBody(): array
{
return $this->data->toArray();
}
// </SECTION>
}

View File

@@ -17,6 +17,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Spatie\LaravelData\DataCollection;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get requisites for a universal recipient.">

View File

@@ -36,13 +36,13 @@ class UpdateUniversalRecipientRequisiteRequest extends Request implements HasBod
return "/api/na/jp/v1/universal-recipients/{$this->universalRecipientId}/requisites/{$this->universalRecipientId}";
}
protected function defaultBody(): array
{
return $this->data;
}
public function createDtoFromResponse(Response $response): GeneralStatusData
{
return GeneralStatusData::from(['success' => $response->successful()]);
}
protected function defaultBody(): array
{
return $this->data;
}
}