@@ -934,6 +934,19 @@ protected function _getAccessToken(): string|null
934934 $ apiKey = $ this ->getConfigData ('api_key ' ) ?? null ;
935935 $ secretKey = $ this ->getConfigData ('secret_key ' ) ?? null ;
936936
937+ return $ this ->retrieveAccessToken ($ apiKey , $ secretKey );
938+ }
939+
940+
941+ /**
942+ * Make the call to get the access token
943+ *
944+ * @param $apiKey
945+ * @param $secretKey
946+ * @return string|null
947+ */
948+ private function retrieveAccessToken ($ apiKey , $ secretKey ): string |null
949+ {
937950 if (!$ apiKey || !$ secretKey ) {
938951 $ this ->_debug (__ ('Authentication keys are missing. ' ));
939952 return null ;
@@ -955,9 +968,23 @@ protected function _getAccessToken(): string|null
955968 } elseif (!empty ($ response ['access_token ' ])) {
956969 $ accessToken = $ response ['access_token ' ];
957970 }
971+
958972 return $ accessToken ;
959973 }
960974
975+ /**
976+ * Get Access Token for Tracking Rest API
977+ *
978+ * @return string|null
979+ */
980+ private function _getTrackingApiAccessToken (): string |null
981+ {
982+ $ trackingApiKey = $ this ->getConfigData ('tracking_api_key ' ) ?? null ;
983+ $ trackingSecretKey = $ this ->getConfigData ('tracking_api_secret_key ' ) ?? null ;
984+
985+ return $ this ->retrieveAccessToken ($ trackingApiKey , $ trackingSecretKey );
986+ }
987+
961988 /**
962989 * Send Curl Request
963990 *
@@ -1007,7 +1034,12 @@ protected function sendRequest($endpoint, $request, $accessToken = null): array|
10071034 */
10081035 protected function _getTrackingInformation ($ tracking ): void
10091036 {
1010- $ accessToken = $ this ->_getAccessToken ();
1037+ if ($ this ->getConfigData ('enable_tracking_api ' )) {
1038+ $ accessToken = $ this ->_getTrackingApiAccessToken ();
1039+ } else {
1040+ $ accessToken = $ this ->_getAccessToken ();
1041+ }
1042+
10111043 if (!empty ($ accessToken )) {
10121044
10131045 $ trackRequest = [
0 commit comments