From 0904d30ac9f358f8f85ce06e09928ba5b29fd056 Mon Sep 17 00:00:00 2001 From: J Cobb <777522+jwcobb@users.noreply.github.com> Date: Fri, 19 Aug 2022 15:09:54 -0700 Subject: [PATCH] - When using `settings()` to update the client settings, check if the description needs to be reloaded due to a version change. (#172) --- CHANGELOG.md | 3 +++ src/Client.php | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 123efae..6ceafb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 4.4.4 (August 19, 2022) +- When using `settings()` to update the client settings, check if the description needs to be reloaded due to a version change. + ## 4.4.3 (July 22, 2022) - Remove unused `include_tevo_section_mappings` parameter from `listings()` method. diff --git a/src/Client.php b/src/Client.php index 594ce16..83ca684 100755 --- a/src/Client.php +++ b/src/Client.php @@ -16,7 +16,7 @@ class Client * * @const string */ - const VERSION = '4.4.3'; + const VERSION = '4.4.4'; /** * Guzzle service description @@ -62,7 +62,9 @@ public function __construct(array $settings = [], array $middleware = []) $this->settings = $settings; // Use the TEvoAuth middleware to handle the request signing - $this->middleware = array_merge([new TEvoAuthMiddleware($this->settings['apiToken'], $this->settings['apiSecret'])], $middleware); + $this->middleware = array_merge([ + new TEvoAuthMiddleware($this->settings['apiToken'], $this->settings['apiSecret']), + ], $middleware); // Don’t need these anymore unset($this->settings['apiToken'], $this->settings['apiSecret']); @@ -89,8 +91,16 @@ public function __construct(array $settings = [], array $middleware = []) */ public function settings(array $settings): Client { + if (isset($settings['apiVersion']) && $settings['apiVersion'] !== $this->settings['apiVersion']) { + $reloadDescription = true; + } + $this->settings = array_merge($this->settings, $settings); + if ($reloadDescription) { + $this->reloadDescription(); + } + if ($this->serviceClient) { $this->buildClient(); }