Skip to content

Commit c72b7e2

Browse files
committed
FN-14504 Added GetCreditors request/response classes and getCreditors method to retrieve available creditors grouped by product type.
1 parent fac28b0 commit c72b7e2

3 files changed

Lines changed: 71 additions & 1 deletion

File tree

src/Api/Client.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Comfino\Api\Request\GetOrder as GetOrderRequest;
1919
use Comfino\Api\Request\GetPaywall as GetPaywallRequest;
2020
use Comfino\Api\Request\GetPaywallItemDetails as GetPaywallItemDetailsRequest;
21+
use Comfino\Api\Request\GetCreditors as GetCreditorsRequest;
2122
use Comfino\Api\Request\GetProductTypes as GetProductTypesRequest;
2223
use Comfino\Api\Request\GetWidgetKey as GetWidgetKeyRequest;
2324
use Comfino\Api\Request\GetWidgetTypes as GetWidgetTypesRequest;
@@ -29,6 +30,7 @@
2930
use Comfino\Api\Response\GetOrder as GetOrderResponse;
3031
use Comfino\Api\Response\GetPaywall as GetPaywallResponse;
3132
use Comfino\Api\Response\GetPaywallItemDetails as GetPaywallItemDetailsResponse;
33+
use Comfino\Api\Response\GetCreditors as GetCreditorsResponse;
3234
use Comfino\Api\Response\GetProductTypes as GetProductTypesResponse;
3335
use Comfino\Api\Response\GetWidgetKey as GetWidgetKeyResponse;
3436
use Comfino\Api\Response\GetWidgetTypes as GetWidgetTypesResponse;
@@ -390,7 +392,7 @@ public function validateOrder(OrderInterface $order): ValidateOrderResponse
390392
}
391393

392394
/**
393-
* Returns a details of specified loan application.
395+
* Returns details of a specified loan application.
394396
*
395397
* @param string $orderId Loan application ID returned by createOrder action.
396398
*
@@ -445,6 +447,23 @@ public function getProductTypes(ProductTypesListTypeEnum $listType): GetProductT
445447
return new GetProductTypesResponse($this->request, $this->sendRequest($this->request), $this->serializer);
446448
}
447449

450+
/**
451+
* Returns a map of available creditors grouped by product type for an authorized shop account.
452+
*
453+
* @throws RequestValidationError
454+
* @throws ResponseValidationError
455+
* @throws AuthorizationError
456+
* @throws AccessDenied
457+
* @throws ServiceUnavailable
458+
* @throws ClientExceptionInterface
459+
*/
460+
public function getCreditors(): GetCreditorsResponse
461+
{
462+
$this->request = (new GetCreditorsRequest())->setSerializer($this->serializer);
463+
464+
return new GetCreditorsResponse($this->request, $this->sendRequest($this->request), $this->serializer);
465+
}
466+
448467
/**
449468
* Returns a widget key associated with an authorized shop account.
450469
*

src/Api/Request/GetCreditors.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Comfino\Api\Request;
6+
7+
use Comfino\Api\Request;
8+
9+
/**
10+
* Available creditors list request.
11+
*/
12+
class GetCreditors extends Request
13+
{
14+
public function __construct()
15+
{
16+
$this->setRequestMethod('GET');
17+
$this->setApiEndpointPath('creditors');
18+
}
19+
20+
/**
21+
* @inheritDoc
22+
*/
23+
protected function prepareRequestBody(): ?array
24+
{
25+
return null;
26+
}
27+
}

src/Api/Response/GetCreditors.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Comfino\Api\Response;
6+
7+
/**
8+
* Available creditors list response.
9+
*/
10+
class GetCreditors extends Base
11+
{
12+
/** @var array<string, string[]> */
13+
public readonly array $creditors;
14+
15+
/**
16+
* @inheritDoc
17+
*/
18+
protected function processResponseBody(array|string|bool|null|float|int $deserializedResponseBody): void
19+
{
20+
$this->checkResponseType($deserializedResponseBody, 'array');
21+
22+
$this->creditors = $deserializedResponseBody;
23+
}
24+
}

0 commit comments

Comments
 (0)