Skip to content

Commit

Permalink
feat: allow for http adapter param
Browse files Browse the repository at this point in the history
- Base client class now accepts Http Adapter object as param.
- Add http adapter interface
  • Loading branch information
saas786 committed Sep 28, 2021
1 parent 8c311c0 commit 774dc86
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/recurly/base_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ abstract class BaseClient
*
* @param string $api_key The API key to use when making requests
*/
public function __construct(string $api_key, LoggerInterface $logger = null)
public function __construct(string $api_key, LoggerInterface $logger = null, HttpAdapterInterface $http_adapter = null)
{
$this->_api_key = $api_key;
$this->http = new HttpAdapter;
if (is_null($http_adapter)) {
$http_adapter = new HttpAdapter;
}
$this->http = $http_adapter;
if (is_null($logger)) {
$logger = new \Recurly\Logger('Recurly', LogLevel::WARNING);
}
Expand Down
11 changes: 11 additions & 0 deletions lib/recurly/http_adapter_interface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Recurly;

/**
* @codeCoverageIgnore
*/
interface HttpAdapterInterface
{
public function execute($method, $url, $body, $headers): array;
}

0 comments on commit 774dc86

Please sign in to comment.