forked from apoloz/alfa-bank-sdk
Compare commits
4 Commits
v0.0.1.25
...
fix/update
| Author | SHA1 | Date | |
|---|---|---|---|
| a81f6b0d21 | |||
| 88760ed127 | |||
|
|
be2aa4b8d3 | ||
| da3ea113ef |
@@ -23,7 +23,7 @@ class UpdateRequisiteRequest extends Request implements HasBody
|
|||||||
{
|
{
|
||||||
use HasJsonBody;
|
use HasJsonBody;
|
||||||
|
|
||||||
protected Method $method = Method::PUT;
|
protected Method $method = Method::PATCH;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected string $beneficiaryId,
|
protected string $beneficiaryId,
|
||||||
|
|||||||
@@ -4,17 +4,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts;
|
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts;
|
||||||
|
|
||||||
use Apoloz\AlfaBank\Data\Shared\ResultResponseData;
|
use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\PayoffResponseData;
|
||||||
use Saloon\Contracts\Body\HasBody;
|
|
||||||
use Saloon\Enums\Method;
|
use Saloon\Enums\Method;
|
||||||
use Saloon\Http\Request;
|
use Saloon\Http\Request;
|
||||||
use Saloon\Http\Response;
|
use Saloon\Http\Response;
|
||||||
use Saloon\Traits\Body\HasJsonBody;
|
|
||||||
|
|
||||||
class PayoffAcceptRequest extends Request implements HasBody
|
class PayoffAcceptRequest extends Request
|
||||||
{
|
{
|
||||||
use HasJsonBody;
|
|
||||||
|
|
||||||
protected Method $method = Method::PATCH;
|
protected Method $method = Method::PATCH;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@@ -24,18 +20,13 @@ class PayoffAcceptRequest extends Request implements HasBody
|
|||||||
|
|
||||||
public function resolveEndpoint(): string
|
public function resolveEndpoint(): string
|
||||||
{
|
{
|
||||||
return "/api/na/jp/v1/payoffs/{$this->payoffId}/accept";
|
$query = http_build_query(['accept' => $this->accept ? 'true' : 'false']);
|
||||||
|
|
||||||
|
return "/api/na/jp/v1/payoffs/{$this->payoffId}/accept?{$query}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createDtoFromResponse(Response $response): ResultResponseData
|
public function createDtoFromResponse(Response $response): PayoffResponseData
|
||||||
{
|
{
|
||||||
return ResultResponseData::from($response->json());
|
return PayoffResponseData::from($response->json());
|
||||||
}
|
|
||||||
|
|
||||||
protected function defaultBody(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'accept' => $this->accept,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal;
|
|||||||
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
|
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
|
||||||
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
|
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
|
||||||
use Spatie\LaravelData\Data;
|
use Spatie\LaravelData\Data;
|
||||||
|
use Spatie\LaravelData\Attributes\MapName;
|
||||||
|
|
||||||
// </SECTION>
|
// </SECTION>
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ class GetQrcReversalDataResponseData extends Data
|
|||||||
public ?string $qrcId = null,
|
public ?string $qrcId = null,
|
||||||
public ?string $trxDT = null,
|
public ?string $trxDT = null,
|
||||||
public ?string $trxId = null,
|
public ?string $trxId = null,
|
||||||
|
#[MapName('RestAmount')]
|
||||||
public ?string $restAmount = null,
|
public ?string $restAmount = null,
|
||||||
) {}
|
) {}
|
||||||
// </SECTION>
|
// </SECTION>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal;
|
|||||||
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
|
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
|
||||||
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
|
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
|
||||||
use Spatie\LaravelData\Data;
|
use Spatie\LaravelData\Data;
|
||||||
|
use Spatie\LaravelData\Attributes\MapName;
|
||||||
|
|
||||||
// </SECTION>
|
// </SECTION>
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ class QrcReversalResponseData extends Data
|
|||||||
public ?string $trxDT = null,
|
public ?string $trxDT = null,
|
||||||
public ?string $trxId = null,
|
public ?string $trxId = null,
|
||||||
public ?string $payrrn = null,
|
public ?string $payrrn = null,
|
||||||
|
#[MapName('RestAmount')]
|
||||||
public ?string $restAmount = null,
|
public ?string $restAmount = null,
|
||||||
) {}
|
) {}
|
||||||
// </SECTION>
|
// </SECTION>
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ use Apoloz\AlfaBank\Core\AlfaConfig;
|
|||||||
use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\AddressData;
|
use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\AddressData;
|
||||||
use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\CreateBeneficiaryRequestData;
|
use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\CreateBeneficiaryRequestData;
|
||||||
use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\CreateBeneficiaryRequest;
|
use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\CreateBeneficiaryRequest;
|
||||||
|
use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\Requisites\UpdateRequisiteRequest;
|
||||||
use Apoloz\AlfaBank\Services\OpenSslCmsSigner;
|
use Apoloz\AlfaBank\Services\OpenSslCmsSigner;
|
||||||
|
use Saloon\Enums\Method;
|
||||||
use Saloon\Http\Faking\MockResponse;
|
use Saloon\Http\Faking\MockResponse;
|
||||||
use Spatie\LaravelData\DataCollection;
|
use Spatie\LaravelData\DataCollection;
|
||||||
|
|
||||||
@@ -58,3 +60,14 @@ test('can create a beneficiary with automatic signing', function (): void {
|
|||||||
expect($response->status())->toBe(202)
|
expect($response->status())->toBe(202)
|
||||||
->and($response->dto()->requestId)->toBe('req-123');
|
->and($response->dto()->requestId)->toBe('req-123');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('update requisite request uses PATCH', function (): void {
|
||||||
|
$request = new UpdateRequisiteRequest(
|
||||||
|
beneficiaryId: 'ben-1',
|
||||||
|
requisiteId: 'req-1',
|
||||||
|
data: ['phoneNumber' => '79031234567'],
|
||||||
|
);
|
||||||
|
|
||||||
|
expect($request->getMethod())->toBe(Method::PATCH)
|
||||||
|
->and($request->resolveEndpoint())->toBe('/api/na/jp/v1/beneficiaries/ben-1/requisites/req-1');
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user