slevomat /
csob-gateway
| 1 | <?php declare(strict_types = 1); |
||
| 2 | |||
| 3 | namespace SlevomatCsobGateway\Call; |
||
| 4 | |||
| 5 | use DateTimeImmutable; |
||
| 6 | use SlevomatCsobGateway\Api\ApiClient; |
||
| 7 | use SlevomatCsobGateway\Crypto\SignatureDataFormatter; |
||
| 8 | use SlevomatCsobGateway\Validator; |
||
| 9 | |||
| 10 | class CustomerInfoRequest |
||
| 11 | { |
||
| 12 | |||
| 13 | /** @var string */ |
||
| 14 | private $merchantId; |
||
| 15 | |||
| 16 | /** @var string */ |
||
| 17 | private $customerId; |
||
| 18 | |||
| 19 | 2 | public function __construct( |
|
| 20 | string $merchantId, |
||
| 21 | string $customerId |
||
| 22 | ) |
||
| 23 | { |
||
| 24 | 2 | Validator::checkCustomerId($customerId); |
|
| 25 | |||
| 26 | 2 | $this->merchantId = $merchantId; |
|
| 27 | 2 | $this->customerId = $customerId; |
|
| 28 | 2 | } |
|
| 29 | |||
| 30 | 1 | public function send(ApiClient $apiClient): CustomerInfoResponse |
|
| 31 | { |
||
| 32 | 1 | $response = $apiClient->get( |
|
| 33 | 1 | 'customer/echo/{merchantId}/{customerId}/{dttm}/{signature}', |
|
| 34 | [ |
||
| 35 | 1 | 'merchantId' => $this->merchantId, |
|
| 36 | 1 | 'customerId' => $this->customerId, |
|
| 37 | ], |
||
| 38 | 1 | new SignatureDataFormatter([ |
|
| 39 | 1 | 'merchantId' => null, |
|
| 40 | 'customerId' => null, |
||
| 41 | 'dttm' => null, |
||
| 42 | ]), |
||
| 43 | 1 | new SignatureDataFormatter([ |
|
| 44 | 1 | 'customerId' => null, |
|
| 45 | 'dttm' => null, |
||
| 46 | 'resultCode' => null, |
||
| 47 | 'resultMessage' => null, |
||
| 48 | ]) |
||
| 49 | ); |
||
| 50 | |||
| 51 | 1 | $data = $response->getData(); |
|
| 52 | |||
| 53 | 1 | return new CustomerInfoResponse( |
|
| 54 | 1 | DateTimeImmutable::createFromFormat('YmdHis', $data['dttm']), |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 55 | 1 | ResultCode::get($data['resultCode']), |
|
| 56 | 1 | $data['resultMessage'], |
|
| 57 | 1 | $data['customerId'] ?? null |
|
| 58 | ); |
||
| 59 | } |
||
| 60 | |||
| 61 | } |
||
| 62 |