Skip to content

A Laravel package that provides a simple way to use the Brasil API endpoints.

License

Notifications You must be signed in to change notification settings

rafaellaurindo/laravel-brasilapi

Repository files navigation

Laravel Brasil API

Latest Stable Version GitHub Tests Action Status GitHub Code Style Action Status License Total Downloads

A Laravel package that provides a simple way to use the Brasil API endpoints.

Installation

You can install the package via composer:

composer require rafaellaurindo/laravel-brasilapi

You can publish the config file with:

php artisan vendor:publish --provider="RafaelLaurindo\BrasilApi\BrasilApiServiceProvider" --tag="config"

Usage

You can use the methods from Dependency Injection, Facade or helper.

Using from Dependency Injection:

use RafaelLaurindo\BrasilApi\BrasilApi;

class ExampleController
{
    public function searchZipCode(BrasilApi $brasilApi)
    {
        return response()->json($brasilApi->cep('01431000'));
    }
}

Using from Facade:

use BrasilApi;

BrasilApi::cep('01431000');

Using from helper:

brasilApi()->getBank(77);

After you've installed the package. All the following examples use the facade. Don't forget to import it at the top of your file.

use BrasilApi;

Searching address by zip code:

BrasilApi::cep('01431000');

Get Brazilian banks list:

BrasilApi::getBanks();

Get a bank from code:

BrasilApi::getBank(77);

Find company information using the CNPJ:

BrasilApi::findCnpj('19131243000197');

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.