22
33namespace daxslab \enzona ;
44
5+ use daxslab \enzona \payment \Configuration as PaymentConfiguration ;
6+ use daxslab \enzona \payment \HeaderSelector as PaymentHeaderSelector ;
7+ use daxslab \enzona \qr \Configuration as QrConfiguration ;
8+ use daxslab \enzona \qr \HeaderSelector as QrHeaderSelector ;
9+ use Exception ;
510use GuzzleHttp \Client ;
611use GuzzleHttp \ClientInterface ;
12+ use GuzzleHttp \Exception \GuzzleException ;
713
814class BaseAPI
915{
@@ -63,22 +69,24 @@ class BaseAPI
6369 /**
6470 * Payment API configuration object
6571 *
66- * @var Configuration
72+ * @var PaymentConfiguration | QrConfiguration
6773 */
6874 protected $ config ;
6975
7076 /**
7177 * HeaderSelector object
7278 *
73- * @var HeaderSelector
79+ * @var PaymentHeaderSelector | QrHeaderSelector
7480 */
7581 protected $ headerSelector ;
7682
7783
7884 /**
7985 * EnZona constructor.
8086 * @param bool $useSandbox
81- * @param null $config
87+ * @param ClientInterface $client
88+ * @param PaymentConfiguration | QrConfiguration $config
89+ * @param PaymentHeaderSelector | QrHeaderSelector $headerSelector
8290 */
8391 public function __construct ($ useSandbox =false , $ client =null , $ config =null , $ headerSelector =null )
8492 {
@@ -161,31 +169,31 @@ public function setClient($client)
161169 }
162170
163171 /**
164- * @return Configuration
172+ * @return PaymentConfiguration | QrConfiguration
165173 */
166174 public function getConfig ()
167175 {
168176 return $ this ->config ;
169177 }
170178
171179 /**
172- * @param Configuration $config
180+ * @param PaymentConfiguration | QrConfiguration $config
173181 */
174182 public function setConfig ($ config )
175183 {
176184 $ this ->config = $ config ;
177185 }
178186
179187 /**
180- * @return HeaderSelector
188+ * @return PaymentHeaderSelector | QrHeaderSelector
181189 */
182190 public function getHeaderSelector ()
183191 {
184192 return $ this ->headerSelector ;
185193 }
186194
187195 /**
188- * @param HeaderSelector $headerSelector
196+ * @param PaymentHeaderSelector | QrHeaderSelector $headerSelector
189197 */
190198 public function setHeaderSelector ($ headerSelector )
191199 {
@@ -195,11 +203,12 @@ public function setHeaderSelector($headerSelector)
195203 /**
196204 * Requests an access token and return it
197205 *
198- * @param $customer_key
199- * @param $customer_secret
206+ * @param string $customer_key
207+ * @param string $customer_secret
200208 * @param array $scopes
201209 * @return string
202- * @throws \GuzzleHttp\Exception\GuzzleException
210+ * @throws GuzzleException
211+ * @throws Exception
203212 */
204213 public function requestAccessToken ($ customer_key , $ customer_secret , $ scopes =[self ::SCOPE_PAYMENT ]){
205214 $ body_scope = implode ('+ ' , $ scopes );
@@ -212,9 +221,9 @@ public function requestAccessToken($customer_key, $customer_secret, $scopes=[sel
212221 ]);
213222
214223 if ($ res ->getStatusCode () != 200 )
215- throw new \ Exception ('Error with status code: ' . $ res ->getStatusCode () . 'and body: ' . $ res ->getBody ());
224+ throw new Exception ('Error with status code: ' . $ res ->getStatusCode () . 'and body: ' . $ res ->getBody ());
216225 elseif ($ res ->getHeader ('content-type ' )[0 ] != 'application/json ' )
217- throw new \ Exception ('Invalid response content-type: ' . $ res ->getHeader ('content-type ' )[0 ] . ' required: application/json ' );
226+ throw new Exception ('Invalid response content-type: ' . $ res ->getHeader ('content-type ' )[0 ] . ' required: application/json ' );
218227
219228 return json_decode ($ res ->getBody ())->access_token ;
220229 }
0 commit comments