forked from apoloz/alfa-bank-sdk
38 lines
889 B
PHP
38 lines
889 B
PHP
<?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());
|
|
}
|
|
}
|