Skip to content

mon-petit-placement/mpp-apicil-client-bundle

Repository files navigation

Symfony Bundle to interact with Apicil API

Installation

To install this bundle, simply run the following command:

$ composer require mpp/apicil-client-bundle

Configuration

First create a guzzle client:

// config/packages/eight_point_guzzle.yaml
eight_points_guzzle:
    clients:
        my_apicil_client:
            base_url: '%env(APICIL_BASE_URL)%'
            options:
                auth:
                    - '%env(APICIL_USERNAME)%'
                    - '%env(APICIL_PASSWORD)%'
        my_apicil_sign_client:
            base_url: '%env(APICIL_BASE_URL)%'
            options:
                auth:
                    - '%env(APICIL_SIGN_USERNAME)%'
                    - '%env(APICIL_SIGN_PASSWORD)%'

Then configure this client to be used by the bundle:

// config/packages/mpp_apicil_client.yaml
mpp_apicil_client:
    http_client: 'eight_points_guzzle.client.my_apicil_client'
    sign_http_client: 'eight_points_guzzle.client.my_apicil_sign_client'

Make sure to have enabled the serializer & property info component in symfony configuration (for serialization/deserialization):

// config/packages/framework.yaml
framework:
    serializer:
        enabled: true
    property_info:
        enabled: true

Clients

Here is the mapping of client for each specification name

Specification name Base path Client Client domain alias Usable ?
Actualisation Connaissance Client /connaissanceclient ApicilAccClient acc Yes
Arbitrage /arbitrage ApicilArbitrationClient arbitration Yes
Compte titre /comptestitres ApicilTradingAccountClient trading_account Yes
Contrat /contrats ApicilContractClient contract Yes
/contratscollectifs ApicilCollectiveContractClient collective_contract Yes
Données de références /referentiel ApicilReferentialClient referential Yes
/produit ApicilProductClient product Yes
KYC /profilfinancier ApicilFinancialProfileClient financial_profile Yes
/kyc/coordonnees ApicilKycContactInformationClient kyc_contact_information Yes
/kyc/iban ApicilKycIbanClient kyc_iban Partially
Preconisation - interne /interne/preconisation/contrat ApicilPreconizationClient preconization Yes
Profil de gestion /modegestion ApicilManagementClient management Yes
Rachat /rachatpartiel ApicilPartialRepurchaseClient partial_repurchase Yes
/rachattotal ApicilTotalRepurchaseClient total_repurchase Yes
Souscription /projet ApicilProjectClient project Yes
Versement /versement ApicilPaymentClient payment Yes

How to use ?

How to get a specific client domain ?

Here is a sample controller on how to get a specific client domain:

<?php

namespace App\Controller;

use Mpp\ApicilClientBundle\Client\ApicilClientDomainRegistryInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

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

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

How to use each clients ?

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

Tests

Update the environment variables in phpunit.xml.dist:

<!-- ... -->
<php>
    <!-- ... -->
    <env name="APP_ENV" value="test" />
    <env name="APICIL_BASE_URL" value="APICIL_BASE_URL" />
    <env name="APICIL_USERNAME" value="USEERNAME" />
    <env name="APICIL_PASSWORD" value="PASSWORD" />
    <!-- ... -->
</php>
<!-- ... -->

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

$ make composer-install # once

$ make phpunit

TODO

  • Create missing model/dto classes used in clients
    • CourtierDto
    • DonneesReferencesActifDto
    • FraisEncoursDto
    • PeriodiciteDto
    • ResultatDeCreationResource
    • SituationCompteDto
    • ProfilFinancierActeDto
    • ProfilFinancierConsultationDto
    • ProfilFinancierDto
    • ProfilFinancierQuestionDto
    • RepartitionDto
    • ChangementCoordonneesDto
    • ErreurCodeFonctionnelDto
    • IbanDto
    • RachatPartielDtoDeConsultation
    • EmailPropositionDto
    • RecuperationVersementSuppression
    • SuppressionOptionDto
    • ModeGestionDto
    • QuestionSupportStructureDto
    • EmailPropositionSouscriptionDto
    • ListDocumentDto
    • CompteTitreDto
    • ContratProfilGestionDto
    • RecuperationContratProfileGestionDto
    • TrClasseActifDto
    • BasePreconisationDto
    • TrProfilAllocationAutoriseDto
  • Add unit tests
    • ApicilAccClient
    • ApicilArbitrationClient
    • ApicilTradingAccountClient
    • ApicilContractClient
    • ApicilCollectiveContractClient
    • ApicilReferentialClient
    • ApicilProductClient
    • ApicilFinancialProfileClient
    • ApicilKycContactInformationClient
    • ApicilKycIbanClient
    • ApicilPreconizationClient
    • ApicilManagementClient
    • ApicilPartialRepurchaseClient
    • ApicilTotalRepurchaseClient
    • ApicilProjectClient
    • ApicilPaymentClient
  • Update documetation
    • Add client exemple usage for all routes in documentation
  • Enhance how options are resolved (ex: how file related fields are handled => add Trait ?)