PHP code example of fragoso-software / integra-icp-sdk
1. Go to this page and download the library: Download fragoso-software/integra-icp-sdk 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/ */
fragoso-software / integra-icp-sdk example snippets
namespace FragosoSoftware\IntegraIcpSdk\Contracts;
use FragosoSoftware\IntegraIcpSdk\Models\AuthenticationResponse;
interface AuthenticationInterface
{
/**
* Método para obter a lista de Clearances (provedores de autenticação).
*
* @param array $params Parâmetros para a requisição (ex.: subject_key, callback_uri).
* @return AuthenticationResponse Retorna a resposta de autenticação encapsulada em um modelo.
*/
public function getClearances(array $params): AuthenticationResponse;
}
namespace FragosoSoftware\IntegraIcpSdk\Contracts;
interface HttpClientInterface
{
public function get(string $url, array $params = []): array;
public function post(string $url, array $data): array;
}
namespace FragosoSoftware\IntegraIcpSdk\Contracts;
use FragosoSoftware\IntegraIcpSdk\Models\SignatureResponse;
interface SignatureInterface
{
/**
* Realiza uma assinatura digital usando os dados fornecidos.
*
* @param array $data Dados necessários para a assinatura, incluindo `credentialId` e `hashes`.
* @return SignatureResponse Retorna a resposta da assinatura encapsulada em um modelo.
*/
public function sign(array $data): SignatureResponse;
}
namespace FragosoSoftware\IntegraIcpSdk\Services;
use FragosoSoftware\IntegraIcpSdk\Contracts\AuthenticationInterface;
use FragosoSoftware\IntegraIcpSdk\Contracts\HttpClientInterface;
use FragosoSoftware\IntegraIcpSdk\Models\AuthenticationResponse;
class AuthenticationService implements AuthenticationInterface
{
private HttpClientInterface $httpClient;
private string $baseUrl;
public function __construct(HttpClientInterface $httpClient, string $baseUrl)
{
$this->httpClient = $httpClient;
$this->baseUrl = $baseUrl;
}
public function getClearances(array $params): AuthenticationResponse
{
$url = "{$this->baseUrl}/authentications";
$response = $this->httpClient->get($url, $params);
return new AuthenticationResponse($response);
}
}
namespace FragosoSoftware\IntegraIcpSdk\Services;
use FragosoSoftware\IntegraIcpSdk\Contracts\SignatureInterface;
use FragosoSoftware\IntegraIcpSdk\Contracts\HttpClientInterface;
use FragosoSoftware\IntegraIcpSdk\Models\SignatureResponse;
class SignatureService implements SignatureInterface
{
private HttpClientInterface $httpClient;
private string $baseUrl;
public function __construct(HttpClientInterface $httpClient, string $baseUrl)
{
$this->httpClient = $httpClient;
$this->baseUrl = $baseUrl;
}
public function sign(array $data): SignatureResponse
{
$url = "{$this->baseUrl}/signatures";
$response = $this->httpClient->post($url, $data);
return new SignatureResponse($response);
}
}
namespace FragosoSoftware\IntegraIcpSdk\Models;
class AuthenticationResponse
{
private array $clearances;
public function __construct(array $data)
{
$this->clearances = $data['clearances'] ?? [];
}
public function getClearances(): array
{
return $this->clearances;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.