diff --git a/composer.json b/composer.json index ad74c61..48b30de 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "type": "library", "description": "LDC CRM Client V2", "license": "MIT", - "version": "2.0.4", + "version": "2.0.5", "authors": [ { "name": "Jérémy Munsch", diff --git a/src/CrmApiV2.php b/src/CrmApiV2.php index 134c16e..6377d03 100644 --- a/src/CrmApiV2.php +++ b/src/CrmApiV2.php @@ -22,9 +22,12 @@ class CrmApiV2 */ private static $apiInterface; - public function __construct() + public function __construct(string $bearerToken = null, string $bearerPwd = null) { - self::$apiInterface = self::$apiInterface ?: new ApiInterface(); + self::$apiInterface = self::$apiInterface ?: new ApiInterface( + $bearerToken, + $bearerPwd + ); return $this; } diff --git a/src/Transport/ApiInterface.php b/src/Transport/ApiInterface.php index 4fda294..93fbd5e 100644 --- a/src/Transport/ApiInterface.php +++ b/src/Transport/ApiInterface.php @@ -58,8 +58,10 @@ class ApiInterface */ protected static $apiToken; - public function __construct() + public function __construct(string $bearerToken = null, string $bearerPwd = null) { + static::$bearerToken = static::$bearerToken ?: $bearerToken; + static::$bearerPwd = static::$bearerPwd ?: $bearerPwd; static::$bearerToken = static::$bearerToken ?: Utils::getConfig('crm.token'); static::$bearerPwd = static::$bearerPwd ?: Utils::getConfig('crm.password'); static::$endpoint = static::$endpoint ?: Utils::getConfig('crm.endpoint'); diff --git a/src/WordPress/WPCrm.php b/src/WordPress/WPCrm.php index 7c1dc8a..231b8c6 100644 --- a/src/WordPress/WPCrm.php +++ b/src/WordPress/WPCrm.php @@ -495,7 +495,7 @@ class WPCrm * * @return void */ - private static function _saveOrUpdateUserToTable() + private static function saveOrUpdateUserToTable() { if (self::getUserToTable(self::$user->crm_id)) { self::query(