rits-tecnologia/melhorenvio-php-sdk

Melhor Envio PHP SDK

0.0.4 2020-06-02 18:35 UTC

This package is auto-updated.

Last update: 2025-03-29 00:50:43 UTC


README

This package provides PHP SDK to the Melhor Envio API (https://docs.menv.io).

Installation

Install this package with composer.

composer require rits-tecnologia/melhorenvio-php-sdk

Usage

$melhorenvio = new MelhorEnvio(env('MELHORENVIO_TOKEN'));

// repositories
$melhorenvio->shipments();
$melhorenvio->carriers();

Examples

$response = $melhorenvio->shipments()->calculate([
    'from' => [
        'postal_code' => '59082000',
    ],
    'to' => [
        'postal_code' => '59148485',
    ],
    'options' => [
        'receipt' => false,
        'own_hand' => false,
    ],
    'services' => '1,2',
    'products' => [
        [
            'id' => 'x',
            'width' => 11,
            'height' => 17,
            'length' => 11,
            'weight' => 0.3,
            'insurance_value' => 10.1,
            'quantity' => 1,
        ],
        [
            'id' => 'x',
            'width' => 20,
            'height' => 10,
            'length' => 11,
            'weight' => 0.5,
            'insurance_value' => 20.1,
            'quantity' => 2,
        ],
    ],
]);