1313
1414class OneSignalClient
1515{
16- const API_URL = "https://onesignal.com/api/v1 " ;
1716
1817 const ENDPOINT_NOTIFICATIONS = "/notifications " ;
1918 const ENDPOINT_PLAYERS = "/players " ;
@@ -22,6 +21,7 @@ class OneSignalClient
2221 protected $ client ;
2322 protected $ headers ;
2423 protected $ appId ;
24+ protected $ restApiUrl ;
2525 protected $ restApiKey ;
2626 protected $ userAuthKey ;
2727 protected $ additionalParams ;
@@ -71,13 +71,15 @@ public function callback(Callable $requestCallback)
7171
7272 /**
7373 * @param $appId
74+ * @param $restApiUrl
7475 * @param $restApiKey
7576 * @param $userAuthKey
7677 * @param int $guzzleClientTimeout
7778 */
78- public function __construct ($ appId , $ restApiKey , $ userAuthKey , $ guzzleClientTimeout = 0 )
79+ public function __construct ($ appId , $ restApiUrl , $ restApiKey , $ userAuthKey , $ guzzleClientTimeout = 0 )
7980 {
8081 $ this ->appId = $ appId ;
82+ $ this ->restApiUrl = $ restApiUrl ;
8183 $ this ->restApiKey = $ restApiKey ;
8284 $ this ->userAuthKey = $ userAuthKey ;
8385
@@ -506,29 +508,29 @@ private function sendPlayer(Array $parameters, $method, $endpoint)
506508
507509 public function post ($ endPoint ) {
508510 if ($ this ->requestAsync === true ) {
509- $ promise = $ this ->client ->postAsync (self :: API_URL . $ endPoint , $ this ->headers );
511+ $ promise = $ this ->client ->postAsync ($ this -> restApiUrl . $ endPoint , $ this ->headers );
510512 return (is_callable ($ this ->requestCallback ) ? $ promise ->then ($ this ->requestCallback ) : $ promise );
511513 }
512- return $ this ->client ->post (self :: API_URL . $ endPoint , $ this ->headers );
514+ return $ this ->client ->post ($ this -> restApiUrl . $ endPoint , $ this ->headers );
513515 }
514516
515517 public function put ($ endPoint ) {
516518 if ($ this ->requestAsync === true ) {
517- $ promise = $ this ->client ->putAsync (self :: API_URL . $ endPoint , $ this ->headers );
519+ $ promise = $ this ->client ->putAsync ($ this -> restApiUrl . $ endPoint , $ this ->headers );
518520 return (is_callable ($ this ->requestCallback ) ? $ promise ->then ($ this ->requestCallback ) : $ promise );
519521 }
520- return $ this ->client ->put (self :: API_URL . $ endPoint , $ this ->headers );
522+ return $ this ->client ->put ($ this -> restApiUrl . $ endPoint , $ this ->headers );
521523 }
522524
523525 public function get ($ endPoint ) {
524- return $ this ->client ->get (self :: API_URL . $ endPoint , $ this ->headers );
526+ return $ this ->client ->get ($ this -> restApiUrl . $ endPoint , $ this ->headers );
525527 }
526528
527529 public function delete ($ endPoint ) {
528530 if ($ this ->requestAsync === true ) {
529- $ promise = $ this ->client ->deleteAsync (self :: API_URL . $ endPoint , $ this ->headers );
531+ $ promise = $ this ->client ->deleteAsync ($ this -> restApiUrl . $ endPoint , $ this ->headers );
530532 return (is_callable ($ this ->requestCallback ) ? $ promise ->then ($ this ->requestCallback ) : $ promise );
531533 }
532- return $ this ->client ->delete (self :: API_URL . $ endPoint , $ this ->headers );
534+ return $ this ->client ->delete ($ this -> restApiUrl . $ endPoint , $ this ->headers );
533535 }
534536}
0 commit comments