Skip to content

wdoyle/Mondo-Client

 
 

Repository files navigation

Thepixeldeveloper\Mondo

Author Version Status Software License Packagist Version Total Downloads SensioLabsInsight Scrutinizer Code Quality

A Mondo Bank API Client - https://getmondo.co.uk/docs

This library is an MVP and only supports the basic functionality. Doesn't yet support pagination, expansions and file uploads. Pull requests happily accepted.

Install

composer require thepixeldeveloper/mondo-client

Quick start

// Get a client from the factory.
$client = (new Thepixeldeveloper\Mondo\ClientFactory('access_token'))->getClient();

// Pass the client into the relevant Client class.
$ping = new Thepixeldeveloper\Mondo\Client\Ping($client);

// Response is of the type \Psr\Http\Message\ResponseInterface
$response = $ping->whoAmI();

var_dump($response->getBody()->getContents());

Should give us ...

{
    "authenticated": true,
    "client_id": "...",
    "user_id": "..."
}

Accounts

$accounts = new Thepixeldeveloper\Mondo\Client\Accounts($client);

var_dump($accounts->getAccounts()->getBody()->getContents())
{
    "accounts": [
        {
            "id": "...",
            "account_number": "...",
            "sort_code": "...",
            "created": "2016-01-12T12:44:45.367Z",
            "description": "John Smith"
        }
    ]
}

Balance

$balance = new Thepixeldeveloper\Mondo\Client\Balance($client);

var_dump($balance->getBalanceForAccountId('...')->getBody()->getContents())
{
    "balance": 0,
    "currency": "GBP",
    "spend_today": 0
}

Transactions

All transactions

$transactions = new Thepixeldeveloper\Mondo\Client\Transactions($client);

var_dump($transactions->getTransactionsForAccountId('...')->getBody()->getContents())
{
    "transactions": [
        {
            "id": "...",
            "created": "2016-02-23T12:34:54.683Z",
            "description": "Initial top up",
            "amount": 10000,
            "currency": "GBP",
            "merchant": null,
            "notes": "",
            "metadata": {},
            "account_balance": 10000,
            "attachments": [],
            "category": "mondo",
            "is_load": true,
            "settled": "2016-02-23T12:34:54.683Z",
            "local_amount": 10000,
            "local_currency": "GBP"
        },
        ...
    ]
}

Specific transaction

$transactions = new Thepixeldeveloper\Mondo\Client\Transactions($client);

var_dump($transactions->getTransaction('...')->getBody()->getContents())
{
    "transaction": {
        "id": "...",
        "created": "2016-02-23T12:34:54.683Z",
        "description": "Initial top up",
        "amount": 10000,
        "currency": "GBP",
        "merchant": null,
        "notes": "",
        "metadata": {},
        "account_balance": 10000,
        "attachments": [],
        "category": "mondo",
        "is_load": true,
        "settled": "2016-02-23T12:34:54.683Z",
        "local_amount": 10000,
        "local_currency": "GBP"
    }
}

OAuth 2

I've decided to leave out authentication for the MVP. Use a library like League/oauth2-client to get yourself an access token.

Testing

Run the phpSpec tests with ...

composer test

About

Mondo Bank API Client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%