99
1010abstract class AbstractHttpClient implements HttpClientInterface
1111{
12- public AuthEntity $ authEntity ;
13-
14- protected ClientInterface $ httpClient ;
12+ public const URL_API_V1_PROD = 'https://api.wegetfinancing.com ' ;
13+ public const URL_API_V1_SANDBOX = 'https://api.sandbox.wegetfinancing.com ' ;
14+ public const URL_API_V3_PROD = 'https://apisrv.wegetfinancing.com ' ;
15+ public const URL_API_V3_SANDBOX = 'https://apisrv.sandbox.wegetfinancing.com ' ;
1516
1617 /**
1718 * @param AuthEntity $authEntity
1819 * @param ClientInterface $httpClient
1920 */
2021 public function __construct (
21- AuthEntity $ authEntity ,
22- ClientInterface $ httpClient
22+ public AuthEntity $ authEntity ,
23+ protected ClientInterface $ httpClient
2324 ) {
24- $ this ->authEntity = $ authEntity ;
25- $ this ->httpClient = $ httpClient ;
2625 }
2726
28- protected function getUrlFromPath (string $ path ): string
27+ protected function getBaseUrlApiV1 (): string
28+ {
29+ return (true === $ this ->authEntity ->isProd ()) ? self ::URL_API_V1_PROD : self ::URL_API_V1_SANDBOX ;
30+ }
31+
32+ protected function getBaseUrlApiV3 (): string
33+ {
34+ return (true === $ this ->authEntity ->isProd ()) ? self ::URL_API_V3_PROD : self ::URL_API_V3_SANDBOX ;
35+ }
36+
37+ protected function getUrlApiV1FromPath (string $ path ): string
38+ {
39+ return $ this ->getBaseUrlApiV1 () . $ path ;
40+ }
41+
42+ protected function getUrlApiV3FromPath (string $ path ): string
2943 {
30- return $ this ->authEntity -> getUrl () . $ path ;
44+ return $ this ->getBaseUrlApiV3 () . $ path ;
3145 }
3246
3347 protected function getMerchantIdPath (string $ path ): string
@@ -39,9 +53,9 @@ protected function getMerchantIdPath(string $path): string
3953 );
4054 }
4155
42- protected function getUrlFromMerchantIdPath (string $ path ): string
56+ protected function getUrlApiV1FromMerchantIdPath (string $ path ): string
4357 {
44- return $ this ->getUrlFromPath (
58+ return $ this ->getUrlApiV1FromPath (
4559 $ this ->getMerchantIdPath ($ path )
4660 );
4761 }
0 commit comments