docs-dispatcher.io/sdk
Composer 安装命令:
composer require docs-dispatcher.io/sdk
包简介
PHP client to consume docs-dispatcher.io API services
README 文档
README
DocsDispatcher PHP Client
Versions
| SDK version | PHP version | Branch |
|---|---|---|
| v0.1.x | 7.2+ | php-7x |
| v0.2.x | 8.1+ | develop |
Installation
$ composer require docs-dispatcher.io/sdk
Getting started
Concepts
This library relays on the following concepts in order to be able to use it with a minimal knowledge of the API itself.
Authentication
Two authentication methods are supported:
- Basic Auth (username/password)
- Bearer Token (JWT token) - recommended for API v3.6+
Service(s)
A service is an API endpoint having its own parameters. For a detailed list of them, please read the API documentation, also available as Swagger format.
ServiceMediator
A single class that will be in charge to temporary store your defined services and their corresponding configurations in order to build the request to be sent to the API.
Client
The class that actually triggers calls to API. It decorates a GuzzleHttp\Client instance.
Usage
A realistic usage can be found in the attached sample file exemple.php. For more details about configuring each services, please refer to the API documentation.
Authentication Examples
Using Bearer Token (JWT) - Recommended:
use DocsDispatcherIo\Sdk\Authentication\BearerTokenAuthentication;
use DocsDispatcherIo\Sdk\Client;
$authentication = new BearerTokenAuthentication('your-jwt-token-here');
$client = new Client($authentication);
Using Basic Auth:
use DocsDispatcherIo\Sdk\Authentication\BasicAuthAuthentication;
use DocsDispatcherIo\Sdk\Client;
$authentication = new BasicAuthAuthentication('username', 'password');
$client = new Client($authentication);
Available Services
The SDK supports the following services:
- EmailService: Send emails with attachments
- FileService: Generate documents from templates
- SmsService: Send SMS messages
- PostalService: Send postal mail
- ESignService: Handle electronic signatures
- UploadService: Upload files to external services
- InvoicingService: Create invoices, quotes, or credit notes (IpaidThat, Qonto, Stripe)
Invoicing Service Example
use DocsDispatcherIo\Sdk\Argument\Address;
use DocsDispatcherIo\Sdk\Argument\Enums\CustomerTypes;
use DocsDispatcherIo\Sdk\Argument\Enums\DiscountTypes;
use DocsDispatcherIo\Sdk\Argument\Enums\InvoiceDocumentTypes;
use DocsDispatcherIo\Sdk\Argument\InvoiceCustomer;
use DocsDispatcherIo\Sdk\Argument\InvoiceItem;
use DocsDispatcherIo\Sdk\Service\InvoicingService;
use DocsDispatcherIo\Sdk\ServiceMediator;
// Create customer billing address
$billingAddress = new Address(
'Acme Corp', // Name
'123 Main Street', // Address
'75001', // Postal code
'Paris', // City
'FR' // Country code
);
// Create a company customer
$customer = new InvoiceCustomer(
CustomerTypes::COMPANY,
'billing@acme.com',
$billingAddress
);
$customer
->setName('Acme Corporation')
->setVatNumber('FR12345678901')
->setRegistrationNumber('123456789')
->setPhone('+33123456789');
// Create invoice items
$item1 = new InvoiceItem('Consulting Services', 150.00);
$item1
->setQuantity(10.0)
->setTaxPercent(20.0)
->setAdditionalInfo('Monthly retainer');
$item2 = new InvoiceItem('Development Services', 200.00);
$item2
->setQuantity(5.0)
->setTaxPercent(20.0)
->setDiscount(DiscountTypes::PERCENTAGE, 10.0, 'Volume discount');
// Create the invoicing service
$invoicingService = new InvoicingService(
$customer,
[$item1, $item2],
InvoiceDocumentTypes::INVOICE,
'2025-11-20' // Issue date
);
$invoicingService
->setProvider('ipaidthat') // or 'qonto' or 'stripe'
->setTitle('Monthly Services Invoice')
->setExternalId('INV-2025-001')
->setCurrency('EUR')
->setLocale('fr_FR')
->setDueDate('2025-12-31')
->setShipping(25.50)
->setDiscount(DiscountTypes::PERCENTAGE, 5.0, 'Early payment discount')
->setSendByEmail(true)
->addRecipientEmail('finance@acme.com')
->setSendCopy(true);
$serviceMediator = new ServiceMediator([$invoicingService]);
$response = $client->executeRequest($serviceMediator, 'application/json');
Customer Types:
CustomerTypes::COMPANY- For businesses (requiresname,registrationNumber,vatNumber)CustomerTypes::INDIVIDUAL- For consumers (requiresfirstname,lastname)CustomerTypes::FREELANCE- For freelancers (requiresfirstname,lastname, optionalbusinessName,registrationNumber,vatNumber)
Document Types:
InvoiceDocumentTypes::INVOICE- Standard invoiceInvoiceDocumentTypes::E_INVOICE- Electronic invoice (e-facture)InvoiceDocumentTypes::QUOTE- Quotation/estimateInvoiceDocumentTypes::CREDIT- Credit note
docs-dispatcher.io/sdk 适用场景与选型建议
docs-dispatcher.io/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 906 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 12 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 docs-dispatcher.io/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 docs-dispatcher.io/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 906
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-12-15