moneymeg/starling-php-sdk

There is no license information available for the latest version (1.0) of this package.

A PHP SDK for the Starling Banking API.

1.0 2017-11-23 12:14 UTC

This package is not auto-updated.

Last update: 2024-05-12 02:47:54 UTC


README

CircleCI StyleCI 68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f30313632336639656362643638613534613630302f6d61696e7461696e6162696c697479

This is an SDK for the starling SDK, you'll have to take care of getting tokens from users but once you have one this SDK will wrap the whole API to allow for ease of use in PHP.

Right now its only read functions, I'll some write functions when I get around to using them.

See the tests folder for all the requests, you can pass any request to the request function on Starling\Api\Client if you want to write your own they'll need to implements RequestInterface

I didn't want to be too opinionated so responses are not formatted.

Install

composer require moneymeg/starling-php-sdk

Test

$ ./vendor/bin/phpunit

Get a users balance

$identity = new Starling\Identity($client_token);
$client = new Starling\Api\Client($identity, ['env' => 'prod']);
$request = new Starling\Api\Request\Accounts\Balance();

try {
    $result = $client->request($request);
    $body = json_decode((string) $result->getBody(), true);
    print "Your balance is " . $body['effectiveBalance'] . " as for right now.";
} catch (Exception $e) {
    print $e->getMessage();
}

Get a users account details

$identity = new Starling\Identity($client_token);
$client = new Starling\Api\Client($identity, ['env' => 'prod']);
$request = new Starling\Api\Request\Accounts();

try {
    $result = $client->request($request);
    $body = json_decode((string) $result->getBody(), true);
    print $body;
} catch (Exception $e) {
    print $e->getMessage();
}

Gets a customers Direct Debits

$identity = new Starling\Identity($client_token);
$client = new Starling\Api\Client($identity, ['env' => 'prod']);
$request = new Starling\Api\Request\DirectDebits();

try {
    $result = $client->request($request);
    $body = json_decode((string) $result->getBody(), true);
    print $body;
} catch (Exception $e) {
    print $e->getMessage();
}

Get transactions for the last 7 days

$identity = new Starling\Identity($client_token);
$client = new Starling\Api\Client($identity);

$request = new Starling\Api\Request\Transactions([
    'from' => new DateTime("-7 Days"),
    'to'   => new DateTime(),
]);

try {
    $result = $client->request($request);
    $body = json_decode((string) $result->getBody(), true);
    print $body;
} catch (Exception $e) {
    print $e->getMessage();
}