PHP code example of stitch-digital / laravel-simpro-api
1. Go to this page and download the library: Download stitch-digital/laravel-simpro-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stitch-digital / laravel-simpro-api example snippets
return [
/*
|--------------------------------------------------------------------------
| Simpro Base URL
|--------------------------------------------------------------------------
|
| Set the base URL for the Simpro API. This option is not ------------------------------------------------------
|
| Set the API key for the Simpro API. This option is not he cache driver can
| be set to any of the Laravel cache drivers. The cache expiry time is
| set in seconds.
|
*/
'cache' => [
'enabled' => true,
'driver' => 'database',
'expire' => 120,
],
/*
|--------------------------------------------------------------------------
| Rate Limit Configuration
|--------------------------------------------------------------------------
|
| Set the rate limit for Simpro requests. The rate limit is set per second
| and the threshold is the percentage of the rate limit that is accepted.
| The threshold must be a number between 0 and 1 (e.g. 0.5 for 50%).
|
| The default rate limit is as per the Simpro API documentation.
|
*/
'rate_limit' => [
'enabled' => true,
'per_second' => 10,
'driver' => 'database',
'threshold' => 0.8,
],
/*
|--------------------------------------------------------------------------
| Global Retry Configuration
|--------------------------------------------------------------------------
|
| Set the number of retries for all requests. This can still be overridden
| on a per-request basis, by chaining sendAndRetry() to the request:
|
| Example:
| $response = $connector->sendAndRetry($request, 1);
|
*/
'global_retries' => 3, // Set to null to disable global retries
];
use StitchDigital\LaravelSimproApi\Facades\Simpro;
use StitchDigital\LaravelSimproApi\Requests\Info\GetInfo;
$response = Simpro::send(new GetInfo())->json();
use StitchDigital\LaravelSimproApi\LaravelSimproApi;
use StitchDigital\LaravelSimproApi\Requests\Info\GetInfo;
$connector = new LaravelSimproApi(
baseUrl: 'https://custom-api-url.simprosuite.com',
apiKey: 'custom-api-key'
);
$response = $connector->send(new GetInfo());
$response->json();