Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme #38

Merged
merged 6 commits into from
Feb 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 164 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Require the library package as a dependency:
```json
{
"require": {
"seegno/bitreserve-sdk-php": "1.0.*"
"seegno/bitreserve-sdk-php": "1.1.*"
}
}
```
Expand All @@ -63,7 +63,7 @@ Then, create a new instance of the `Client` class with token. Take a look at the
```php
require_once 'vendor/autoload.php';

use \Bitreserve\BitreserveClient as Client;
use Bitreserve\BitreserveClient as Client;

// Initialize the client.
$client = new Client('AUTHORIZATION_TOKEN');
Expand All @@ -72,11 +72,148 @@ $client = new Client('AUTHORIZATION_TOKEN');
$user = $client->getUser();
```

### Get user balances
```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 balances for all currencies.
$balances = $user->getBalances();
```

You could get user total balance:

```php
// Get user total balance.
$totalBalance = $user->getTotalBalance();
```

The above produces the output shown below:

```php
Array
(
[amount] => 3.14
[currency] => BTC
)
```

### Get user cards
```php
require_once 'vendor/autoload.php';

use Bitreserve\BitreserveClient as Client;

// Initialize the client.
$client = new Client('AUTHORIZATION_TOKEN');

// Get current user cards.
$cards = $user->getCards();
```

### Create new card
```php
require_once 'vendor/autoload.php';

use Bitreserve\BitreserveClient as Client;

// Initialize the client.
$client = new Client('AUTHORIZATION_TOKEN');

// Create a new 'BTC' card.
$card = $user->createCard('My new card', 'BTC');
```

The above produces the output shown below:

```php
Bitreserve\Model\Card Object
(
[id:protected] => ade869d8-7913-4f67-bb4d-72719f0a2be0
[address:protected] => Array
(
[bitcoin] => 1GpBtJXXa1NdG94cYPGZTc3DfRY2P7EwzH
)

[addresses:protected] => Array
(
[0] => Array
(
[id] => 1GpBtJXXa1NdG94cYPGZTc3DfRY2P7EwzH
[network] => bitcoin
)

)

[available:protected] => 0.00
[balance:protected] => 0.00
[currency:protected] => BTC
[label:protected] => My new card
[lastTransactionAt:protected] =>
[transactions:protected] =>
[settings] => Array
(
[position] => 10
)
)
```

### Get ticker
```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();
```

Or you could get a ticker for a specific currency:

```php
// Get tickers for BTC.
$tickers = $client->getTickerByCurrency('BTC');
```

The above produces the output shown below:

```php
Array
(
[0] => Bitreserve\Model\Ticker Object
(
[ask:protected] => 1
[bid:protected] => 1
[currency:protected] => BTC
[pair:protected] => BTCBTC
)

[1] => Bitreserve\Model\Ticker Object
(
[ask:protected] => 234.89
[bid:protected] => 234.8
[currency:protected] => USD
[pair:protected] => BTCUSD
)
)
```

### Create and commit a new transaction
```php
require_once 'vendor/autoload.php';

use \Bitreserve\BitreserveClient as Client;
use Bitreserve\BitreserveClient as Client;

// Initialize the client.
$client = new Client('AUTHORIZATION_TOKEN');
Expand All @@ -94,6 +231,30 @@ $transaction = $card->createTransaction('foo@bar.com', '2.0', 'BTC');
$transaction->commit();
```

The above produces the output shown below:

```php
Bitreserve\Model\Transaction Object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very verbose to be in the main README file. Can we show a simplified version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fixe Do you mean something like this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure why not.

(
[id:protected] => a97bb994-6e24-4a89-b653-e0a6d0bcf634
[createdAt:protected] => 2015-01-30T11:46:11.439Z
[denomination:protected] => Array
(
[pair] => BTCBTC
[rate] => 1
[amount] => 2.0
[currency] => BTC
)
[destination:protected] => <snip>
[message:protected] =>
[origin:protected] => <snip>
[params:protected] => <snip>
[refundedById:protected] =>
[status:protected] => completed
[type] => transfer
)
```

### Get all public transactions
```php
require_once 'vendor/autoload.php';
Expand Down
2 changes: 1 addition & 1 deletion examples/Ticker.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// AUTHORIZATION_TOKEN because the Ticker endpoint is public.
$client = new Client();

// Get current user cards.
// Get tickers.
$tickers = $client->getTicker();

echo "*** Current exchange rates ***\n";
Expand Down