mpp / generali-client-bundle
Symfony Generali Client Bundle
该软件包的官方仓库似乎已消失,因此该软件包已被冻结。
v3.11.4
2024-06-21 13:15 UTC
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.4
- 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/add-situation-const
- 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-06-21 13:17:21 UTC
README
Symfony Bundle用于与Generali API交互
安装
要安装此软件包,请运行以下命令
$ composer require mpp/generali-client-bundle
配置
首先,您必须使用八点Guzzle在文件config/packages/eight_points_guzzle.yaml
中配置一个Guzzle客户端
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)%'
然后,您必须在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)%'
将这些环境变量放入您的.env
文件中
###> 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 ###
客户端
规范名称 | 基本路径 | 客户端 | 客户端别名 |
---|---|---|---|
套利 | /v2.0/transaction/arbitrage | GeneraliArbitrationClient | arbitration |
合同 | /v2.0/contrats | GeneraliContractClient | contract |
基金 | /v1.0/fonds | GeneraliFundsClient | funds |
证明文件 | /v1.0/transaction/piecesAFournir & /v1.0/transaction/fournirPiece | GeneraliAttachmentClient | document |
部分回购 | /v1.0/donnees/rachatpartiel | GeneraliPartialRepurchaseClient | partial_repruchase |
文档管理 | /v2.0/document | GeneraliDocumentClient | document |
订阅 | /v2.0/transaction/souscription | GeneraliSubscriptionClient | subscription |
自由支付 | /v2.0/transaction/versementLibre | GeneraliFreePaymentClient | free_payment |
计划自由支付 | /v2.0/transaction/versementsLibresProgrammes | GeneraliScheduledFreePaymentClient | scheduled_free_payment |
计划自由支付 - 修改 | /v1.0/transaction/modificationVersementsLibresProgrammes | GeneraliScheduledFreePaymentEditClient | scheduled_free_payment_edit |
计划自由支付 - 暂停 | /v1.0/transaction/suspensionVersementsLibresProgrammes | GeneraliScheduledFreePaymentSuspendClient | scheduled_free_payment_suspend |
如何使用?
如何获取特定客户端域名?
<?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 // ... } }
如何使用每个客户端?
下面提供了每个客户端的用法示例
- [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)
如何轻松创建模型对象?
感谢 ModelFactory,您可以通过 createFromArray
和 createFromJson
方法创建具有深层关系的对象。
以下是一个示例
<?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')); } }
API 的工作原理(已过时)
首先,您需要创建一个 订阅,在订阅中,您将发送有关客户和所需订阅的所有必要信息。
然后,您将获得一个合同编号,该编号将用于创建
您将使用特定代码来设置某些属性,请在构建数据结构时查看这里。
如何获取合同编号?
- 在开发环境中:您需要联系您的Generali合作伙伴
- 在预生产和生产环境中:您需要解析由sftp访问提供的某些csv文件。您可以通过搜索在订阅创建过程中提供的内部参考1和/或内部参考2来找到合同编号。
测试
更新 phpunit.xml.dist
中的环境变量或创建一个 phpunit.xml
文件
<!-- ... --> <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> <!-- ... -->
然后,如果您想运行测试套件,请使用以下命令
$ make composer-install # once
$ make phpunit
待办事项
- 在GeneraliFundsClient和其他客户中,“avenant”字段存在问题,该字段可能根据上下文为布尔值或对象
- 完成客户测试