jerfeson/correios

A library that facilitates integration with Brazilian postal services

1.0.0 2021-09-18 02:35 UTC

This package is auto-updated.

Last update: 2024-11-20 23:02:34 UTC


README

build Latest Version on Packagist Software License Minimum PHP Version GitHub all releases

This library facilitates the integration with the Correios delivery services of Brazil on php

Functionalities

Installation

  • Using composer
    $ composer require jerfeson/correios

How to use

Consult address by zip code

use Jerfeson\Correios;

require 'vendor/autoload.php';

$correios = new Correios();
$repsonse = $correios->address()->find("73100‑020");

/** result 
[
    'zipcode' => '01001-000',
    'street' => 'Praça da Sé',
    'complement' => [
        'lado ímpar',
    ],
    'district' => 'Sé',
    'city' => 'São Paulo',
    'uf' => 'SP',
]

**/

Calculate Prices and Deadlines

Calculate prices and terms of delivery services (Sedex, PAC and etc), with support for multiple objects in the same query.

use Jerfeson\Correios;

require 'vendor/autoload.php';

$correios = new Correios();

$response = $correios->freight()
    ->origin('01001-000')
    ->destination('73100‑020')
    ->services(FreightType::SEDEX, FreightType::PAC)
    ->item(16, 16, 16, .3, 1)->calculate();
    
    
/** result
[
    0 =>
        [
            'name' => 'Sedex',
            'code' => '4014',
            'price' => 35.1,
            'deadline' => 4,
            'error' => [],
        ],
    1 =>
        [
            'name' => 'PAC',
            'code' => '4510',
            'price' => 24.8,
            'deadline' => 8,
            'error' =>[],
        ],
]
*/

How to test

    $ composer test

Roadmap

  • CodeCoverage

License

jerfeson/correios is release under the MIT license.

Thanks

This project is based on the project in flyingluscas/correios-php feel free to contribute to this and the other project.