mpp / generali-client-bundle
Symfony Generali Client Bundle
Installs: 6 599
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 6
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.0
- ext-json: *
- eightpoints/guzzle-bundle: ^8.0
- symfony/dependency-injection: ^4.0 | ^5.0 | ^6.0
- symfony/framework-bundle: ^4.0 | ^5.0 | ^6.0
- symfony/monolog-bundle: *
- symfony/options-resolver: ^4.0 | ^5.0 | ^6.0
- symfony/property-info: ^4.0 | ^5.0 | ^6.0
- symfony/serializer: ^4.0 | ^5.0 | ^6.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/property-access: ^4.0 | ^5.0
- symfony/yaml: ^4.0 | ^5.0
- dev-master
- v3.11.3
- v3.11.2
- v3.11.1
- v3.11.0
- 3.10.2
- 3.10.1
- v3.10.0
- v3.9.0
- v3.8.5
- v3.8.4
- v3.8.3
- v3.8.2
- v3.8.1
- v3.8.0
- v3.7.1
- v3.7.0
- v3.6.1
- v3.6.0
- v3.5.0
- v3.4.0
- v3.3.3
- v3.3.2
- v3.3.1
- v3.3.0
- v3.2.1
- v3.2.0
- v3.1.0
- v3.0.2
- v3.0.1
- v3.0.0
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.0
- dev-fix/get-docs-for-kyc-update
- dev-feat/add-kyc-update-client
- dev-fix/api-response-error-messages
- dev-feat/add-contract-status-constant
- dev-refactor/apireponse-messages
- dev-feat/add-etat-situation
- dev-fix/replace-bad-character
- dev-fix/partial-repurchased-data
- dev-fix-create-contractans-model
- dev-fix/info-vlp
- dev-fix-handle-ö
- dev-fix/seralization-for-special-i
- dev-fix-contract-model
- dev-fix/return-type
- dev-fix/pieceAFournir
- dev-hotfix-replace-characters-not-handle
- dev-feat/add-context-field
- dev-mpp-CU-860pd0nqt
- dev-fix-fund-model
- dev-fix/get-contract-data
- dev-fix/depecated
- dev-mpp-CU-ahxdec
- dev-fix-amendement-type
- dev-fix/missing-amendment-model
- dev-fix/edit-scheduled-payment
- dev-fix/ordering
- dev-fix/orders-bad-type
- dev-fix-bad-type
This package is auto-updated.
Last update: 2024-04-14 09:51:41 UTC
README
Installation
To install this bundle, simply run the following command:
$ composer require mpp/generali-client-bundle
Configuration
First you must configure a guzzle client using eight point guzzle in the file config/packages/eight_points_guzzle.yaml
:
eight_points_guzzle: clients: my_generali_client: base_url: '%env(GENERALI_BASE_URL)%' options: timeout: 30 http_errors: true headers: 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
:
mpp_generali_client: http_client: 'eight_points_guzzle.client.mpp_generali' # reference to guzzle client app_code: '%env(string:GENERALI_APP_CODE)%' default_context: 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 ###
GENERALI_BASE_URL=https://generalifrprod-recette.apigee.net/epart
GENERALI_API_KEY=YOUR_API_KEY
GENERALI_APP_CODE=YOUR_APP_CODE
GENERALI_DEFAULT_PROVIDER_CODE=YOUR_PROVIDER_CODE
GENERALI_DEFAULT_SUBSCRIPTION_CODE=YOUR_SUBSCRIPTION_CODE
###< mpp/generali-client-bundle ###
Clients
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 ?
<?php 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
- [WIP] GeneraliArbitrationClient (arbitration)
- [WIP] GeneraliContractClient (contract)
- [WIP] GeneraliAttachmentClient (document)
- [WIP] GeneraliFreePaymentClient (free_payment)
- [WIP] GeneraliFundsClient (funds)
- [WIP] GeneraliPartialRepurchaseClient (partial_repruchase)
- [WIP] GeneraliScheduledFreePaymentClient (scheduled_free_payment)
- [WIP] GeneraliScheduledFreePaymentEditClient (scheduled_free_payment_edit)
- [WIP] GeneraliScheduledFreePaymentSuspendClient (scheduled_free_payment_suspend)
- GeneraliSubscriptionClient (subscription)
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:
<?php 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
Tests
Update the environment variables in phpunit.xml.dist
or create a phpunit.xml
file:
<!-- ... --> <php> <!-- ... --> <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="" /> <!-- ... --> </php> <!-- ... -->
Then, use the following commands if you want to run the tests suite
$ make composer-install # once
$ make phpunit
TODO
- There is a problem with "avenant" field which can be bool or objet depending on context in GeneraliFundsClient & other clients
- Finish client tests