Skip to content

Commit

Permalink
add-cep service remove example folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jhowbhz committed May 24, 2023
1 parent 9c143ec commit 9b531e2
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 42 deletions.
32 changes: 0 additions & 32 deletions Examples/WhatsApp.php

This file was deleted.

46 changes: 36 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# SDK PHP - APIGratis <small> by API BRASIL</small> 🚀
This package is free and can be used for API Brazil website functions
Conjunto de API, para desenvolvedores.

_Transforme seus projetos em soluções inteligentes com nossa API. Com recursos como API do WhatsApp, geolocalização, rastreamento de encomendas, verificação de CPF/CNPJ e mais, você pode criar soluções eficientes e funcionais. Comece agora._


[![latest stable version](https://poser.pugx.org/jhowbhz/apigratis-sdk-php/v/stable.svg)](https://packagist.org/packages/jhowbhz/apigratis-sdk-php)
[![license mit](https://poser.pugx.org/jhowbhz/apigratis-sdk-php/license.svg)](https://packagist.org/packages/jhowbhz/apigratis-sdk-php)
Expand All @@ -26,14 +29,15 @@ https://packagist.org/packages/jhowbhz/apigratis-sdk-php

| Up | Services available | Description | Free | Beta | Stable |
------|-------------------------------|-------------------|---------| ------------------------- | ------------------------- |
|| WhatsAppService | Free in WhatsApp API. ||||
|| Receita Data CNPJ | API CNPJ or data of Receita Federal BR. ||||
|| Receita Data CPF | API CPF or data of SERASA Brazil. ||||
|| CorreiosService | API CEP or Tracker packages, correios Brazil. ||||
|| VehiclesService | API Plate get infos vehicle. ||||
|| FipeService | FIPE value the velhicle plate. ||||

## Install package with composer
|| WhatsAppService | API do WhatsApp Gratuita. ||||
|| Receita Data CNPJ | API Dados CNPJ Receita. ||||
|| Receita Data CPF | API Dados de CPF Serasa. ||||
|| CorreiosService | API Busca encomendas Correios Brazil. ||||
|| CEPLocation | API CEP Geolocation + IBGE Brazil. ||||
|| VehiclesService | API Placa Dados. ||||
|| FipeService | API Placa FIPE. ||||

## Instalando pacote com o composer
```bash
composer require jhowbhz/apigratis-sdk-php
```
Expand Down Expand Up @@ -152,7 +156,6 @@ $address = Service::Correios("address", [
var_dump($address);
die;
```

## CNPJService
- Obtenha dados de endereço através de um CNPJ de várias formas
- Lista CNAES
Expand Down Expand Up @@ -181,3 +184,26 @@ $cnpj = Service::CNPJ("cnpj", [
var_dump($cnpj);
die;
```

## CEPLocation
- Com essa API é possível obter dados de coordenadas LAT e LONG e código IBGE apenas com o CEP

```php
<?php

require_once('vendor/autoload.php');
use ApiBrasil\Service;

$cnpj = Service::CEP("geolocation", [
"Bearer" => "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.....",
"SecretKey" => "f87eb607-a8cc-43ea-b439...",
"PublicToken" => "3f279a5c-bfbc-11ed-afa1...",
"DeviceToken" => "d019580b-3c8c-40e3-b9a0....",
"body" => [
"cep" => "32146057",
]
]);

var_dump($cnpj);
die;
```
30 changes: 30 additions & 0 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,34 @@ public static function CNPJ(String $action = '', Array $data = []) {

}

public static function CEP(String $action = '', Array $data = []) {

try {

$base_uri = "https://cluster.apigratis.com/api/v1/cep/".$action;
$method = $data['method'] ?? 'POST';

$headers = [
"Content-Type" => "application/json",
"Accept" => "application/json",
"Authorization" => "Bearer ".$data['Bearer'],
"SecretKey" => $data['SecretKey'] ?? '',
"PublicToken" => $data['PublicToken'] ?? '',
"DeviceToken" => $data['DeviceToken'] ?? '',
];

$body = $data['body'] ?? [];

$response = self::defaultRequest($method, $base_uri, $action, $headers, $body);
return $response;

} catch (ClientException $e) {

$response = $e->getResponse();
return json_decode((string)($response->getBody()->getContents()));

}

}

}

0 comments on commit 9b531e2

Please sign in to comment.