Skip to content

Commit

Permalink
Add buildConfiguration() method
Browse files Browse the repository at this point in the history
  • Loading branch information
webeweb committed Aug 2, 2019
1 parent 63ff637 commit f6070c4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

### [2.4.3](https://github.com/webeweb/smsmode-library/tree/v2.4.3) (2019-08-02)

- Add buildConfiguration() method
- Fix PHPDoc

### [2.4.2](https://github.com/webeweb/smsmode-library/tree/v2.4.2) (2019-07-22)

- Add PHP extensions into Composer
Expand Down
33 changes: 21 additions & 12 deletions src/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ public function __construct(Authentication $authentication) {
$this->setRequestNormalizer(new RequestNormalizer());
}

/**
* Build the configuration.
*
* @return array Returns the configuration.
*/
private function buildConfiguration() {
return [
"base_uri" => self::ENDPOINT_PATH . "/",
"debug" => $this->getDebug(),
"headers" => [
"Accept" => "text/html",
"User-Agent" => "webeweb/smsmode-library",
],
"synchronous" => true,
];
}

/**
* Call API.
*
Expand All @@ -81,15 +98,7 @@ protected function callAPI(AbstractRequest $request, array $queryData, array $po

try {

$client = new Client([
"base_uri" => self::ENDPOINT_PATH . "/",
"debug" => $this->getDebug(),
"headers" => [
"Accept" => "text/html",
"User-Agent" => "webeweb/smsmode-library",
],
"synchronous" => true,
]);
$client = new Client($this->buildConfiguration());

$method = 0 === count($postData) ? "GET" : "POST";
$uri = substr($request->getResourcePath(), 1);
Expand Down Expand Up @@ -141,7 +150,7 @@ public function getRequestNormalizer() {
* Set the authentication.
*
* @param Authentication $authentication The authentication.
* @return APIProvider Returns this provider.
* @return AbstractProvider Returns this provider.
*/
protected function setAuthentication(Authentication $authentication) {
$this->authentication = $authentication;
Expand All @@ -152,7 +161,7 @@ protected function setAuthentication(Authentication $authentication) {
* Set the debug.
*
* @param bool $debug The debug.
* @return APIProvider Returns this provider.
* @return AbstractProvider Returns this provider.
*/
public function setDebug($debug) {
$this->debug = $debug;
Expand All @@ -163,7 +172,7 @@ public function setDebug($debug) {
* Set the request normalizer.
*
* @param RequestNormalizer $requestNormalizer
* @return APIProvider Returns this provider.
* @return AbstractProvider Returns this provider.
*/
protected function setRequestNormalizer(RequestNormalizer $requestNormalizer) {
$this->requestNormalizer = $requestNormalizer;
Expand Down

0 comments on commit f6070c4

Please sign in to comment.