@@ -26,6 +26,7 @@ use GuzzleHttp\Exception\RequestException;
2626use GuzzleHttp\Psr7\MultipartStream;
2727use GuzzleHttp\Psr7\Request;
2828use GuzzleHttp\RequestOptions;
29+ use { {invokerPackage} }\ApiClient;
2930use { {invokerPackage} }\ApiException;
3031use { {invokerPackage} }\Configuration;
3132use { {invokerPackage} }\HeaderSelector;
@@ -61,6 +62,20 @@ use {{invokerPackage}}\ObjectSerializer;
6162 */
6263 protected $hostIndex ;
6364
65+ /**
66+ * ApiKey obtained from Developer Portal - when you registered your app with us.
67+ *
68+ * @link https://developers.erstegroup.com/portal/organizations/vitezslav-dvorak/applications/ Grab Your API key here
69+ * @var string
70+ */
71+ protected string $apiKey ;
72+ protected string $token ;
73+
74+ /**
75+ * Use the /api/csas/public/sandbox/v3/* path for endpoints ?
76+ */
77+ protected $sandBoxMode = false ;
78+
6479 /** @var string[] $contentTypes **/
6580 public const contentTypes = [{{#operation} }
6681 '{ {{operationId} }}' => [{ {#consumes} }
@@ -82,10 +97,49 @@ use {{invokerPackage}}\ObjectSerializer;
8297 HeaderSelector $selector = null,
8398 $hostIndex = 0
8499 ) {
85- $this -> client = $client ?: new Client ();
100+ $this -> client = $client ?: new ApiClient ();
86101 $this -> config = $config ?: Configuration::getDefaultConfiguration();
87102 $this -> headerSelector = $selector ?: new HeaderSelector();
88103 $this -> hostIndex = $hostIndex ;
104+ if (method_exists($this -> client , ' getApiKey' )) {
105+ $config [' headers' ][' web-api-key' ] = $this -> client -> getApiKey ();
106+ $this -> setApiKey ($this -> client -> getApiKey ());
107+ }
108+ if (method_exists($this->client, 'getAccessToken')) {
109+ $config [' headers' ][' authorization' ] = ' Bearer ' .$this -> client -> getAccessToken ();
110+ $this -> setAccessToken ($this -> client -> getAccessToken ());
111+ }
112+ if (method_exists($this->client, 'getSandBoxMode')) {
113+ $this -> setSandBoxMode ($this -> client -> getSandBoxMode ());
114+ }
115+
116+ $config['base_uri'] = ($this->sandBoxMode ? 'https://webapi.developers.erstegroup.com/api/csas/public/sandbox' : 'https://www.csas.cz/webapi/api') . '/v3/accounts/' ;
117+
118+ }
119+
120+ /**
121+ * @param string $apiKey Set you API_KEY here
122+ */
123+ public function setApiKey(string $apiKey): void
124+ {
125+ $this -> config -> setApiKey (' web-api-key' , $apiKey );
126+ }
127+
128+ /**
129+ * @param string $token set access token
130+ */
131+ public function setAccessToken($token): void
132+ {
133+ $this -> config -> setAccessToken ($token );
134+ }
135+
136+ /**
137+ * @param boolean $sandboxing Use mocking api for development purposes ?
138+ */
139+ public function setSandBoxMode(bool $sandboxing): void
140+ {
141+ $this -> sandBoxMode = $sandboxing ;
142+ $this -> config -> setHost (' https://' .($this -> sandBoxMode ? ' webapi.developers.erstegroup.com' : ' www.csas.cz' ));
89143 }
90144
91145 /**
@@ -622,7 +676,7 @@ use {{invokerPackage}}\ObjectSerializer;
622676 { {/minItems} }
623677 { {/hasValidation} }{ {/allParams} }
624678
625- $resourcePath = ' { {{path} }}';
679+ $resourcePath = ($this->sandBoxMode ? '/api/csas/public/sandbox' : '/webapi/api').'/v3/accounts { {{path} }}';
626680 $formParams = [];
627681 $queryParams = [];
628682 $headerParams = [];
@@ -855,6 +909,9 @@ use {{invokerPackage}}\ObjectSerializer;
855909 }
856910 }
857911
912+ $options['headers']['web-api-key'] = $this->config->getApiKey('web-api-key');
913+ $options['headers']['authorization'] = 'Bearer '.$this->config->getAccessToken();
914+
858915 return $options;
859916 }
860917}
0 commit comments