justbetter / laravel-exact-client
A client to interact with Exact
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.5
- laravel/framework: ^11.0|^12.0
- spatie/laravel-activitylog: ^4.9
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.21
- orchestra/testbench: ^9.10
- pestphp/pest: ^3.7
- phpstan/phpstan-mockery: ^2.0
- phpunit/phpunit: ^11.5
README
Laravel Exact Client
A client to communicate with Exact from your Laravel application.
Installation
Install the composer package.
composer require justbetter/laravel-exact-client
Setup
Publish the configuration of the package.
php artisan vendor:publish --provider="JustBetter\ExactClient\ServiceProvider" --tag=config
Run the migrations.
php artisan migrate
Add the following keys to your .env
file:
EXACT_CLIENT_ID= EXACT_CLIENT_SECRET= EXACT_DIVISION=
Out of the box, the connection is called default
.
Middleware
By default, no middleware has been added to authorize with Exact. Update the middleware
in your configuration to add proper authentication and authorization.
Exact Apps
You have to create a new app in Exact Online. Make sure your account has the necessary permissions, otherwise you will be redirected back to the login page.
- Open the login page.
- Click on the login button in the section "Exact Online App Store"
- Register a new app.
Make sure the redirect URL is the callback URL of the application. This must be an HTTPS address.
https://localhost/exact/callback/default
Divisions in the configuration file must be unique across all connections.
Initiate Authentication
In order to initiate the authentication process with Exact, open the following link.
https://localhost/exact/authorize/default
After finishing the process, you can check your connection by requesting all available divisions.
php artisan exact:list-divisions default
Tokens are stored in the database.
Retaining Access
Making calls to Exact will make sure the tokens remain valid. The package automatically refreshes the tokens when required. If you are not regularly making calls to Exact, you should add the command below to your scheduler. Otherwise, the refresh token may expire and you'll have to authenticate with Exact again. A refresh token is valid for 30 days.
$schedule->command(\JustBetter\ExactClient\Commands\RefreshTokenCommand::class, [ 'connection' => 'default', ])->weekly();
Rate Limits
Exact is known for their strict rate limiting. It's generally recommended to distribute a load over a longer period of time. To prevent unnessecary failures further, this package includes a RateLimitMiddleware
which is a job middleware to automatically release jobs back on the queue if a rate limit has been exceeded.
use JustBetter\ExactClient\Jobs\Middleware\RateLimitMiddleware; public function middleware(): array { return [ RateLimitMiddleware::division('default'), ]; }
Rate limits are stored in the database.
Quality
To ensure the quality of this package, run the following command:
composer quality
This will execute three tasks:
- Makes sure all tests are passed
- Checks for any issues using static code analysis
- Checks if the code is correctly formatted
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.