2017 © Pedro Peláez
 

library nocks-sdk-php

PHP SDK for the Nocks API

image

nocksapp/nocks-sdk-php

PHP SDK for the Nocks API

  • Tuesday, June 19, 2018
  • by nocksapp
  • Repository
  • 4 Watchers
  • 3 Stars
  • 203 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 26 Versions
  • 9 % Grown

The README.md

Latest Stable Version Total Downloads Latest Unstable Version, (*1)

Nocks SDK PHP

Nocks SDK PHP is a php package for Nocks. It can be used in any php >=5.4.0 environment. The SDK supports both the calls to the Nocks api endpoints as well to the oauth endpoints., (*2)



Installation

This SDK uses composer., (*3)

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you., (*4)

For more information on how to use/install composer, please visit: https://github.com/composer/composer, (*5)

To install this SDK into your project with composer, simply use:, (*6)

$ composer require nocksapp/nocks-sdk-php, (*7)

Getting Started

Oauth

The NocksOauth class provides the following methods:, (*8)

  • getOauthUri
  • requestToken
  • refreshToken
  • passwordGrantToken
  • scopes
  • tokenScopes

Example

require '../../vendor/autoload.php';

use Nocks\SDK\NocksOauth;
use Nocks\SDK\Constant\Platform;

try {
    $clientId = '1';
    $clientSecret = '1234';
    $scopes = ['user.read'];
    $redirectUri = 'https://www.example.com';

    $nocksOauth = new NocksOauth(Platform::SANDBOX, $clientId, $clientSecret, $scopes, $redirectUri);
    $uri = $nocksOauth->getOauthUri();

    // For example, redirect the user to the Nocks login page
    header('Location: ' . $uri);
    die();
} catch (\Nocks\SDK\Exception\Exception $e) {
    // Handle any SDK exception
}

Please checkout the oauth docs and examples to see how the oauth methods can be used., (*9)

API

The NocksApi class provides all the Nocks resources. Please checkout the resources docs and examples., (*10)

require '../../vendor/autoload.php';

use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;

try {
    $accessToken = 'your_access_token';
    $nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);

    $user = $nocksApi->user->findAuthenticated();
} catch (\Nocks\SDK\Exception\Exception $e) {
    // Handle any SDK exception
}

Results

The result returned from a method call in the SDK will differ, please check the PHPDocs to see what will be returned from a method. Most of the time it will be a Model or a NocksResponse., (*11)

Model

A Model is just a simple object which holds the data returned from the api. Each Model will provide the necessary getters and setters for the specific data., (*12)

NocksResponse

A NocksResponse is an object which holds a data array and a pagination object. This is typically returned from a .find method., (*13)

Example:, (*14)

require '../../vendor/autoload.php';

use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;

try {
    $accessToken = 'your_access_token';
    $nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);

    $result = $nocksApi->transaction->find();
    $result->getPagination(); // Do something with pagination

    // Loop through transactions
    foreach ($result->getData() as $transaction) {
        // Do something with the transaction
    }   
} catch (\Nocks\SDK\Exception\Exception $e) {
    // Handle any SDK exception
}

Exceptions

The SDK uses the following exceptions. All exceptions are inherit from Nocks\SDK\Exception\Exception., (*15)

  • Nocks\SDK\Exception\Exception (super)
    • Nocks\SDK\Exception\HttpException (super)
      • Nocks\SDK\Exception\BadRequestException
      • Nocks\SDK\Exception\ForbiddenException
      • Nocks\SDK\Exception\GoneException
      • Nocks\SDK\Exception\InternalServerError
      • Nocks\SDK\Exception\MethodNotAllowedException
      • Nocks\SDK\Exception\NotAcceptable
      • Nocks\SDK\Exception\NotFoundException
      • Nocks\SDK\Exception\ServiceUnavailable
      • Nocks\SDK\Exception\TooManyRequests
      • Nocks\SDK\Exception\UnauthorizedException
    • Nocks\SDK\Exception\ValidationException
    • Nocks\SDK\Exception\ScopeConfigurationException

HttpException

A HttpException is thrown when a http call to Nocks fails. The HttpException is the super exception and the actual exception that is thrown is corresponding to the http statuscode, see the documentation., (*16)

