This is a simple API for calling REST API's against Sigma. It handles authentication for you so install, add the environment variables, and start making REST API calls!
Requires PHP >= 8.0.
composer require interworks/sigmarestNext, add the following required environment variables to your .env file:
SIGMA_API_URL="https://YOUR-API-URL.com"
SIGMA_CLIENT_ID="YOUR-CLIENT-ID"
SIGMA_CLIENT_SECRET="YOUR-CLIENT-SECRET"Use the following doc from Sigma to find these values: Get started with the Sigma REST API
There is a function for each documented Sigma REST API endpoint. Those endpoints can be found here: Sigma REST API Documentation
Instantiate a SigmaREST object and start making calls!
use InterWorks\SigmaREST\SigmaREST;
// Instantiate
$sigma = new SigmaREST();
// Get first 100 users and create a collection.
$users = $sigma->getMembers(['limit' => 100]);
$users = collect($users['entries']);
// Get first 10 workbooks, loop through each and get their sources
$workbooks = $sigma->getWorkbooks(['limit' => 10]);
$sources = [];
foreach ($workbooks['entries'] as $workbook) {
$sources[] = $sigma->getWorkbookSource($workbook['workbookId']);
}If there's an endpoint missed, you can use the call function to specify the URL, arguments, and method. The function returns a Illuminate\Http\Client\Response object.
$response = $sigma->call(
url : 'cool/unknown/endpoint',
args : ['name' => 'Cool thing'],
method: 'POST'
);
$response->json();By default, either an array or boolean will be returned depending on the endpoint. If you'd like more control over how the response is processed, you can set returnResponseObject to true in the constructor to always receive the Illuminate\Http\Client\Response object.
$sigma = new SigmaREST(returnResponseObject: true);
$response = $sigma->getMembers(['limit' => 100]);
$success = $response->successful();
$body = $response->body();
$users = $response->json();This package is released under the MIT License. See LICENSE for details.