From 15c384d5c56c54e80b75c98fdef7c301565af945 Mon Sep 17 00:00:00 2001 From: saasfreelancer Date: Tue, 28 Sep 2021 18:04:52 +0500 Subject: [PATCH] feat: allow for http adapter param - Base client class now accepts Http Adapter object as param. - Add http adapter interface --- lib/recurly/base_client.php | 7 ++++++- lib/recurly/http_adapter_interface.php | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 lib/recurly/http_adapter_interface.php diff --git a/lib/recurly/base_client.php b/lib/recurly/base_client.php index 39fa7f35..821ba130 100644 --- a/lib/recurly/base_client.php +++ b/lib/recurly/base_client.php @@ -31,7 +31,7 @@ abstract class BaseClient * In addition to the options managed by BaseClient, it accepts the following options: * - "region" to define the Data Center connection - defaults to "us"; */ - public function __construct(string $api_key, LoggerInterface $logger = null, array $options = []) + public function __construct(string $api_key, LoggerInterface $logger = null, array $options = [], HttpAdapterInterface $http_adapter = null) { $this->_api_key = $api_key; if (isset($options['region'])) { @@ -41,6 +41,11 @@ public function __construct(string $api_key, LoggerInterface $logger = null, arr $this->baseUrl = BaseClient::API_HOSTS[$options['region']]; } + if (is_null($http_adapter)) { + $http_adapter = new HttpAdapter; + } + $this->http = $http_adapter; + $this->http = new HttpAdapter; if (is_null($logger)) { $logger = new \Recurly\Logger('Recurly', LogLevel::WARNING); diff --git a/lib/recurly/http_adapter_interface.php b/lib/recurly/http_adapter_interface.php new file mode 100644 index 00000000..843e7a5b --- /dev/null +++ b/lib/recurly/http_adapter_interface.php @@ -0,0 +1,11 @@ +