forked from apoloz/alfa-bank-sdk
refactor(core): enhance SDK structure and documentation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
37
src/Requests/B2C/CreateB2CPaymentRequest.php
Normal file
37
src/Requests/B2C/CreateB2CPaymentRequest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Apoloz\AlfaBank\Requests\B2C;
|
||||
|
||||
use Apoloz\AlfaBank\Data\B2C\B2CPaymentRequestData;
|
||||
use Apoloz\AlfaBank\Data\B2C\B2CPaymentResponseData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class CreateB2CPaymentRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected B2CPaymentRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user