Skip to content

Commit 8e294c9

Browse files
committed
The mocking api is now availble
1 parent 4f3d1df commit 8e294c9

4 files changed

Lines changed: 50 additions & 8 deletions

File tree

.openapi-generator/templates/ApiClient.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,23 @@ class ApiClient extends \GuzzleHttp\Client
3636
*/
3737
protected $pSUIPAddress = null;
3838

39+
/**
40+
* Use mocking for api calls ?
41+
* @var boolean
42+
*/
43+
protected $mockMode = false;
3944

4045
/**
4146
* @inheritDoc
4247
*
4348
* $config['clientid'] - obtained from Developer Portal - when you registered your app with us.
4449
* $config['cert'] = ['/path/to/cert.p12','certificat password']
4550
* $config['clientpubip'] = the closest IP address to the real end-user
51+
* $config['mocking'] = true to use /rbcz/premium/mock/* endpoints
4652
*
4753
* @param array $config
48-
* @throws Exception CERT_FILE is not set
49-
* @throws Exception CERT_PASS is not set
54+
* @throws \Exception CERT_FILE is not set
55+
* @throws \Exception CERT_PASS is not set
5056
*/
5157
public function __construct(array $config = [])
5258
{
@@ -57,10 +63,10 @@ public function __construct(array $config = [])
5763
if (array_key_exists('cert', $config) === false) {
5864
$config['cert'] = [\Ease\Functions::cfg('CERT_FILE'), \Ease\Functions::cfg('CERT_PASS')];
5965
if (empty($config['cert'][0])) {
60-
throw new Exception('Certificate (CERT_FILE) not specified');
66+
throw new \Exception('Certificate (CERT_FILE) not specified');
6167
}
6268
if (empty($config['cert'][1])) {
63-
throw new Exception('Certificate password (CERT_PASS) not specified');
69+
throw new \Exception('Certificate password (CERT_PASS) not specified');
6470
}
6571
}
6672

@@ -71,6 +77,10 @@ public function __construct(array $config = [])
7177
if(array_key_exists('clientpubip', $config)){
7278
$this->pSUIPAddress = $config['clientpubip'];
7379
}
80+
81+
if(array_key_exists('mocking', $config)){
82+
$this->mockMode = boolval($config['mocking']);
83+
}
7484

7585
parent::__construct($config);
7686
}
@@ -82,7 +92,7 @@ public function __construct(array $config = [])
8292
*/
8393
public function getXIBMClientId()
8494
{
85-
return $this->xIBMClientID;
95+
return $this->xIBMClientId;
8696
}
8797

8898
/**
@@ -94,6 +104,16 @@ public function getpSUIPAddress()
94104
{
95105
return $this->pSUIPAddress;
96106
}
107+
108+
/**
109+
* Use mocking uri for api calls ?
110+
*
111+
* @return boolean
112+
*/
113+
public function getMockMode()
114+
{
115+
return $this->mockMode;
116+
}
97117

98118
/**
99119
* Obtain Your current Public IP

.openapi-generator/templates/api.mustache

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ use {{invokerPackage}}\ObjectSerializer;
6767
*/
6868
protected $xIBMClientId = null;
6969
70+
/**
71+
* Use the /rbcz/premium/mock/* path for endpoints ?
72+
*/
73+
protected $mockMode = false;
74+
7075
/**
7176
* the end IP address of the client application (no server) in IPv4 or IPv6 format. If the bank client (your user) uses a browser by which he accesses your server app, we need to know the IP address of his browser. Always provide the closest IP address to the real end-user possible. (optional)
7277
*
@@ -105,6 +110,9 @@ use {{invokerPackage}}\ObjectSerializer;
105110
if(method_exists($this->client, 'getpSUIPAddress')){
106111
$this->setSUIPAddress($this->client->getpSUIPAddress());
107112
}
113+
if(method_exists($this->client, 'getMockMode')){
114+
$this->setMockMode($this->client->getMockMode());
115+
}
108116
}
109117

110118
/**
@@ -136,6 +144,13 @@ use {{invokerPackage}}\ObjectSerializer;
136144
$this->SUIPAddress;
137145
}
138146

147+
/**
148+
* @param boolean $mocking Use mocking api for development purposes ?
149+
*/
150+
public function setMockMode($mocking) {
151+
$his->mockMode = $mocking;
152+
}
153+
139154
/**
140155
* Set the host index
141156
*
@@ -652,6 +667,9 @@ use {{invokerPackage}}\ObjectSerializer;
652667
{{/hasValidation}}{{/allParams}}
653668

654669
$resourcePath = '{{{path}}}';
670+
if($this->mockMode === true){
671+
$resoucePath = str_replace('/rbcz/premium/api/', '/rbcz/premium/mock/', $sourcePath);
672+
}
655673
$formParams = [];
656674
$queryParams = [];
657675
$headerParams = [];

examples/example.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CERT_FILE=examples/test_cert.p12
1+
CERT_FILE=test_cert.p12
22
CERT_PASS=test12345678
33
XIBMCLIENTID=FbboLD2r1WHDRcuKS4wWUbSRHxlDloWL
44
API_DEBUG=True

examples/getstatements.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace VitexSoftware\Raiffeisenbank;
44

55
require_once( '../vendor/autoload.php');
6-
$apiInstance = new PremiumAPI\GetStatementListApi(new ApiClient());
6+
\Ease\Shared::init([], 'example.env');
77
$x_ibm_client_id = 'FbboLD2r1WHDRcuKS4wWUbSRHxlDloWL'; // string | ClientID obtained from Developer Portal - when you registered your app with us.
88
$x_request_id = time(); // string | Unique request id provided by consumer application for reference and auditing.
99
$accept_language = 'cs'; // string | The Accept-Language request HTTP header is used to determine document language. Supported languages are `cs` and `en`.
@@ -15,8 +15,12 @@
1515
$page = 56; // int | Number of the requested page. Default is 1.
1616
$size = 56; // int | Number of items on the page. Default is 15.
1717

18+
$apiInstance = new PremiumAPI\GetStatementListApi(new ApiClient([
19+
'clientpubip' => $psu_ip_address,
20+
'clientid' => $x_ibm_client_id
21+
]));
1822
try {
19-
$result = $apiInstance->getStatements($x_ibm_client_id, $x_request_id, $request_body, $psu_ip_address, $page, $size);
23+
$result = $apiInstance->getStatements($x_request_id, $request_body, $page, $size);
2024
print_r($result);
2125
} catch (\Ease\Exception $e) {
2226
echo 'Exception when calling GetStatementListApi->getStatements: ', $e->getMessage(), PHP_EOL;

0 commit comments

Comments
 (0)