assoconnect / linxo-client
PHP Client for the Linxo API
Installs: 7 718
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 6
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.2|^8.3
- ext-json: *
- assoconnect/php-date: ^2.2
- guzzlehttp/guzzle: ^7.4
- koriym/http-constants: ^1.2
- league/oauth2-client: ^2.6
- moneyphp/money: ^3.3|^4.0
- symfony/translation: ^5.4|^6.0|^7.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-28 14:42:47 UTC
README
Installation
composer require assoconnect/linxo-client
Documentation
Use the official documentation.
Quick start
<?php use AssoConnect\LinxoClient\AuthClient; // Set up the AuthClient with your credentials $authClient = new AuthClient( 'clientId', 'clientSecret', 'http://your-app.com/linxo/redirect' ); // OAuth2 code exchange $token = $authClient->getTokenFromCode('code'); // OAuth2 token refresh $newToken = $authClient->refreshToken($token->getRefreshToken()); // Get an API Client for a given user identified by its access token $apiClient = $authClient->createApiClient($token->getToken()); $apiClient->getAccounts(); // List of Linxo bank accounts
Tests
This lib ships with a Guzzle system to mock API responses.
It will answer a mocked response if one is defined for a given request, or will call the API.
How to use it
<?php use AssoConnect\LinxoClient\Dto\AccountDto; use AssoConnect\LinxoClient\Test\MockAuthClient; use AssoConnect\LinxoClient\Test\MockFactory; $authClient = new MockAuthClient( 'clientId', 'clientSecret', 'http://your-app.com/linxo/redirect' ); $middleware = $authClient->getMiddleware(); // Create your own mock responses $middleware->stackAccount([ 'id' => '1', 'connection_id' => '2', 'name' => 'My account', 'iban' => 'FR4930003000703896912638U72', 'status' => AccountDto::STATUS_ACTIVE, 'currency' => 'EUR', ]); // You can also mock you or transactions $middleware->stackMe(...); $middleware->stackTransaction(...); $apiClient = $authClient->createApiClient('token'); $apiClient->getAccount('1'); // Will return the mocked DTO $apiClient->getAccount('2'); // Will call the API // Or you can use a factory to get predefined content $factory = new MockFactory($middleware); $factory->mockAccount([ 'name' => 'My 2nd account' // Replace only what you want ]); $factory->mockMe(...); $factory->mockTransaction(...);