Skip to content

Commit 9b62646

Browse files
committed
Support currency better
1 parent 077d38f commit 9b62646

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/Candy.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class Candy
2626
protected $token = null;
2727
protected $driver;
2828
protected $logger;
29+
protected $currency;
2930

3031
public function __construct($app, $driver = 'guzzle')
3132
{
@@ -85,7 +86,7 @@ public function init($url, array $config = [])
8586
$this->locale = $config['locale'] ?? $this->locale;
8687
$this->channel = $config['channel'] ?? $this->channel;
8788
$this->debug = $config['debug'] ?? false;
88-
89+
$this->currency = $config['currency'] ?? null;
8990
$this->client = new Client([
9091
'base_uri' => $this->getUri(),
9192
]);
@@ -106,6 +107,11 @@ public function getChannel()
106107
return $this->channel;
107108
}
108109

110+
public function getCurrency()
111+
{
112+
return $this->currency;
113+
}
114+
109115
public function getLocale()
110116
{
111117
return $this->locale;

src/Drivers/AbstractDriver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ protected function getDefaultHeaders($force = false)
3030
'accept' => 'application/json',
3131
'Content-Type' => 'application/json',
3232
'X-CANDYAPI' => 'TRUE',
33+
'X-CANDY-CURRENCY' => CandyClient::getCurrency(),
3334
'X-CANDY-CHANNEL' => CandyClient::getChannel(),
3435
'Accept-Language' => $this->app->getLocale(),
3536
];

0 commit comments

Comments
 (0)