From 85b9220c1ffce2384029145afd119ff9ac623d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Fri, 13 Aug 2021 11:03:24 +0200 Subject: [PATCH] tokens to CrmApiV2 contructor --- src/CrmApiV2.php | 7 +++++-- src/Transport/ApiInterface.php | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) 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');