ceddyg/maileva-sdk-php

1.0.1 2020-10-06 12:17 UTC

This package is auto-updated.

Last update: 2024-12-06 21:55:23 UTC


README

API pour envoyer et suivre des Lettres Recommandées En Ligne distribuées par le facteur Elles comprennent les fonctions clés pour :

  • créer un envoi,
  • ajouter des documents et des destinataires,
  • choisir ses options (noir & blanc ou couleur, recto ou recto-verso, avec ou sans AR …).
  • suivre la production (date de planification, suivi de l’envoi…). Voir la documentation "notification_center".

Requirements

PHP 5.5 and later

Installation & Usage

Composer

To install the bindings via Composer, add the following to composer.json:

composer require ceddyg/maileva-sdk-php

Tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Getting Started

Please follow the installation procedure and then run the following:

La classe Maileva\Client\Maileva a 3 fonctions :

//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();

Il suffit ensuite d'utiliser les endpoints de chaque objet.

<?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;

Documentation for API Endpoints

All URIs are relative to https://api.sandbox.maileva.net/registered_mail/v2

Documentation For Models

Documentation For Authorization

bearerAuth

  • Type: HTTP bearer authentication