esilvajr/via-cep-sdk

There is no license information available for the latest version (0.1.0beta) of this package.

Biblioteca de integração com viaCep

0.1.0beta 2017-11-03 05:24 UTC

This package is auto-updated.

Last update: 2024-11-13 11:20:59 UTC


README

Installation

composer require esilvajr/via-cep-sdk

How to use

Search using zipcode
$viaCep = new \ViaCep\ViaCep();
$address = $viaCep->ZipCode('13566590')
                  ->find(new \ViaCep\Requests\Json());
return $address->toArray();

Search using address
$viaCep = new \ViaCep\ViaCep();
$addresses = $viaCep->Address('SP', 'São Carlos', 'Carlos Botelho')
                    ->find(new \ViaCep\Requests\Json());
return $address->toArray();

Dev

Exceptions
AddressNotFoundException: {
    "code": 404,
    'Message: "Addresses not found. Try again with a different one."
}

InvalidZipCodeFormatException: {
    "code": 400,
    'Message: "ZipCode must be a string that contains only number. See: https://viacep.com.br/ in Validação do Cep sector."
}