forked from apoloz/alfa-bank-sdk
fix(formating)
This commit is contained in:
@@ -31,13 +31,13 @@ class GetAccountsRequest extends Request implements Paginatable
|
||||
return '/api/pp/v1/accounts';
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return $this->getPaginationQuery();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return AccountData::collect($response->json('accounts'), DataCollection::class);
|
||||
}
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return $this->getPaginationQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ class CheckComplianceRequest extends Request
|
||||
return '/api/aff/jp/v1/creditors/compliance';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): AffResponseData
|
||||
{
|
||||
return AffResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return [
|
||||
@@ -30,9 +35,4 @@ class CheckComplianceRequest extends Request
|
||||
'name' => $this->name,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): AffResponseData
|
||||
{
|
||||
return AffResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class CreateRegisterRequest extends Request implements HasBody
|
||||
return '/api/aff/jp/v1/registers';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): AffResponseData
|
||||
{
|
||||
return AffResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,4 +29,4 @@ class DownloadRegisterDocumentsRequest extends Request
|
||||
'size' => strlen($response->body()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,4 +26,4 @@ class GetPaymentStatusRequest extends Request
|
||||
{
|
||||
return AffResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,15 +27,15 @@ class SignRegisterRequest extends Request implements HasBody
|
||||
return '/api/aff/jp/v1/registers/sign';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from([
|
||||
'success' => $response->successful(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasFormBody;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a class for the OAuth 2.0 token endpoint request.">
|
||||
@@ -55,6 +56,14 @@ class GetTokenRequest extends Request implements HasBody
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw JSON response into a structured TokenData DTO.">
|
||||
// <BELIEF_STATE "Automatically casting the JSON token response into a `TokenData` DTO provides type safety and a clean, object-oriented way to access token properties like `access_token` and `expires_in`.">
|
||||
public function createDtoFromResponse(Response $response): TokenData
|
||||
{
|
||||
return TokenData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="request_body_builder" intent="Construct the form-urlencoded body for the token request.">
|
||||
// <BELIEF_STATE "This method builds the request body array. It correctly maps the class properties to the `snake_case` parameter names expected by the OAuth 2.0 standard.">
|
||||
protected function defaultBody(): array
|
||||
@@ -64,7 +73,7 @@ class GetTokenRequest extends Request implements HasBody
|
||||
'client_id' => $this->clientId,
|
||||
'client_secret' => $this->clientSecret,
|
||||
];
|
||||
|
||||
|
||||
if ($this->grantType === 'authorization_code') {
|
||||
$body['code'] = $this->code;
|
||||
$body['redirect_uri'] = $this->redirectUri;
|
||||
@@ -77,12 +86,4 @@ class GetTokenRequest extends Request implements HasBody
|
||||
return $body;
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw JSON response into a structured TokenData DTO.">
|
||||
// <BELIEF_STATE "Automatically casting the JSON token response into a `TokenData` DTO provides type safety and a clean, object-oriented way to access token properties like `access_token` and `expires_in`.">
|
||||
public function createDtoFromResponse(Response $response): TokenData
|
||||
{
|
||||
return TokenData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\Auth\ClientSecretData;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a class for refreshing an OAuth client secret.">
|
||||
|
||||
@@ -18,6 +18,7 @@ use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasFormBody;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a class for the OAuth 2.0 token revocation endpoint request.">
|
||||
@@ -52,6 +53,12 @@ class RevokeTokenRequest extends Request implements HasBody
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="request_body_builder" intent="Construct the form-urlencoded body for the revocation request.">
|
||||
// <BELIEF_STATE "This method correctly builds the request body array, including optional parameters. `array_filter` is used to gracefully omit null values from the final payload.">
|
||||
protected function defaultBody(): array
|
||||
@@ -63,10 +70,4 @@ class RevokeTokenRequest extends Request implements HasBody
|
||||
'token_type_hint' => $this->tokenTypeHint,
|
||||
]);
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\Auth\UserInfo\ClientConsentCollectionData;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a class for retrieving client consents.">
|
||||
@@ -47,6 +48,14 @@ class GetClientConsentsRequest extends Request
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw JSON response into a structured ClientConsentCollectionData DTO.">
|
||||
// <BELIEF_STATE "Automatically casting the JSON response to a `ClientConsentCollectionData` DTO provides type safety and a clean, object-oriented way to access the list of consents and any associated metadata.">
|
||||
public function createDtoFromResponse(Response $response): ClientConsentCollectionData
|
||||
{
|
||||
return ClientConsentCollectionData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="query_parameter_builder" intent="Construct the query string for filtering and pagination.">
|
||||
// <BELIEF_STATE "The `array_filter` function is used to dynamically build the query parameters, ensuring that only non-null values are included in the request, which results in clean and efficient API calls.">
|
||||
protected function defaultQuery(): array
|
||||
@@ -58,15 +67,7 @@ class GetClientConsentsRequest extends Request
|
||||
'isActive' => $this->isActive,
|
||||
'limit' => $this->limit,
|
||||
'offset' => $this->offset,
|
||||
], fn($value) => $value !== null);
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw JSON response into a structured ClientConsentCollectionData DTO.">
|
||||
// <BELIEF_STATE "Automatically casting the JSON response to a `ClientConsentCollectionData` DTO provides type safety and a clean, object-oriented way to access the list of consents and any associated metadata.">
|
||||
public function createDtoFromResponse(Response $response): ClientConsentCollectionData
|
||||
{
|
||||
return ClientConsentCollectionData::from($response->json());
|
||||
], fn ($value) => $value !== null);
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\Auth\UserInfo\UserInfoData;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a class for the OIDC UserInfo endpoint request.">
|
||||
@@ -33,6 +34,26 @@ class GetUserInfoRequest extends Request
|
||||
{
|
||||
return '/oidc/userinfo';
|
||||
}
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw JWT response into a structured UserInfoData DTO.">
|
||||
// <BELIEF_STATE "The API returns a JWT token in the response body. This method manually decodes the JWT payload (assuming it's a standard JWS) and casts it to a `UserInfoData` DTO, providing type safety and structured access to the user claims. A fallback is provided for invalid formats.">
|
||||
public function createDtoFromResponse(Response $response): UserInfoData
|
||||
{
|
||||
$jwt = $response->body();
|
||||
$parts = explode('.', $jwt);
|
||||
|
||||
if (count($parts) === 3) {
|
||||
$payload = json_decode(base64_decode($parts[1]), true);
|
||||
|
||||
return UserInfoData::from($payload);
|
||||
}
|
||||
|
||||
// Fallback or throw error?
|
||||
// If the response is not a valid JWT (e.g. error json), Saloon might have handled it if we throw on error status.
|
||||
// But if it's 200 OK and not a JWT, it's unexpected.
|
||||
|
||||
throw new \Exception('Invalid UserInfo response format. Expected JWT.');
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="default_headers" intent="Set the required 'Accept' header for a JWT response.">
|
||||
@@ -43,24 +64,5 @@ class GetUserInfoRequest extends Request
|
||||
'Accept' => 'application/jwt', // As per doc
|
||||
];
|
||||
}
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw JWT response into a structured UserInfoData DTO.">
|
||||
// <BELIEF_STATE "The API returns a JWT token in the response body. This method manually decodes the JWT payload (assuming it's a standard JWS) and casts it to a `UserInfoData` DTO, providing type safety and structured access to the user claims. A fallback is provided for invalid formats.">
|
||||
public function createDtoFromResponse(Response $response): UserInfoData
|
||||
{
|
||||
$jwt = $response->body();
|
||||
$parts = explode('.', $jwt);
|
||||
|
||||
if (count($parts) === 3) {
|
||||
$payload = json_decode(base64_decode($parts[1]), true);
|
||||
return UserInfoData::from($payload);
|
||||
}
|
||||
|
||||
// Fallback or throw error?
|
||||
// If the response is not a valid JWT (e.g. error json), Saloon might have handled it if we throw on error status.
|
||||
// But if it's 200 OK and not a JWT, it's unexpected.
|
||||
|
||||
throw new \Exception("Invalid UserInfo response format. Expected JWT.");
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ class CheckMerchantRequest extends Request
|
||||
return "/api/1c/merchants/{$this->merchantId}";
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): MerchantData
|
||||
{
|
||||
return MerchantData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultHeaders(): array
|
||||
{
|
||||
return [
|
||||
'Authorization-1C' => $this->auth1C,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): MerchantData
|
||||
{
|
||||
return MerchantData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ class GetPaymentLinkRequest extends Request
|
||||
return "/api/1c/payment-link/{$this->qrId}";
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): PaymentLinkData
|
||||
{
|
||||
return PaymentLinkData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultHeaders(): array
|
||||
{
|
||||
return [
|
||||
'Authorization-1C' => $this->auth1C,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): PaymentLinkData
|
||||
{
|
||||
return PaymentLinkData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,11 @@ class SearchPaymentsRequest extends Request implements HasBody
|
||||
return '/api/1c/payments/search';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return Payment1CData::collect($response->json(), DataCollection::class);
|
||||
}
|
||||
|
||||
protected function defaultHeaders(): array
|
||||
{
|
||||
return [
|
||||
@@ -39,9 +44,4 @@ class SearchPaymentsRequest extends Request implements HasBody
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return Payment1CData::collect($response->json(), DataCollection::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class CreateB2CPaymentRequest extends Request implements HasBody
|
||||
return '/api/b2cpay/jp/v1/payments';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): B2CPaymentResponseData
|
||||
{
|
||||
return B2CPaymentResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@ class GetB2CPaymentReportRequest extends Request
|
||||
return '/api/b2cpay/jp/v1/payments';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): B2CPaymentReportData
|
||||
{
|
||||
return B2CPaymentReportData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return array_filter([
|
||||
@@ -36,9 +41,4 @@ class GetB2CPaymentReportRequest extends Request
|
||||
'transactionId' => $this->transactionId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): B2CPaymentReportData
|
||||
{
|
||||
return B2CPaymentReportData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ class ResolveClaimRequest extends Request implements HasBody
|
||||
return "/api/claims/pp/v1/claims/{$this->claimId}";
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,15 +27,15 @@ class ConfirmSigningWithSmsRequest extends Request implements HasBody
|
||||
return "/api/jp/v3/signature/requests/operations/{$this->operationId}";
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'smsCode' => $this->smsCode,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ class IssueRsaCertificateRequest extends Request implements HasBody
|
||||
return '/api/jp/v3/signature/rsa-certificates/requests/issue';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): CloudSignatureResponseData
|
||||
{
|
||||
return CloudSignatureResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return array_filter([
|
||||
@@ -34,9 +39,4 @@ class IssueRsaCertificateRequest extends Request implements HasBody
|
||||
'pkcs10Content' => $this->pkcs10Content,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): CloudSignatureResponseData
|
||||
{
|
||||
return CloudSignatureResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,4 @@ class GetCertificatesRequest extends Request
|
||||
{
|
||||
return CertificateData::collect($response->json('certificates') ?? [], DataCollection::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,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 a class for updating a cryptographic certificate's status.">
|
||||
@@ -49,6 +50,14 @@ class UpdateCertificateRequest extends Request implements HasBody
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw JSON response into a structured CertificateData DTO.">
|
||||
// <BELIEF_STATE "Automatically casting the JSON response to a `CertificateData` DTO provides type safety and a clean, object-oriented way to access the details of the updated certificate.">
|
||||
public function createDtoFromResponse(Response $response): CertificateData
|
||||
{
|
||||
return CertificateData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="request_body_builder" intent="Construct the JSON body for the certificate update request (JSON Patch format).">
|
||||
// <BELIEF_STATE "This method builds the request body in a JSON Patch-like format, specifying the `op` (operation), `path` (field to update), and `value` (new status). This is a common pattern for partial updates in REST APIs.">
|
||||
protected function defaultBody(): array
|
||||
@@ -60,12 +69,4 @@ class UpdateCertificateRequest extends Request implements HasBody
|
||||
];
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw JSON response into a structured CertificateData DTO.">
|
||||
// <BELIEF_STATE "Automatically casting the JSON response to a `CertificateData` DTO provides type safety and a clean, object-oriented way to access the details of the updated certificate.">
|
||||
public function createDtoFromResponse(Response $response): CertificateData
|
||||
{
|
||||
return CertificateData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -18,6 +18,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 a class for uploading a cryptographic certificate.">
|
||||
@@ -47,6 +48,14 @@ class UploadCertificateRequest extends Request implements HasBody
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw JSON response into a structured CertificateData DTO.">
|
||||
// <BELIEF_STATE "Automatically casting the JSON response to a `CertificateData` DTO provides type safety and a clean, object-oriented way to access the details of the newly uploaded certificate.">
|
||||
public function createDtoFromResponse(Response $response): CertificateData
|
||||
{
|
||||
return CertificateData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="request_body_builder" intent="Construct the JSON body for the certificate upload request.">
|
||||
// <BELIEF_STATE "This method builds the request body array, mapping the constructor properties to the expected JSON payload.">
|
||||
protected function defaultBody(): array
|
||||
@@ -57,12 +66,4 @@ class UploadCertificateRequest extends Request implements HasBody
|
||||
];
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw JSON response into a structured CertificateData DTO.">
|
||||
// <BELIEF_STATE "Automatically casting the JSON response to a `CertificateData` DTO provides type safety and a clean, object-oriented way to access the details of the newly uploaded certificate.">
|
||||
public function createDtoFromResponse(Response $response): CertificateData
|
||||
{
|
||||
return CertificateData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@ class GetDfaInitialPlacementListRequest extends Request implements Paginatable
|
||||
return '/api/dfa/gd/v1/dfa-profile/initial-placement-list';
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return $this->getPaginationQuery();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return DfaInitialPlacementData::collect($response->json('items') ?? [], DataCollection::class);
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return $this->getPaginationQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class CreateDebitCardApplicationRequest extends Request implements HasBody
|
||||
return '/api/pp/v1/debit-cards/application';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DebitCardApplicationResponseData
|
||||
{
|
||||
return DebitCardApplicationResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,11 @@ class GetEscrowOrdersRequest extends Request implements Paginatable
|
||||
return '/api/escrow-orders';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return EscrowOrderData::collect($response->json('orders') ?? [], DataCollection::class);
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return array_merge([
|
||||
@@ -40,9 +45,4 @@ class GetEscrowOrdersRequest extends Request implements Paginatable
|
||||
'filterToDate' => $this->filterToDate,
|
||||
], $this->getPaginationQuery());
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return EscrowOrderData::collect($response->json('orders') ?? [], DataCollection::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\Shared\DownloadedFileData;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a class for downloading a file.">
|
||||
@@ -41,6 +42,15 @@ class DownloadFileRequest extends Request
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): DownloadedFileData
|
||||
{
|
||||
return DownloadedFileData::from([
|
||||
'content' => $response->body(),
|
||||
'size' => strlen($response->body()),
|
||||
]);
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="default_headers" intent="Set the necessary HTTP headers for accepting any content type.">
|
||||
// <BELIEF_STATE "Setting `Accept: */*` indicates to the server that the client can handle any content type, which is appropriate when downloading arbitrary files.">
|
||||
protected function defaultHeaders(): array
|
||||
@@ -49,13 +59,4 @@ class DownloadFileRequest extends Request
|
||||
'Accept' => '*/*',
|
||||
];
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): DownloadedFileData
|
||||
{
|
||||
return DownloadedFileData::from([
|
||||
'content' => $response->body(),
|
||||
'size' => strlen($response->body()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasStreamBody;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a class for uploading a file via a stream.">
|
||||
@@ -47,13 +48,19 @@ class UploadFileRequest extends Request implements HasBody
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="default_headers" intent="Set the necessary HTTP headers for a binary file upload.">
|
||||
// <BELIEF_STATE "Headers like `Accept: */*`, `Content-Length`, and `Content-Type: application/octet-stream` are crucial for correctly indicating the nature of the streamed binary data to the server.">
|
||||
protected function defaultHeaders(): array
|
||||
{
|
||||
return [
|
||||
'Accept' => '*/*',
|
||||
'Content-Length' => (string)$this->fileSize,
|
||||
'Content-Length' => (string) $this->fileSize,
|
||||
'Content-Type' => 'application/octet-stream',
|
||||
];
|
||||
}
|
||||
@@ -65,10 +72,4 @@ class UploadFileRequest extends Request implements HasBody
|
||||
{
|
||||
return $this->fileStream;
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ class UploadFileRequest extends Request implements HasBody
|
||||
protected Method $method = Method::PUT;
|
||||
|
||||
/**
|
||||
* @param string $url Full pre-signed URL from Alfa Bank
|
||||
* @param mixed $resource File resource or stream
|
||||
* @param string $url Full pre-signed URL from Alfa Bank
|
||||
* @param mixed $resource File resource or stream
|
||||
*/
|
||||
public function __construct(
|
||||
protected string $url,
|
||||
|
||||
@@ -31,13 +31,13 @@ class ExecuteOrderActionRequest extends Request implements HasBody
|
||||
return "/api/logistics/jp/v1/partners/channels/{$this->channelId}/providers/{$this->providerId}/orders/{$this->orderId}/actions/{$this->action}";
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,11 @@ class GetDeliveriesRequest extends Request
|
||||
return '/api/logistics/jp/v1/partners/deliveries';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return DeliveryData::collect($response->json('items') ?? [], DataCollection::class);
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return [
|
||||
@@ -33,9 +38,4 @@ class GetDeliveriesRequest extends Request
|
||||
'offset' => $this->offset,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return DeliveryData::collect($response->json('items') ?? [], DataCollection::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ class GetLoyaltyTransactionsRequest extends Request implements HasBody
|
||||
return '/api/pp/v1/bonus-account-transactions';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return LoyaltyTransactionData::collect($response->json('transactions') ?? [], DataCollection::class);
|
||||
}
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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.">
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class CreateAfishaOrderRequest extends Request implements HasBody
|
||||
return '/api/order-core/pp/v1/afisha/orders';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): OrderResponseData
|
||||
{
|
||||
return OrderResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class CreateTravelOrderRequest extends Request implements HasBody
|
||||
return '/api/order-core/pp/v1/travel/orders';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): OrderResponseData
|
||||
{
|
||||
return OrderResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Requests\Partner;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
|
||||
@@ -26,6 +26,11 @@ class GetPartnerApplicationsRequest extends Request
|
||||
return '/api/partner/jp/v1/individuals';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return PartnerApplicationData::collect($response->json('items') ?? [], DataCollection::class);
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return array_filter([
|
||||
@@ -35,9 +40,4 @@ class GetPartnerApplicationsRequest extends Request
|
||||
'offset' => $this->offset,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return PartnerApplicationData::collect($response->json('items') ?? [], DataCollection::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,6 @@ class CreatePaymentRequest extends Request implements HasBody
|
||||
return '/api/jp/v2/payments';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): PaymentResponseData
|
||||
{
|
||||
return PaymentResponseData::from([
|
||||
@@ -39,4 +34,9 @@ class CreatePaymentRequest extends Request implements HasBody
|
||||
'status' => $response->status() === 201 ? 'CREATED' : 'ERROR',
|
||||
]);
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,4 @@ class CreatePoaRequest extends Request
|
||||
{
|
||||
return PoaResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,4 +26,4 @@ class GetPoaRequestStatusRequest extends Request
|
||||
{
|
||||
return PoaResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class CreateRegistryRequest extends Request implements HasBody
|
||||
return '/api/jp/v1/registries';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): RegistryResponseData
|
||||
{
|
||||
return RegistryResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class CreateSelfEncashmentRegistryRequest extends Request implements HasBody
|
||||
return '/api/jp/v1/self-encashment/registries';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): RegistryResponseData
|
||||
{
|
||||
return RegistryResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,17 +30,17 @@ class SignRegistryRequest extends Request implements HasBody
|
||||
return "/api/jp/v1/registries/{$this->registryId}/signatures";
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'digestSignatures' => $this->signatures->toArray(),
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from([
|
||||
'success' => $response->successful(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'digestSignatures' => $this->signatures->toArray(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Requests\Reports;
|
||||
|
||||
use Apoloz\AlfaBank\Data\Reports\AccountBalanceReportData;
|
||||
use Apoloz\AlfaBank\Data\Registries\RegistryResponseData;
|
||||
use Apoloz\AlfaBank\Data\Reports\AccountBalanceReportData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
@@ -26,16 +26,17 @@ class CreateAccountBalanceReportRequest extends Request implements HasBody
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
$path = $this->language === 'eng' ? 'eng' : 'rus';
|
||||
return "/api/pp/v1/reports/type/account/balance/{$path}";
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
return "/api/pp/v1/reports/type/account/balance/{$path}";
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): RegistryResponseData
|
||||
{
|
||||
return RegistryResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,11 @@ class CreateAccountApplicationRequest extends Request implements HasBody
|
||||
return '/api/jp/v1/salary-project/accounts/applications';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): SalaryApplicationResponseData
|
||||
{
|
||||
return SalaryApplicationResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultHeaders(): array
|
||||
{
|
||||
return array_filter([
|
||||
@@ -39,9 +44,4 @@ class CreateAccountApplicationRequest extends Request implements HasBody
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): SalaryApplicationResponseData
|
||||
{
|
||||
return SalaryApplicationResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,11 @@ class CreatePayrollApplicationRequest extends Request implements HasBody
|
||||
return '/api/jp/v1/salary-project/payroll/applications';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): SalaryApplicationResponseData
|
||||
{
|
||||
return SalaryApplicationResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultHeaders(): array
|
||||
{
|
||||
return array_filter([
|
||||
@@ -39,9 +44,4 @@ class CreatePayrollApplicationRequest extends Request implements HasBody
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): SalaryApplicationResponseData
|
||||
{
|
||||
return SalaryApplicationResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 a class for creating a test RUB payment in the Sandbox.">
|
||||
@@ -47,16 +48,16 @@ class CreateRubPaymentRequest extends Request implements HasBody
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="request_body_builder" intent="Construct the JSON body for the test payment request.">
|
||||
// <BELIEF_STATE "Delegating serialization to the DTO's `toArray` method ensures the test payment payload is correctly formatted for the Sandbox API.">
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ class SignatureEncryptionTestRequest extends Request implements HasBody
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
/**
|
||||
* @param string $data Raw content (JWS, TEXT or XML)
|
||||
* @param string $format json|text|xml
|
||||
* @param string $requestSecurity NO|SIGNATURE|ENCRYPTION
|
||||
* @param string $responseSecurity NO|SIGNATURE|ENCRYPTION
|
||||
* @param string $data Raw content (JWS, TEXT or XML)
|
||||
* @param string $format json|text|xml
|
||||
* @param string $requestSecurity NO|SIGNATURE|ENCRYPTION
|
||||
* @param string $responseSecurity NO|SIGNATURE|ENCRYPTION
|
||||
*/
|
||||
public function __construct(
|
||||
protected string $data,
|
||||
@@ -51,4 +51,4 @@ class SignatureEncryptionTestRequest extends Request implements HasBody
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,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 a class for triggering a test webhook event in the Sandbox.">
|
||||
@@ -46,6 +47,12 @@ class TriggerWebhookEventRequest extends Request implements HasBody
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="request_body_builder" intent="Construct the JSON body for the webhook event trigger request.">
|
||||
// <BELIEF_STATE "This method builds the request body array, mapping the constructor property to the expected JSON payload for event simulation.">
|
||||
protected function defaultBody(): array
|
||||
@@ -54,10 +61,4 @@ class TriggerWebhookEventRequest extends Request implements HasBody
|
||||
'object' => $this->object,
|
||||
];
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ class GetComplianceScoreRequest extends Request
|
||||
return '/api/mathmod-scorings/jp/v1/compliance';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): ComplianceScoreData
|
||||
{
|
||||
return ComplianceScoreData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return [
|
||||
'inn' => $this->inn,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): ComplianceScoreData
|
||||
{
|
||||
return ComplianceScoreData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ class GetSubscriptionsRequest extends Request
|
||||
return '/api/alfa-security/jp/v1/subscription-api/client/subscriptions';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return SecuritySubscriptionData::collect($response->json('subscriptions') ?? [], DataCollection::class);
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return [
|
||||
'active' => $this->active,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return SecuritySubscriptionData::collect($response->json('subscriptions') ?? [], DataCollection::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class CreateAgreementLinkRequest extends Request implements HasBody
|
||||
return '/api/semp/v1/agreement-pages';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): AgreementLinkData
|
||||
{
|
||||
return AgreementLinkData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class CreatePayoutRequest extends Request implements HasBody
|
||||
return '/api/semp/v1/payouts/registries/with-selfemployed-check-status';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): PayoutResponseData
|
||||
{
|
||||
return PayoutResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class GetTaxpayerStatusRequest extends Request implements HasBody
|
||||
return '/api/semp/v1/selfemployed/taxpayer-statuses';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): TaxpayerStatusResponseData
|
||||
{
|
||||
return TaxpayerStatusResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class RegisterIncomeRequest extends Request implements HasBody
|
||||
return '/semp/v1/selfemployed/income';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): CreateIncomeResponseData
|
||||
{
|
||||
return CreateIncomeResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use Apoloz\AlfaBank\Data\Shared\DownloadedFileData;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define the request for fetching 1C formatted transactions.">
|
||||
@@ -45,6 +46,15 @@ class GetTransactions1CRequest extends Request
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): DownloadedFileData
|
||||
{
|
||||
return DownloadedFileData::from([
|
||||
'content' => $response->body(),
|
||||
'size' => strlen($response->body()),
|
||||
]);
|
||||
}
|
||||
// </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`) that will be appended to the request URL. These parameters are crucial for filtering the transaction data by date range, directly influencing the scope of the API response.">
|
||||
protected function defaultQuery(): array
|
||||
@@ -54,14 +64,5 @@ class GetTransactions1CRequest extends Request
|
||||
'dateTo' => $this->dateTo,
|
||||
];
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): DownloadedFileData
|
||||
{
|
||||
return DownloadedFileData::from([
|
||||
'content' => $response->body(),
|
||||
'size' => strlen($response->body()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
@@ -17,6 +17,7 @@ use Apoloz\AlfaBank\Data\Shared\DownloadedFileData;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define the request for fetching MT940 formatted transactions.">
|
||||
@@ -45,6 +46,15 @@ class GetTransactionsMT940Request extends Request
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): DownloadedFileData
|
||||
{
|
||||
return DownloadedFileData::from([
|
||||
'content' => $response->body(),
|
||||
'size' => strlen($response->body()),
|
||||
]);
|
||||
}
|
||||
// </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`) that will be appended to the request URL. These parameters are crucial for filtering the transaction data by date range, directly influencing the scope of the API response.">
|
||||
protected function defaultQuery(): array
|
||||
@@ -54,14 +64,5 @@ class GetTransactionsMT940Request extends Request
|
||||
'dateTo' => $this->dateTo,
|
||||
];
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
public function createDtoFromResponse(Response $response): DownloadedFileData
|
||||
{
|
||||
return DownloadedFileData::from([
|
||||
'content' => $response->body(),
|
||||
'size' => strlen($response->body()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
@@ -40,6 +40,14 @@ class GetTransactionsRequest extends Request
|
||||
{
|
||||
return '/api/jp/v1/statement/transactions';
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw API JSON response into a structured collection DTO.">
|
||||
// <BELIEF_STATE "The API returns a list of transactions. Casting this directly to a `TransactionCollectionData` DTO provides a type-safe, iterable object for the end-user, which is a significant improvement over dealing with raw arrays.">
|
||||
public function createDtoFromResponse(Response $response): TransactionCollectionData
|
||||
{
|
||||
return TransactionCollectionData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
@@ -50,12 +58,4 @@ class GetTransactionsRequest extends Request
|
||||
], $this->getPaginationQuery());
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_dto_caster" intent="Transform the raw API JSON response into a structured collection DTO.">
|
||||
// <BELIEF_STATE "The API returns a list of transactions. Casting this directly to a `TransactionCollectionData` DTO provides a type-safe, iterable object for the end-user, which is a significant improvement over dealing with raw arrays.">
|
||||
public function createDtoFromResponse(Response $response): TransactionCollectionData
|
||||
{
|
||||
return TransactionCollectionData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class CreateWebhookRequest extends Request implements HasBody
|
||||
return '/api/v2/webhooks';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): WebhookSubscriptionData
|
||||
{
|
||||
return WebhookSubscriptionData::from($response->json());
|
||||
}
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,4 @@ class DeleteWebhookRequest extends Request
|
||||
'success' => $response->status() === 204 || $response->successful(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,4 +26,4 @@ class GetWebhookRequest extends Request
|
||||
{
|
||||
return WebhookSubscriptionData::from($response->json());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,15 +31,15 @@ class GetWebhooksRequest extends Request
|
||||
return '/api/v2/webhooks';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return WebhookSubscriptionData::collect($response->json(), DataCollection::class);
|
||||
}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return array_filter(array_merge([
|
||||
'object' => $this->object,
|
||||
], $this->getPaginationQuery()));
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): DataCollection
|
||||
{
|
||||
return WebhookSubscriptionData::collect($response->json(), DataCollection::class);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user