Skip to content

Commit

Permalink
Merge pull request #1 from eoko/feature/setBaseUri
Browse files Browse the repository at this point in the history
Add baseUri setter & Set in Factory
  • Loading branch information
Loxic authored Nov 27, 2017
2 parents 71aca2a + 616a185 commit 680d9c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/Api/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ protected function authenticatedRequest($method, $uri, array $options = [])
//add credentials to request
if ($this->credentials) {
$method = strtoupper($method);

if ($method === 'POST') {
if (isset($options['multipart'])) {
$multipart = $this->setMultipartField('username', $this->credentials['username'], $options['multipart']);
Expand All @@ -73,7 +74,6 @@ protected function authenticatedRequest($method, $uri, array $options = [])
);
}
}

return $this->request($method, $uri, $options);
}

Expand Down Expand Up @@ -222,6 +222,16 @@ public function setCredentials($account, $username, $password)
];
return $this;
}
/**
* @param string $baseUri
* @return $this
*/
public function setBaseUri($baseUri) {
if ($baseUri !== '') {
$this->baseUri = $baseUri;
}
return $this;
}

/**
* @param string $name
Expand Down
5 changes: 3 additions & 2 deletions src/Factory/TextKernelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ class TextKernelFactory
* @param string $account
* @param string $username
* @param string $password
* @param string $baseUri
* @return SourceboxApi
*/
public function createSourceboxApi($account, $username, $password)
public function createSourceboxApi($account, $username, $password, $baseUri = '')
{
return (new SourceboxApi())->setCredentials($account, $username, $password);
return (new SourceboxApi())->setCredentials($account, $username, $password)->setBaseUri($baseUri);
}
}

0 comments on commit 680d9c3

Please sign in to comment.