2017 © Pedro Peláez
 

library bitreserve-sdk-php

Uphold SDK PHP for the Uphold API

image

seegno/bitreserve-sdk-php

Uphold SDK PHP for the Uphold API

  • Tuesday, April 17, 2018
  • by fixe
  • Repository
  • 16 Watchers
  • 16 Stars
  • 35 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 12 Forks
  • 4 Open issues
  • 18 Versions
  • 0 % Grown

The README.md

Uphold SDK for PHP

Latest Version Build Status Code Climate Test Coverage License, (*1)

Uphold is a next generation money service business that shields you from bitcoin volatility by enabling you to hold bitcoin as the money you use every day., (*2)

The Uphold SDK for PHP provides an easy way for developers to integrate PHP applications with the Uphold API., (*3)

Requirements

  • PHP >= 5.5 with the cURL extension.
  • Guzzle library.

Installation

Standalone

Grab the latest version of the library:, (*4)

$ git clone https://github.com/seegno/uphold-sdk-php.git

Install composer:, (*5)

$ curl -s https://getcomposer.org/installer | php

Install the library dependencies:, (*6)

$ php composer.phar install

Require the autoloader file generated by composer:, (*7)

require 'vendor/autoload.php';

Integrating with another project using composer

Require the library package as a dependency:, (*8)

{
    "require": {
        "seegno/uphold-sdk-php": "~5.0"
    }
}

Basic usage

In order to learn more about the Uphold API, please check out the API documentation., (*9)

First, create a Personal Access Token (PAT) using the command described below., (*10)

Create a Personal Access Token

$ php lib/Uphold/console.php tokens:create

Then, create a new instance of the Client class with token. Take a look at the following examples and explore more on the examples directory., (*11)

Authorize user

require_once 'vendor/autoload.php';

use Uphold\UpholdClient as Client;

// Initialize the client.
$client = new Client(array(
  'client_id' => 'APPLICATION_CLIENT_ID',
  'client_secret' => 'APPLICATION_CLIENT_SECRET',
));

// Authorize user using the code parameter from the application redirect url.
$user = $client->authorizeUser('CODE');

// Get the Bearer token.
$bearer = $user->getClient()->getOption('bearer');

Get authenticated user

require_once 'vendor/autoload.php';

use Uphold\UpholdClient as Client;

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

// Get user.
$user = $client->getUser('AUTHORIZATION_TOKEN');

Get user balances

require_once 'vendor/autoload.php';

use Uphold\UpholdClient as Client;

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

// Get user.
$user = $client->getUser('AUTHORIZATION_TOKEN');

// Get user balances for all currencies.
$balances = $user->getBalances();

You could get user total balance:, (*12)

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

The above produces the output shown below:, (*13)

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

Get user cards

require_once 'vendor/autoload.php';

use Uphold\UpholdClient as Client;

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

// Get user.
$user = $client->getUser('AUTHORIZATION_TOKEN');

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

Create new card

require_once 'vendor/autoload.php';

use Uphold\UpholdClient as Client;

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

// Get the current user.
$user = $client->getUser('AUTHORIZATION_TOKEN');

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

The above produces the output shown below:, (*14)

Uphold\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 rates

require_once 'vendor/autoload.php';

use Uphold\UpholdClient as Client;

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

// Get rates (public endpoint).
$rates = $client->getRates();

Or you could get rates for a specific currency:, (*15)

// Get rates for BTC.
$rates = $client->getRatesByCurrency('BTC');

The above produces the output shown below:, (*16)

Array
(
    [0] => Uphold\Model\Rate Object
        (
            [ask:protected] => 1
            [bid:protected] => 1
            [currency:protected] => BTC
            [pair:protected] => BTCBTC
        )

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

Create and commit a new transaction

require_once 'vendor/autoload.php';

use Uphold\UpholdClient as Client;

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

// Get user.
$user = $client->getUser('AUTHORIZATION_TOKEN');

// Get a specific card by id.
$card = $user->getCardById('ade869d8-7913-4f67-bb4d-72719f0a2be0');

// Create a new transaction.
$transaction = $card->createTransaction('foo@bar.com', '2.0', 'BTC');

// Commit the transaction.
$transaction->commit();

The above produces the output shown below:, (*17)

Uphold\Model\Transaction Object
(
    [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

require_once 'vendor/autoload.php';

use \Uphold\UpholdClient as Client;

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

// Get all public transactions (public endpoint).
$pager = $client->getReserve()->getTransactions();

// Get next page of transactions.
$transactions = $pager->getNext();

Or you could get a specific public transaction:, (*18)

// Get one public transaction.
$transaction = $client->getReserve()->getTransactionById('a97bb994-6e24-4a89-b653-e0a6d0bcf634');

Get reserve status

require_once 'vendor/autoload.php';

use \Uphold\UpholdClient as Client;

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

// Get the reserve summary of all the obligations and assets within it (public endpoint).
$statistics = $client->getReserve()->getStatistics();

Pagination

Some endpoints will return a paginator. Here is some examples on how you can handle it., (*19)

// Get public transactions.
$pager = $client->getReserve()->getTransactions();

// Check whether the paginator has a valid next page.
while($pager->hasNext()) {
    // Get next page with results.
    $transactions = $pager->getNext();

    // Do something...
}

Tests

Run the tests from the root directory:, (*20)

$ ./vendor/bin/phpunit

You can find PHPUnit documentation here., (*21)

Contributing & Development

Contributing

Found a bug or want to suggest something? Take a look first on the current and closed issues. If it is something new, please submit an issue., (*22)

Develop

It will be awesome if you can help us evolve uphold-sdk-php. Want to help?, (*23)

  1. Fork it.
  2. php composer.phar install.
  3. Hack away.
  4. Run the tests: phpunit.
  5. Create a Pull Request.

The Versions

17/04 2018
14/08 2015
11/03 2015
24/02 2015
21/02 2015
29/01 2015
23/01 2015

1.0.1

1.0.1.0 https://github.com/seegno/bitreserve-sdk-php

Bitreserve SDK PHP for the Bitreserve API

  Sources   Download

MIT

The Requires

 

The Development Requires

php sdk bitreserve

22/01 2015

1.0.0

1.0.0.0 https://github.com/seegno/bitreserve-sdk-php

Bitreserve SDK PHP for the Bitreserve API

  Sources   Download

MIT

The Requires

 

The Development Requires

php sdk bitreserve