Skip to content

Commit

Permalink
Merge pull request #494 from range-of-motion/update-usage-of-exchange…
Browse files Browse the repository at this point in the history
…-rates-api

Update usage of exchange rates API
  • Loading branch information
range-of-motion authored Aug 31, 2024
2 parents 304c816 + 4e462ff commit 0bf9ba4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/Jobs/FetchConversionRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,16 @@ public function handle(
}

$url = sprintf(
'https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/%s/%s.json',
'https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/%s.json',
$baseCurrency->iso_lowercased,
$targetCurrency->iso_lowercased,
);

try {
$response = $client->request('GET', $url);

$decoded_response = json_decode($response->getBody(), true);

$rate = $decoded_response[$targetCurrency->iso_lowercased];
$rate = $decoded_response[$baseCurrency->iso_lowercased][$targetCurrency->iso_lowercased];
} catch (Exception $e) {
continue;
}
Expand Down

0 comments on commit 0bf9ba4

Please sign in to comment.