Symfony Generali Client Bundle

v3.11.0 2024-02-23 16:01 UTC



To install this bundle, simply run the following command:

$ composer require mpp/generali-client-bundle


First you must configure a guzzle client using eight point guzzle in the file config/packages/eight_points_guzzle.yaml:

            base_url: '%env(GENERALI_BASE_URL)%'
                timeout: 30
                http_errors: true
                    User-Agent: "MppGeneraliClient/v1.0"
                    Accept: 'application/json'
                    Content-Type: 'application/json'
                    apiKey: '%env(GENERALI_API_KEY)%'

Then you have to configure your credentials in config/packages/mpp_generali_client.yaml:

    http_client: 'eight_points_guzzle.client.mpp_generali' # reference to guzzle client
    app_code: '%env(string:GENERALI_APP_CODE)%'
        codeApporteur: '%env(string:GENERALI_DEFAULT_PROVIDER_CODE)%'
        codeSouscription: '%env(string:GENERALI_DEFAULT_SUBSCRIPTION_CODE)%'

Put these environment variables i your .env file:

###> mpp/generali-client-bundle ###
###< mpp/generali-client-bundle ###


Specification name Base path Client Client alias
Arbitrage /v2.0/transaction/arbitrage GeneraliArbitrationClient arbitration
Contrat /v2.0/contrats GeneraliContractClient contract
Fonds /v1.0/fonds GeneraliFundsClient funds
Pièces justificatives /v1.0/transaction/piecesAFournir & /v1.0/transaction/fournirPiece GeneraliAttachmentClient document
Rachat partiel /v1.0/donnees/rachatpartiel GeneraliPartialRepurchaseClient partial_repruchase
Gestion des documents /v2.0/document GeneraliDocumentClient document
Souscription /v2.0/transaction/souscription GeneraliSubscriptionClient subscription
Versement Libre /v2.0/transaction/versementLibre GeneraliFreePaymentClient free_payment
Versement libre programmé /v2.0/transaction/versementsLibresProgrammes GeneraliScheduledFreePaymentClient scheduled_free_payment
Versement libre programmé - Modification /v1.0/transaction/modificationVersementsLibresProgrammes GeneraliScheduledFreePaymentEditClient scheduled_free_payment_edit
Versement libre programmé - Suspension /v1.0/transaction/suspensionVersementsLibresProgrammes GeneraliScheduledFreePaymentSuspendClient scheduled_free_payment_suspend

How to use ?

How to get a specific client domain ?


namespace App\Controller;

use Mpp\GeneraliClientBundle\Client\GeneraliClientRegistryInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class ExampleController extends AbstractController
    public function exampleAction(GeneraliClientRegistryInterface $generaliClientRegistry)
        // Here are the three different available methods on how to retrieve a client domain by its alias (choose the one you prefer)
        $myClient = $generaliClientRegistry->get('client_domain_alias');
        // or
        $myClient = $generaliClientRegistry->getClientDomainAlias();

        // Execute operations from the retrieved client domain
        // ...

How to use each clients ?

You'll find an exemple of usage of each client below

How can I create model object easily

Thanks to the ModelFactory you can create objects with deep relationships thanks to createFromArray & createFromJson methods:

Here is an example:


namespace App\Controller;

use Mpp\GeneraliClientBundle\Factory\ModelFactory;
use Mpp\GeneraliClientBundle\Model\Arbitrage;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class ExampleController extends AbstractController
    public function exampleAction(ModelFactory $generaliModelFactory)
        $arbitration = $generaliModelFactory->createFromArray(Arbitrage::class, [
            'numOperationExterne' => 1234,
            'mandatTransmissionOrdre' => true,
            'mandatArbitrage' => false,
            'fondsInvestis' => [],
            'fondsDesinvestis' => [
                    'codeFonds' => 'FP12SN73DU4EJ',
                    'montant' => 750.40,
                    'pourcentage' => 0.4,
                    'avenantValide' => true,
                    'taux' => 5,
                    'duree' => 2,
                    'numeroEngagement' => 1,

        // or

        $arbitration = $generaliModelFactory->createFromJson(Arbitrage::class, file_get_contents('/path/to/arbitration.json'));

How the api works (outdated)

First you will have to create a Subscription, where you will send all the needed information on your customer and the subscription asked.

Then you will get a contractNumber which will be used to create:

You will use specifics code for some attributes, please check here when you will build your data structure.

How can you get the contract number ?

  • On development environment: you will have to contact your Generali Partner
  • On pre-production and on production environment: you will have to parse some csv files given by sftp access. You will find your contractNumber by searching for your internalReference1 and/or internalReference2 that you have given during your subscription creation


Update the environment variables in phpunit.xml.dist or create a phpunit.xml file:

<!-- ... -->
    <!-- ... -->
    <env name="APP_ENV" value="test" />
    <env name="GENERALI_BASE_URL" value="" />
    <env name="GENERALI_API_KEY" value="" />
    <env name="GENERALI_APP_CODE" value="" />
    <env name="GENERALI_DEFAULT_PROVIDER_CODE" value="" />
    <env name="GENERALI_DEFAULT_SUBSCRIPTION_CODE" value="" />
    <!-- ... -->
<!-- ... -->

Then, use the following commands if you want to run the tests suite

$ make composer-install # once
$ make phpunit


  • There is a problem with "avenant" field which can be bool or objet depending on context in GeneraliFundsClient & other clients
  • Finish client tests