PHP code example of clubfixinsurtech / susep-sandbox-api

1. Go to this page and download the library: Download clubfixinsurtech/susep-sandbox-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/ */

    

clubfixinsurtech / susep-sandbox-api example snippets




// Inicialize o Connector definindo o ambiente de trabalho
// 

$connector = new Susep\Connector(production: false);

// Definindo o Token de Acesso
$auth = new \Susep\Requests\Auth(
    clientId: $env('SUSEP_CLIENT_ID'),
    clientSecret: $env('SUSEP_CLIENT_SECRET'),
    username: $env('SUSEP_USERNAME'),
    password: $env('SUSEP_PASSWORD')
);

$authResponse = $connector->send($auth);
$token = $authResponse->json('access_token');

$connector->withTokenAuth($token);


// Obtendo os dados da Agenda com suas respectivas competências

$agendaInfoRequest = $connector->send(new \Susep\Requests\AgendaInfo);

$agenda = $agendaInfo->json();
$agendaId = $agenda['agendaEntidadeId'];

// Enviando os dados de acordo com um competência

$sendFileReq = new \Susep\Requests\SendFile(
    agendaId: $agendaInfo->json('id'),
    files: json_encode([/*...*/])
);

$responseSentFile = $connector->send($sendFileReq);

$response = $responseSentFile->json();