ceddyg/maileva-sdk-php

1.0.1 2020-10-06 12:17 UTC

This package is auto-updated.

Last update: 2024-09-06 21:27:41 UTC


README

API用于发送和跟踪由邮递员分发的在线推荐信。它包括创建发送、添加文档和收件人、选择选项(黑白或彩色、单面或双面、是否带AR…)的关键功能。

  • 创建发送,
  • 添加文档和收件人,
  • 选择选项(黑白或彩色、单面或双面、带或不带AR…)。
  • 跟踪生产(计划日期、发送跟踪…)。请参阅“notification_center”文档。

需求

PHP 5.5及以后版本

安装与使用

Composer

要通过Composer安装绑定,请在composer.json中添加以下内容

composer require ceddyg/maileva-sdk-php

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门

请遵循安装过程,然后运行以下命令

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/registered_mail/v2

模型文档

授权文档

bearerAuth

  • 类型:HTTP bearer认证