diff --git a/composer.lock b/composer.lock index ae31aca..6859c1c 100644 --- a/composer.lock +++ b/composer.lock @@ -110,6 +110,10 @@ "rest", "web service" ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.4.5" + }, "funding": [ { "url": "https://github.com/GrahamCampbell", @@ -190,6 +194,10 @@ "keywords": [ "promise" ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/1.5.1" + }, "funding": [ { "url": "https://github.com/GrahamCampbell", @@ -301,6 +309,10 @@ "uri", "url" ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.4.0" + }, "funding": [ { "url": "https://github.com/GrahamCampbell", @@ -364,6 +376,9 @@ "psr", "psr-18" ], + "support": { + "source": "https://github.com/php-fig/http-client/tree/master" + }, "time": "2020-06-29T06:28:15+00:00" }, { @@ -416,6 +431,9 @@ "request", "response" ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/master" + }, "time": "2019-04-30T12:38:16+00:00" }, { @@ -466,6 +484,9 @@ "request", "response" ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, "time": "2016-08-06T14:39:51+00:00" }, { @@ -506,11 +527,15 @@ } ], "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, "time": "2019-03-08T08:55:37+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.1", + "version": "v2.5.2", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", @@ -556,6 +581,9 @@ ], "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -632,6 +660,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.15.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -709,6 +740,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.20.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -727,16 +761,16 @@ }, { "name": "symfony/polyfill-php72", - "version": "v1.23.0", + "version": "v1.26.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "9a142215a36a3888e30d0a9eeea9766764e96976" + "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976", - "reference": "9a142215a36a3888e30d0a9eeea9766764e96976", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/bf44a9fd41feaac72b074de600314a93e2ae78e2", + "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2", "shasum": "" }, "require": { @@ -745,7 +779,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.26-dev" }, "thanks": { "name": "symfony/polyfill", @@ -782,6 +816,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-php72/tree/v1.26.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -796,7 +833,7 @@ "type": "tidelift" } ], - "time": "2021-05-27T09:17:38+00:00" + "time": "2022-05-24T11:49:31+00:00" } ], "packages-dev": [], @@ -807,5 +844,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.2.0" } diff --git a/src/OwaClient.php b/src/OwaClient.php index 40cb31c..a394cf6 100644 --- a/src/OwaClient.php +++ b/src/OwaClient.php @@ -18,7 +18,8 @@ public function __construct( $config ) { 'instance_url' => '', 'ns' => 'owa_', 'endpoint' => 'api', - 'credentials' => [] + 'credentials' => [], + 'debug' => false ]; // override default config with config array passed in. @@ -159,11 +160,14 @@ public function makeRequest( $params ) { $conf = [ - 'base_uri' => $this->getSetting('instance_url') + 'base_uri' => $this->getSetting('instance_url'), + ]; $http = $this->getHttpClient( $conf ); + //$http->setUserAgent('OWA SDK Client', true); + $uri = $this->getSetting('endpoint') . $params['uri']; $request_options = []; @@ -183,7 +187,8 @@ public function makeRequest( $params ) { $request_options[ 'headers' ] = [ 'X-SIGNATURE' => $this->generateRequestSignature( $params, $credentials ), - 'X-API-KEY' => $credentials['api_key'] + 'X-API-KEY' => $credentials['api_key'], + 'User-Agent' => 'OWA SDK Client' ]; @@ -222,12 +227,16 @@ public function makeRequest( $params ) { $this->last_response = $res ; $b = $res->getBody(); - $b = json_decode( $b, true); - if ( array_key_exists( 'data', $b ) ) { + if ( $b ) { - return $b['data']; - } + $b = json_decode( $b, true); + + if ( $b && array_key_exists( 'data', $b ) ) { + + return $b['data']; + } + } } } diff --git a/src/sdk.php b/src/sdk.php index 5d4a3c3..6e6a1f3 100644 --- a/src/sdk.php +++ b/src/sdk.php @@ -13,6 +13,8 @@ class sdk { private $config; + public static $inDebug; + public function __construct( $config = [] ) { $this->config = $config; @@ -22,6 +24,7 @@ public function __construct( $config = [] ) { ini_set('display_errors', 1); error_reporting( -1 ); + self::$inDebug = true; } } @@ -89,12 +92,15 @@ private function addToConfig( $service, $config ) { static function debug( $msg ) { - if ( is_object( $msg ) || is_array( $msg ) ) { + if ( self::$inDebug ) { + + if ( is_object( $msg ) || is_array( $msg ) ) { + + $msg = print_r( $msg, true ); + } - $msg = print_r( $msg, true ); + error_log( $msg . "\n", 3, "./errors.log" ); } - - error_log( $msg . "\n", 3, "./errors.log" ); } }