ValidationException

A ValidationException may occur when you call a function with invalid parameters or when there are missing required parameters. For example:, (*17)

use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;

try {
    $accessToken = 'your_access_token';
    $nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);

    $userToUpdate = new User();
    // $userToUpdate->setUuid('1234'); Will occur in an exception when not set
    $user = $nocksApi->user->update($userToUpdate);
} catch (\Nocks\SDK\Exception\ValidationException $e) {
    // A ValidationException will be thrown when the $userToUpdate has no uuid
}

Note that the SDK doesn't check your request data, if there is something wrong with your data, the http call will resolve in a HttpException, (*18)

ScopeConfigurationException

A ScopeConfigurationException may occur when calling a function which depends on a certain scope parameter that was not provided. For example, calling a private resource while there was no accessToken configured:, (*19)

use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;

try {
    $accessToken = null;
    $nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);

    $userToUpdate = new User([
        'uuid' => '1234',
        'locale' => 'nl_NL',
    ]);
    $user = $nocksApi->user->update($userToUpdate);
} catch (\Nocks\SDK\Exception\ScopeConfigurationException $e) {
    // A ScopeConfigurationException will be thrown when the $accessToken is null
}

Examples

In the examples directory you will find examples for each call that is supported in this SDK., (*20)

Support

Need help or support? Please check https://www.nocks.com/support., (*21)

Found a bug? Please check the existing GitHub issues and open a new issue if necessary. Or even better, create a pull request to directly resolve the issue you have found!, (*22)

The Versions

19/06 2018

dev-master

9999999-dev https://nocks.com/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

api payment sdk bitcoin blockchain transaction nocks gulden

19/06 2018

v1.0.2

1.0.2.0 https://nocks.com/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

api payment sdk bitcoin blockchain transaction nocks gulden

19/06 2018

dev-develop

dev-develop https://nocks.com/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

api payment sdk bitcoin blockchain transaction nocks gulden

14/06 2018

v1.0.1

1.0.1.0 https://nocks.com/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

api payment sdk bitcoin blockchain transaction nocks gulden

13/06 2018

v1.0.0

1.0.0.0 https://nocks.com/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

api payment sdk bitcoin blockchain transaction nocks gulden

03/10 2017

v0.0.21

0.0.21.0 https://nocks.co/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

11/09 2017

v0.0.20

0.0.20.0 https://nocks.co/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

18/03 2017

v0.0.19

0.0.19.0 https://nocks.co/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

24/01 2017

v0.0.18

0.0.18.0 https://nocks.co/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

29/11 2016

v0.0.17

0.0.17.0 https://nocks.co/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

07/10 2016

v0.0.16

0.0.16.0 https://nocks.co/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

19/06 2016

v0.0.15

0.0.15.0 https://nocks.co/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

11/06 2016

v0.0.14

0.0.14.0 https://nocks.co/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

10/06 2016

v0.0.13

0.0.13.0 https://nocks.co/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

10/06 2016

v0.0.12

0.0.12.0 https://nocks.co/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

22/04 2016

v0.0.11

0.0.11.0 https://nocks.nl/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

25/03 2016

v0.0.10

0.0.10.0 https://nocks.nl/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks gulden

25/01 2016

v0.0.9

0.0.9.0 https://nocks.nl/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks guldencoin

06/11 2015

v0.0.8

0.0.8.0 https://nocks.nl/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks guldencoin

06/11 2015

v0.0.7

0.0.7.0 https://nocks.nl/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks guldencoin

06/11 2015

v0.0.6

0.0.6.0 https://nocks.nl/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks guldencoin

05/11 2015

v0.0.5

0.0.5.0 https://nocks.nl/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks guldencoin

05/11 2015

v0.0.4

0.0.4.0 https://nocks.nl/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks guldencoin

23/09 2015

v0.0.3

0.0.3.0 https://nocks.nl/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks guldencoin

13/09 2015

v0.0.2

0.0.2.0 https://nocks.nl/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks guldencoin

10/09 2015

v0.0.1

0.0.1.0 https://nocks.nl/

PHP SDK for the Nocks API

  Sources   Download

MIT

The Requires

 

api payment sdk bitcoin blockchain transaction nocks guldencoin