jp10 / maileva-simple-sdk
API 用于发送和跟踪邮政信件。它包括以下关键功能:- 创建发送,- 添加文档和收件人,- 选择选项,- 跟踪生产。要了解与此 API 相关的通知(webhooks),请参阅通知_center API 文档。
1.0.2
2023-10-26 11:20 UTC
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
README
API 用于发送和跟踪邮政信件。
它包括以下关键功能:
- 创建发送,
- 添加文档和收件人,
- 选择选项,
- 跟踪生产。
要了解与此 API 相关的通知(webhooks),请参阅 notification_center API 文档。
安装 & 使用
要求
PHP 7.4 及更高版本。也应该与 PHP 8.0 兼容。
Composer
要通过 Composer 安装绑定,请将以下内容添加到 composer.json
composer require jp10/maileva-simple-sdk
入门
请按照安装过程进行操作,然后运行以下命令
Maileva\Client\Maileva 类有 3 个功能
//Retourne un objet Maileva\Client\Api\EnvoiApi
$maileva->envoi();
//Retourne un objet Maileva\Client\Api\DocumentsApi
$maileva->documents():
//Retourne un objet Maileva\Client\Api\DestinatairesApi
$maileva->destinataires();
然后只需使用每个对象的端点即可。
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$maileva = new \Maileva\Client\Maileva(
'<YOU-MAILEVA-LOGIN>',
'<YOU-MAILEVA-PASSWORD>',
'<YOU-MAILEVA-client_id>',
'<YOU-MAILEVA-client_secret>',
new GuzzleHttp\Client(),
new \Maileva\Client\Configuration()
);
//Création d'une lettre
$body = new \Maileva\Client\Model\SendingCreation(
[
"name" => "Résiliation d'un abonnement téléphonique",
"custom_id" => "order_1234",
"custom_data" => "order_1234",
"acknowledgement_of_receipt" => true,
"acknowledgement_of_receipt_scanning" => true,
"color_printing" => true,
"duplex_printing" => true,
"optional_address_sheet" => false,
"notification_email" => "do_not_reply@maileva.com",
"sender_address_line_1" => "Société Durand",
"sender_address_line_2" => "M. Pierre DUPONT",
"sender_address_line_3" => "Batiment B",
"sender_address_line_4" => "10 avenue Charles de Gaulle",
"sender_address_line_5" => "",
"sender_address_line_6" => "94673 Charenton-Le-Pont",
"sender_country_code" => "FR",
"archiving_duration" => 3,
"return_envelope_reference" => 123456
]
); // \Maileva\Client\Model\RecipientCreation |
try {
$result = $maileva->envoi()->sendingsPost($body);
echo '<pre>';
print_r($result);
echo '</pre>';
} catch (Exception $e) {
echo 'Exception when calling EnvoiApi->sendingsPost: ', $e->getMessage(), PHP_EOL;
}
$sending_id = $result->getId();
//Suppression d'une lettre
try {
$result = $apiInstance->sendingsSendingIdDelete($sending_id);
echo '<pre>';
print_r($result);
echo '</pre>';
} catch (Exception $e) {
echo 'Exception when calling EnvoiApi->sendingsSendingIdDelete: ', $e->getMessage(), PHP_EOL;
}
//Récupération de toutes les lettres
try {
$result = $maileva->envoi()->sendingsGet();
echo '<pre>';
print_r($result);
echo '</pre>';
} catch (Exception $e) {
echo 'Exception when calling EnvoiApi->sendingsSendingIdGet: ', $e->getMessage(), PHP_EOL;
API 端点
所有 URI 都相对于 https://api.sandbox.maileva.net/mail/v2
类 | 方法 | HTTP 请求 | 描述 |
---|---|---|---|
DestinatairesApi | patchRecipient | PATCH /sendings/{sending_id}/recipients/{recipient_id} | 部分修改收件人 |
DestinatairesApi | sendingsSendingIdRecipientsDelete | DELETE /sendings/{sending_id}/recipients | 删除所有收件人 |
DestinatairesApi | sendingsSendingIdRecipientsGet | GET /sendings/{sending_id}/recipients | 发送的收件人列表 |
DestinatairesApi | sendingsSendingIdRecipientsImportsPost | POST /sendings/{sending_id}/recipients/imports | 向发送添加一个或多个收件人 |
DestinatairesApi | sendingsSendingIdRecipientsPost | POST /sendings/{sending_id}/recipients | 向发送添加收件人 |
DestinatairesApi | sendingsSendingIdRecipientsRecipientIdDelete | DELETE /sendings/{sending_id}/recipients/{recipient_id} | 删除收件人 |
DestinatairesApi | sendingsSendingIdRecipientsRecipientIdDeliveryStatusesGet | GET /sendings/{sending_id}/recipients/{recipient_id}/delivery_statuses | 收件人分发状态列表 |
DestinatairesApi | sendingsSendingIdRecipientsRecipientIdDownloadArchiveGet | GET /sendings/{sending_id}/recipients/{recipient_id}/download_archive | 下载发送给收件人的信件 |
DestinatairesApi | sendingsSendingIdRecipientsRecipientIdGet | GET /sendings/{sending_id}/recipients/{recipient_id} | 收件人详细信息 |
DocumentsApi | sendingsSendingIdDocumentsDocumentIdDelete | DELETE /sendings/{sending_id}/documents/{document_id} | 删除文档 |
DocumentsApi | sendingsSendingIdDocumentsDocumentIdGet | GET /sendings/{sending_id}/documents/{document_id} | 文档详细信息 |
DocumentsApi | sendingsSendingIdDocumentsDocumentIdSetPriorityPost | POST /sendings/{sending_id}/documents/{document_id}/set_priority | 文档分类 |
DocumentsApi | sendingsSendingIdDocumentsGet | GET /sendings/{sending_id}/documents | 发送的文档列表 |
DocumentsApi | sendingsSendingIdDocumentsPost | POST /sendings/{sending_id}/documents | 向发送添加文档 |
EnvoiApi | sendingsGet | GET /sendings | 发送列表 |
EnvoiApi | sendingsPost | POST /sendings | 创建发送 |
EnvoiApi | sendingsSendingIdDelete | DELETE /sendings/{sending_id} | 删除发送 |
EnvoiApi | sendingsSendingIdGet | GET /sendings/{sending_id} | 发送详细信息 |
EnvoiApi | sendingsSendingIdPatch | 补丁 /sendings/{sending_id} | 修改部分发件 |
EnvoiApi | sendingsSendingIdSubmitPost | POST /sendings/{sending_id}/submit | 完成发件 |
模型
- AcceptedImport
- CountryCode
- DeliveryStatusesResponse
- DeliveryStatusesResponseDeliveryStatusesInner
- DocumentResponse
- DocumentsOverrideItem
- DocumentsResponse
- EnvelopeType
- ErrorResponse
- ErrorsResponse
- ImportRecipients
- PagingResponse
- PostageType
- Priority
- RecipientCreation
- RecipientCreationImport
- RecipientPostageClass
- RecipientResponse
- RecipientStatus
- RecipientsCounts
- RecipientsImportResponse
- RecipientsResponse
- RejectedImport
- ReturnEnvelope
- ReturnEnvelopeOutput
- SendingCreation
- SendingResponse
- SendingStatus
- SendingUpdate
- SendingsResponse
- SendingsSendingIdDocumentsPostRequestMetadata
授权
为API定义的认证方案
bearerAuth
- 类型: 带证认证 (JWT)
oAuth2PasswordProduction
- 类型:
OAuth
- 流程:
password
- 授权URL: ``
- 作用域:
- all: 资源CRUD操作
oAuth2PasswordSandbox
- 类型:
OAuth
- 流程:
password
- 授权URL: ``
- 作用域:
- all: 资源CRUD操作
测试
要运行测试,请使用
composer install
vendor/bin/phpunit
作者
关于此包
此PHP包由OpenAPI Generator项目自动生成
- API版本:
2.8
- 构建包:
org.openapitools.codegen.languages.PhpClientCodegen