Skip to content

Commit f3743da

Browse files
authored
Merge pull request #6 from SmartBase-SK/dev_24514
feat(pay_later): add loanPrecalculation operation
2 parents df14dd5 + 9178d1f commit f3743da

12 files changed

+1658
-1637
lines changed

lib/Api/TatraPayPlusAPIApi.php

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class TatraPayPlusAPIApi
4747
'setLogo' => [
4848
'application/json',
4949
],
50+
'loanPrecalculation' => [
51+
'application/json',
52+
],
5053
];
5154
/**
5255
* @var object
@@ -106,7 +109,7 @@ public function __construct(
106109
} else {
107110
$this->client = $client;
108111
}
109-
$this->config = \Tatrapayplus\TatrapayplusApiClient\Configuration::getDefaultConfiguration($mode);
112+
$this->config = new \Tatrapayplus\TatrapayplusApiClient\Configuration($mode);
110113
}
111114

112115
/**
@@ -992,4 +995,69 @@ public function log(HttpResponse $response, array $additional_data = null): void
992995
$this->logger->log($response, $additional_data);
993996
}
994997
}
998+
999+
/**
1000+
* Operation loanPrecalculation
1001+
*
1002+
* Calculate loan parameters from input
1003+
*
1004+
* @param \Tatrapayplus\TatrapayplusApiClient\Model\BasicCalculationRequest precalculation_request Request body (required)
1005+
*
1006+
* @return array of \Tatrapayplus\TatrapayplusApiClient\Model\BasicCalculationResponseItem, HTTP status code, HTTP response headers (array of strings)
1007+
*
1008+
* @throws InvalidArgumentException
1009+
* @throws ApiException on non-2xx response or if the response body is not in the expected format
1010+
*/
1011+
public function loanPrecalculation($precalculation_request)
1012+
{
1013+
$request = $this->loanPrecalculationRequest($precalculation_request);
1014+
1015+
return $this->processRequest($request, '\Tatrapayplus\TatrapayplusApiClient\Model\BasicCalculationResponseItem', '\Tatrapayplus\TatrapayplusApiClient\Model\Model400ErrorBody');
1016+
}
1017+
1018+
/**
1019+
* Create request for operation 'loanPrecalculation'
1020+
*
1021+
* @param \Tatrapayplus\TatrapayplusApiClient\Model\BasicCalculationRequest precalculation_request Request body (required)
1022+
*
1023+
* @return Request
1024+
*
1025+
* @throws InvalidArgumentException
1026+
*/
1027+
public function loanPrecalculationRequest($precalculation_request)
1028+
{
1029+
// verify the required parameter 'precalculation_request' is set
1030+
if ($precalculation_request === null || (is_array($precalculation_request) && count($precalculation_request) === 0)) {
1031+
throw new InvalidArgumentException('Missing the required parameter precalculation_request when calling loanPrecalculation');
1032+
}
1033+
1034+
$resourcePath = '/v1/payments/loans/precalculation';
1035+
1036+
$headers = $this->headerSelector->selectHeaders(
1037+
['application/json'],
1038+
self::contentTypes['loanPrecalculation'][0],
1039+
false
1040+
);
1041+
1042+
$httpBody = static::json_encode(ObjectSerializer::sanitizeForSerialization($precalculation_request));
1043+
1044+
// this endpoint requires OAuth (access token)
1045+
$headers = $this->addAuthHeader($headers);
1046+
1047+
$defaultHeaders = $this->getDefaultHeaders();
1048+
1049+
$headers = array_merge(
1050+
$defaultHeaders,
1051+
$headers
1052+
);
1053+
1054+
$operationHost = $this->config->getHost();
1055+
1056+
return new Request(
1057+
'PUT',
1058+
$operationHost . $resourcePath,
1059+
$headers,
1060+
$httpBody
1061+
);
1062+
}
9951063
}

lib/CurlClient.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public function send(Request $request): HttpResponse
3939
} elseif ($request->method === "PATCH") {
4040
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
4141
curl_setopt($ch, CURLOPT_POSTFIELDS, $request->httpBody);
42+
} elseif ($request->method === "PUT") {
43+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
44+
curl_setopt($ch, CURLOPT_POSTFIELDS, $request->httpBody);
4245
} else {
4346
exit("Unsupported request type");
4447
}

0 commit comments

Comments
 (0)