diff --git a/README.md b/README.md index 8325d1a..5daecc7 100644 --- a/README.md +++ b/README.md @@ -126,3 +126,13 @@ You will receive the following array: [rate] => 1.222637 [result] => 30.565925 ) + +### Additional features + +#### SSL support + +All paid subscription plans available on Fixer.io come with 256-bit SSL encryption. You can enable SSL support by providing extra information in the class constructor: + + $config = array('ssl' => true); + $fixer = new \InfiniWeb\FixerAPI\Fixer($config); + diff --git a/src/FixerAPI/Fixer.php b/src/FixerAPI/Fixer.php index d512be3..b68e6c5 100644 --- a/src/FixerAPI/Fixer.php +++ b/src/FixerAPI/Fixer.php @@ -8,7 +8,7 @@ class Fixer * The API base URL * @var string */ - private $baseUrl = "https://data.fixer.io/api/"; + private $baseUrl = "data.fixer.io/api/"; /** * The API provider for GET operations @@ -34,11 +34,18 @@ class Fixer */ public $convert; - public function __construct() + public function __construct($config = []) { $this->symbols = new Symbols($this); $this->rates = new Rates($this); $this->convert = new Convert($this); + + $this->setConfig($config); + } + + protected function setConfig($config) + { + $this->baseUrl = isset($config['ssl']) && $config['ssl'] ? "https://".$this->baseUrl : "http://".$this->baseUrl; } /** @@ -51,9 +58,8 @@ public function setAccessKey($accessKey) } /** - * Set the base URL of the API. - * It will be used to compose the API endpoint - * @param string $baseUrl the API base URL + * Override the base URL of the API. + * @param string $baseUrl */ public function setBaseUrl($baseUrl) {