emSzmal Banking API wrapper in PHP
PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
src
.gitignore
LICENSE.md
README.md
composer.json

README.md

emSzmal Banking API wrapper in PHP

Latest Version on Packagist Software License Total Downloads StyleCI SensioLabsInsight

emSzmal Banking API wrapper in PHP

Install

Via Composer

$ composer require kduma/emszmal-api

Usage

$api = new \KDuma\emSzmalAPI\emSzmalAPI($api_id, $api_key);

$BankCredentials = new BankCredentials(\KDuma\emSzmalAPI\Bank::PKOiPKO, "Login", "Password");

$accounts = $api->GetAccountsList($BankCredentials);
$transactions = $api->GetAccountHistory("account number", '2016-10-25', '2016-10-30', $BankCredentials);

Laravel Usage

Setup

Then add the Service Provider to the providers array in config/app.php:

KDuma\emSzmalAPI\Laravel\ServiceProvider::class,

Add following entries to your .env file:

EMSZMAL_API_ID="<api id>"
EMSZMAL_API_KEY=<api key>

EMSZMAL_BANK_PROVIDER_ID=<provider ID>
EMSZMAL_BANK_LOGIN=<login>
EMSZMAL_BANK_PASSWORD=<password>

Usage

You can resolve emSzmalAPI::class class:

use KDuma\emSzmalAPI\emSzmalAPI;

$api = app(emSzmalAPI::class);

$accounts = $api->GetAccountsList();
$transactions = $api->GetAccountHistory("account number", '2016-10-25', '2016-10-30');

or You can use injection container

use KDuma\emSzmalAPI\emSzmalAPI;

Route::get('/api', function (emSzmalAPI $api) {
    $accounts = $api->GetAccountsList();
    $transactions = $api->GetAccountHistory("account number", '2016-10-25', '2016-10-30');
});

Multiple Bank Credentials

You can use multiple bank credentials. First, run the following command to copy config file:

php artisan vendor:publish --provider="KDuma\emSzmalAPI\Laravel\ServiceProvider"

In Your config/emszmalapi.php file, in bank_credentials section add additional credentials:

'bank_credentials' => [
    'bank_1' => [
        'provider' => env('EMSZMAL_BANK_1_PROVIDER_ID'),
        'login' => env('EMSZMAL_BANK_1_LOGIN'),
        'password' => env('EMSZMAL_BANK_1_PASSWORD'),
        'user_context' => env('EMSZMAL_BANK_1_USER_CONTEXT', "I"),
    ],
    'bank_2' => [
        'provider' => env('EMSZMAL_BANK_2_PROVIDER_ID'),
        'login' => env('EMSZMAL_BANK_2_LOGIN'),
        'password' => env('EMSZMAL_BANK_2_PASSWORD'),
        'user_context' => env('EMSZMAL_BANK_2_USER_CONTEXT', "I"),
    ],
],

Now you can use the alias when calling API methods:

use KDuma\emSzmalAPI\emSzmalAPI;

$api = app(emSzmalAPI::class);

$bank_1_accounts = $api->GetAccountsList('bank_1');
$bank_1_transactions = $api->GetAccountHistory("account number", '2016-10-25', '2016-10-30', 'bank_1');

$bank_2_accounts = $api->GetAccountsList('bank_2');
$bank_2_transactions = $api->GetAccountHistory("account number", '2016-10-25', '2016-10-30', 'bank_2');

Credits

License

The MIT License (MIT). Please see License File for more information.