sgdf/intranet-api-client

PHP client for the SGDF Intranet API.

Maintainers

Package info

gitlab.com/sgdf/sgdf-intranetapi-php-client

Issues

pkg:composer/sgdf/intranet-api-client

Transparency log

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

v1.0.0 2026-07-12 18:37 UTC

This package is not auto-updated.

Last update: 2026-07-28 17:31:29 UTC


README

A PHP 8.2+ Composer library that wraps the SGDF Intranet API behind a small, typed, PSR-18/PSR-17-based HTTP client. Guzzle is the default transport but any PSR-18 client can be injected.

Installation

composer install

Authentication is handled for you: the client obtains an OAuth2 access token (client-credentials grant) from Keycloak, caches it until it expires, and sends it — together with the idAppelant caller header — on every request. Responses are returned as typed model objects; the API's { data, errors } envelope is unwrapped automatically and business errors are raised as ApiErrorException.

Quick start

Qualification:


baseUri: 'https://test-api-sgdf-qual.intrassoc.com'
tokenUrl: 'https://auth.sgdf-qual.intrassoc.com/auth/realms/sgdf_qualification/protocol/openid-connect/token'

Production:


baseUri: 'https://intranetapi.sgdf.fr'
tokenUrl: 'https://auth.sgdf.fr/auth/realms/sgdf_production/protocol/openid-connect/token'

Example:

use Sgdf\IntranetApi\Client\Configuration;
use Sgdf\IntranetApi\Client\IntranetApiClient;

$client = IntranetApiClient::create(new Configuration(
    baseUri: 'https://test-api-sgdf-qual.intrassoc.com',
    tokenUrl: 'https://auth.sgdf-qual.intrassoc.com/auth/realms/sgdf_qualification/protocol/openid-connect/token',
    oauthClientId: 'my-client-id',
    clientSecret: 'my-client-secret',
    idAppelant: 'my-calling-id',
));

// Typed access through resource groups:
foreach ($client->configuration()->listCivilites() as $civilite) {
    echo $civilite->getId() . ' → ' . $civilite->getLibelle() . "\n";
}

You can also inject your own PSR-18 client, PSR-17 factories and token provider for full control:

$client = new IntranetApiClient($httpClient, $requestFactory, $streamFactory, $configuration, $tokenProvider);

Configuration & credentials

Local access is read from a git-ignored .env file. Copy the template:

cp .env.dist .env
# then fill in the base URI, token URL, OAuth client id/secret and idAppelant

Never commit .env.

Development

composer test        # run the offline unit test suite
composer qa          # style check + static analysis + tests

Integration tests hit the real API and are skipped unless SGDF_API_INTEGRATION_TESTS=1 and SGDF_API_BASE_URI are set in .env.