/** * Constructor. * * @param BitreserveClient $client Bitreserve client. */ public function __construct(BitreserveClient $client) { if (!$client->getOption('bearer')) { throw new AuthenticationRequiredException('Missing bearer authorization'); } $this->client = $client; }
<?php require_once 'vendor/autoload.php'; use Bitreserve\BitreserveClient as Client; // Initialize the client. $client = new Client('AUTHORIZATION_TOKEN'); // Get the current user. $user = $client->getUser(); // Get user transactions. $pager = $user->getTransactions(); echo "*** List of user transactions ***\n"; while ($pager->hasNext()) { $transactions = $pager->getNext(); foreach ($transactions as $transaction) { echo sprintf("Date: %s\n", $transaction->getCreatedAt()); echo sprintf("Status: %s\n", $transaction->getStatus()); $origin = $transaction->getOrigin(); echo sprintf("Origin: %s\n", $origin['description']); $destination = $transaction->getDestination(); echo sprintf("Destination: %s\n", $destination['description']); echo sprintf("Amount: %s %s\n", $destination['amount'], $destination['currency']); echo "\n"; } } echo "\n*** Create and commit a new transaction ***\n"; // Get a user card. $card = $user->getCardById('ade869d8-7913-4f67-bb4d-72719f0a2be0'); // Create a new transaction. $transaction = $card->createTransaction('*****@*****.**', '0.001', 'BTC'); // Commit the transaction $transaction->commit();
/** * @test */ public function shouldReturnReserve() { $client = new BitreserveClient(); $this->assertInstanceOf('Bitreserve\\Model\\Reserve', $client->getReserve()); }
<?php require_once 'vendor/autoload.php'; use Bitreserve\BitreserveClient as Client; // Initialize the client. In this case, we don't need an // AUTHORIZATION_TOKEN because the Ticker endpoint is public. $client = new Client(); // Get the reserve summary of all the obligations and assets within it. $statistics = $client->getReserve()->getStatistics(); print_r($statistics); // Get the reserve ledger $pager = $client->getReserve()->getLedger(); print_r($pager->getNext()); // Get latest transactions $pager = $client->getReserve()->getTransactions(); print_r($pager->getNext());
<?php require_once 'vendor/autoload.php'; use Bitreserve\BitreserveClient as Client; // Initialize the client. In this case, we don't need an // AUTHORIZATION_TOKEN because the Ticker endpoint is public. $client = new Client(); // Get tickers. $tickers = $client->getTicker(); echo "*** Current exchange rates ***\n"; foreach ($tickers as $ticker) { echo sprintf("Pair: %s\n", $ticker->getPair()); echo sprintf("Ask: 1 %s = %s %s\n", substr($ticker->getPair(), 0, 3), $ticker->getAsk(), $ticker->getCurrency()); echo sprintf("Bid: 1 %s = %s %s\n", substr($ticker->getPair(), 0, 3), $ticker->getBid(), $ticker->getCurrency()); echo "\n"; }