-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
62 lines (44 loc) · 1.64 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Joomla\DI\Container;
use ScriptFUSION\Porter\Porter;
use PayCrypto\CryptoMonitor;
use PayCrypto\Connector\CryptoConnector;
use PayCrypto\Resource\GetSpecificRate;
use PayCrypto\Resource\GetAllRate;
use PayCrypto\Resource\GetAssets;
use ScriptFUSION\Porter\Specification\ImportSpecification;
// Get specific rate
$apiKey = 'your-coin-api-key';
$container = new Container;
$container->set(CryptoMonitor::class, new CryptoMonitor(new CryptoConnector($apiKey)));
$porter = new Porter($container);
$specificRate = new GetSpecificRate($apiKey, 'BTC', 'USD');
$rates = $porter->importOne(new ImportSpecification($specificRate));
var_dump($rates);
// Get all rates
$container = new Container;
$container->set(CryptoMonitor::class, new CryptoMonitor(new CryptoConnector($apiKey)));
$porter = new Porter($container);
$specificRate = new GetAllRate($apiKey, 'BTC');
$rates = $porter->import(new ImportSpecification($specificRate));
foreach ($rates as $rateRecord) {
echo $rateRecord['asset_id_quote'] . PHP_EOL;
echo $rateRecord['rate'] . PHP_EOL;
echo $rateRecord['time'] . PHP_EOL;
}
// Get the base id
echo PHP_EOL;
$rates = $rates->findFirstCollection();
echo $rates->getBase(); //BTC
// Get Assets
$container = new Container;
$container->set(CryptoMonitor::class, new CryptoMonitor(new CryptoConnector($apiKey)));
$porter = new Porter($container);
$assets = new GetAssets($apiKey);
$assets = $porter->import(new ImportSpecification($assets));
foreach ($assets as $assetRecord) {
var_dump($assetRecord['asset_id']);
var_dump($assetRecord['name']);
var_dump($assetRecord['type_is_crypto']);
}