Exemplo n.º 1
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use Aveiv\OpenExchangeRatesApi\Client;
use GuzzleHttp\Client as GuzzleClient;
$client = new Client('YOUR_APP_ID', new GuzzleClient());
// Get currency list
print_r($client->getCurrencies());
// Get latest rates
print_r($client->getLatest());
// Get latest rates with custom base currency and limit result currencies
print_r($client->getLatest('EUR'), ['USD', 'RUB']);
// Get rates by date
print_r($client->getHistorical(new DateTime()));
// Get rates by date with custom base currency and limit result currencies
print_r($client->getHistorical(new DateTime(), 'EUR', ['USD', 'RUB']));
Exemplo n.º 2
0
 public function testInvalidAppId()
 {
     $client = new Client('BAD_APP_ID', new GuzzleClient());
     $this->setExpectedException(Exception::class);
     $client->getCurrencies();
     $client->getLatest();
     $client->getHistorical(new \DateTime());
 }