定制 gschurgast/eudr-api-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gschurgast/eudr-api-client

最新稳定版本:v1.0.7

Composer 安装命令:

composer require gschurgast/eudr-api-client

包简介

Minimal EUDR SOAP client utilities and functional test

README 文档

README

This repository provides a minimal, typed PHP client for the European Union Deforestation Regulation (EUDR) SOAP services. It exposes small service classes, request/response DTOs, and a functional PHPUnit test. Internally it uses JMS Serializer for consistent array<->object transformations instead of ad‑hoc toArray/fromSoap code.

What's included

  • Services (src/Services):
    • EudrEchoClient
    • EudrSubmissionClient
    • EudrRetrievalClient
    • EudrClient facade to access the right service by ModeEnum
  • Request/Response DTOs (src/Dto) with JMS Serializer attributes
    • Requests: SubmitDdsRequest, AmendDdsRequest, GetDdsInfoRequest, GetStatementByIdentifiersRequest, GetReferenceDdsRequest, etc.
    • Responses: TestEchoResponse, SubmitDdsResponse, AmendDdsResponse, RetractDdsResponse, GetDdsInfoResponse, GetStatementByIdentifiersResponse, GetReferenceDdsResponse
    • Typed sub-objects in src/Dto/Type (StatementType, CommodityType, OperatorType, StatusType, ...)
  • Functional tests using PHPUnit: tests/Functional/DemoTest.php

Requirements

  • PHP >= 8.1
  • ext-soap, ext-dom
  • Composer

Install

  • make init

Running tests or acceptance tests

  • Edit your .env file to provide your credentials.
EUDR_USERNAME=your-username
EUDR_PASSWORD=your-password
  • make test

Create an EUDR client

  • Choose the environment via src\Enum\EnvironmentEnum (ACCEPTANCE or PRODUCTION).

  • Provide your credentials via environment variables (recommended for local dev put them in a .env file at the project root):

  • Instantiate the high-level client and pass credentials read from env:

$client = new EudrClient(getenv('EUDR_USERNAME'), getenv('EUDR_PASSWORD'), EnvironmentEnum::ACCEPTANCE);

Usage examples

Echo

$echoReq = new TestEchoRequest();
$echoReq->query = "My test query"
$testEchoResponse = $client->getClient(ModeEnum::ECHO)->testEcho($echoReq);

Submit

Submit DDS Request

$submitReq = new SubmitDdsRequest();
$submitReq->operatorType = OperatorTypeEnum::OPERATOR;
$submitReq->statement = new StatementType();
...
$submitDdsResponse = $client->getClient(ModeEnum::SUBMISSION)->submitDds($submitReq);

Amend DDS Request

$amendReq = new AmendDdsRequest();
$amendReq->ddsIdentifier = {{<ddsIdentifier>}};
$amendReq->statement = new StatementType();
...
$amendDdsResponse = $client->getClient(ModeEnum::SUBMISSION)->amendDds($amendReq);

Retract DDS Request

$retractReq = new AmendDdsRequest();
$retractReq->ddsIdentifier = {{<ddsIdentifier>}};
$retractReq->reason = "Reason of retractation";
$retractDdsResponse = $client->getClient(ModeEnum::SUBMISSION)->retractDds($retractReq);

Retrieval

Get DDS Info Request

$getDDSInfoReq = new GetDdsInfoRequest
$getDDSInfoReq->identifier = {{<ddsIdentifier>}};
$getDDSInfoResponse = $client->getClient(ModeEnum::RETRIEVAL)->getDdsInfo($getDDSInfoReq);

Get DDS Info by Internal Reference Number

$getDDSInfoByInternalRefReq = new GetDdsInfoByInternalReferenceNumberRequest
$getDDSInfoByInternalRefReq->identifier = {{<my_reference_number>}};
$getDDSInfoByInternalRefResponse = $client->getClient(ModeEnum::RETRIEVAL)->getDdsInfoByInternalReferenceNumber($getDDSInfoReq);
Get Statement by DDS Identifier
$getStatementByIdentifierReq = new GetStatementByIdentifiersRequest
$getStatementByIdentifierReq->referenceNumber = {{<ddsReferenceNumber>}};
$getStatementByIdentifierReq->verificationNumber = {{<ddsVerificationNumber>}};
$getStatementByIdentifierResponse = $client->getClient(ModeEnum::RETRIEVAL)->getStatementByIdentifiers($getDDSInfoReq);

Get Reference DDS (No test has been performed on this method)

$getReferenceDDSReq = new GetReferenceDdsRequest
$getReferenceDDSReq->referenceNumber = {{<ddsReferenceNumber>}};
$getReferenceDDSReq->referenceDdsVerificationNumber = {{<ddsVerificationNumber>}};
$getReferenceDDSResponse = $client->getClient(ModeEnum::RETRIEVAL)->getReferencedDds($getDDSInfoReq);

Functional tests

  • tests/Functional/DemoTest.php builds DTOs from fixtures (tests/fixtures/payloads.yaml) and can perform real calls when credentials are valid.
  • Use composer run test:functional to execute the suite.

Notes

  • EudrEchoClient operations must not be used in production environments per EUDR rules.
  • Service methods return dedicated Response DTOs mapping SOAP responses to typed PHP objects.

License

MIT

统计信息

  • 总下载量: 1.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-23