Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 4036e9d

Browse files
committed
v1.0.1
Signed-off-by: Finbarrs Oketunji <f@finbarrs.eu>
1 parent cc743ef commit 4036e9d

File tree

3 files changed

+88
-3
lines changed

3 files changed

+88
-3
lines changed

example.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Initialize the Currensees SDK
88
$currensees = new Currensees();
99

10-
// Set your username and password for the Currensees API
10+
// Set your username and password for the Currency API
1111
$username = 'your_username';
1212
$password = 'your_password';
1313

@@ -41,4 +41,31 @@
4141
} else {
4242
echo "Conversion to all currencies failed: " . $convertAllResult['error'] . "\n";
4343
}
44+
45+
// Set the date for which you want to retrieve the currencies
46+
$day = '02';
47+
$month = '04';
48+
$year = '2023';
49+
50+
// Set the UUID of the currency you want to retrieve
51+
$uuid = 'currency_uuid';
52+
53+
// Call the getCurrencies method to get the available currencies for the given date
54+
$currenciesResult = $currensees->getCurrencies($username, $day, $month, $year);
55+
if ($currenciesResult) {
56+
echo "Currencies for " . $day . "/" . $month . "/" . $year . ":\n";
57+
echo json_encode($currenciesResult) . "\n";
58+
} else {
59+
echo "Failed to retrieve currencies for the given date.\n";
60+
}
61+
62+
// Call the getCurrency method to get the details of the specific currency for the given date
63+
$currencyResult = $currensees->getCurrency($uuid, $username, $day, $month, $year);
64+
if ($currencyResult) {
65+
echo "Currency details for " . $day . "/" . $month . "/" . $year . ":\n";
66+
echo json_encode($currencyResult) . "\n";
67+
} else {
68+
echo "Failed to retrieve currency details for the given date.\n";
69+
}
70+
4471
?>

src/currensees.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,39 @@ public function convertAll($base_currency, $amount, $date)
7474
return false;
7575
}
7676
}
77+
78+
public function getCurrencies($username, $day, $month, $year)
79+
{
80+
$client = new Client();
81+
$headers = [
82+
'Accept' => 'application/json'
83+
];
84+
$url = 'https://currensees.com/v1/currencies?username=' . $username . '&day=' . $day . '&month=' . $month . '&year=' . $year;
85+
$request = new Request('GET', $url, $headers);
86+
$res = $client->sendAsync($request)->wait();
87+
88+
if ($res->getStatusCode() == 200) {
89+
return json_decode($res->getBody(), true);
90+
} else {
91+
return false;
92+
}
93+
}
94+
95+
public function getCurrency($uuid, $username, $day, $month, $year)
96+
{
97+
$client = new Client();
98+
$headers = [
99+
'Accept' => 'application/json'
100+
];
101+
$url = 'https://currensees.com/v1/currencies/' . $uuid . '?username=' . $username . '&day=' . $day . '&month=' . $month . '&year=' . $year;
102+
$request = new Request('GET', $url, $headers);
103+
$res = $client->sendAsync($request)->wait();
104+
105+
if ($res->getStatusCode() == 200) {
106+
return json_decode($res->getBody(), true);
107+
} else {
108+
return false;
109+
}
110+
}
111+
77112
}

tests/CurrenseesTest.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testConvert()
2929
$date = '2023_04_03';
3030
$baseCurrency = 'GBP';
3131
$targetCurrency = 'EUR';
32-
$amount = 100;
32+
$amount = 1000;
3333

3434
$result = $this->currensees->convert($date, $baseCurrency, $targetCurrency, $amount);
3535
$this->assertTrue(is_array($result));
@@ -38,10 +38,33 @@ public function testConvert()
3838
public function testConvertAll()
3939
{
4040
$baseCurrency = 'GBP';
41-
$amount = 100;
41+
$amount = 1000;
4242
$date = '2023_04_03';
4343

4444
$result = $this->currensees->convertAll($baseCurrency, $amount, $date);
4545
$this->assertTrue(is_array($result));
4646
}
47+
48+
public function testGetCurrencies()
49+
{
50+
$username = 'your_username';
51+
$day = '02';
52+
$month = '04';
53+
$year = '2023';
54+
55+
$result = $this->currensees->getCurrencies($username, $day, $month, $year);
56+
$this->assertTrue(is_array($result));
57+
}
58+
59+
public function testGetCurrency()
60+
{
61+
$uuid = 'currency_uuid';
62+
$username = 'your_username';
63+
$day = '02';
64+
$month = '04';
65+
$year = '2023';
66+
67+
$result = $this->currensees->getCurrency($uuid, $username, $day, $month, $year);
68+
$this->assertTrue(is_array($result));
69+
}
4770
}

0 commit comments

Comments
 (0)