Skip to content

Commit

Permalink
Merge pull request #11 from daniel-mannheimer/master
Browse files Browse the repository at this point in the history
use config file like in readme
  • Loading branch information
repat authored Sep 10, 2019
2 parents 4487dd3 + 9ba73fd commit 7d7b1fd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/PlentymarketsRestClient/PlentymarketsRestClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ class PlentymarketsRestClient
private $rateLimitingEnabled = true;
private $throttledOnLastRequest = false;

public function __construct($configFile, $config)
public function __construct($configFile, $config = null)
{
$this->client = new Client();
$this->config = $config;

if ($config !== null) {
$this->config = $config;
} else {
$this->config = $this->readConfigFile($configFile);
}

if (!file_exists($configFile)) {
$this->configFile = $configFile;
$this->saveConfigFile();
Expand Down Expand Up @@ -140,6 +144,11 @@ private function saveConfigFile()
file_put_contents($this->configFile, serialize($this->config));
}

private function readConfigFile($configFile)
{
return unserialize(file_get_contents($configFile));
}

private function correctURL($url)
{
$sUrl = new s($url);
Expand Down

0 comments on commit 7d7b1fd

Please sign in to comment.