Skip to content

Commit

Permalink
SSL support for paid subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
infiniweb committed Jun 3, 2018
1 parent fdd0a03 commit 3bc635d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);

16 changes: 11 additions & 5 deletions src/FixerAPI/Fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

/**
Expand All @@ -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)
{
Expand Down

0 comments on commit 3bc635d

Please sign in to comment.