Skip to content

Commit

Permalink
Merge pull request #7 from WillianAgostini/feat/cepV1
Browse files Browse the repository at this point in the history
feat: adicionado rota para cep V1
  • Loading branch information
WillianAgostini committed Mar 16, 2024
2 parents 34583b8 + 405e16b commit 223b19c
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -54,6 +54,14 @@ Buscando um banco específico pelo seu código.
const response = await api.bank.getBy(1);
```

### CEP V1

Buscando um CEP específico.

```js
const response = await api.cepV1.getBy('01001000');
```

### CEP V2

Buscando um CEP específico.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "brasilapi-js",
"version": "0.0.3",
"version": "1.0.0",
"description": "biblioteca em js para acessar Brasil Api",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
@@ -1,5 +1,6 @@
import * as bank from "./routes/bank";
import * as cep from "./routes/cep";
import * as cepV1 from "./routes/cepV1";
import * as cnpj from "./routes/cnpj";
import * as cvm from "./routes/cvm";
import * as ddd from "./routes/ddd";
Expand All @@ -24,6 +25,9 @@ export {
/** Informações referentes a CEPs */
cep,

/** Informações referentes a CEPs V1 */
cepV1,

/** Busca dados de empresas por CNPJ */
cnpj,

Expand Down
9 changes: 9 additions & 0 deletions src/routes/cepV1.ts
@@ -0,0 +1,9 @@
import { get } from "../service/api.service";
import { CepV1 } from "../types/cep";
import { onlyNumbers } from "../utils/format";

const endpointV1 = "/cep/v1/";

export const getBy = (cep: string) => {
return get<CepV1>(endpointV1 + onlyNumbers(cep));
};
1 change: 1 addition & 0 deletions test/module/cjs/index.js
Expand Up @@ -4,6 +4,7 @@ const api = require("brasilapi-js");
assert.strictEqual(typeof api.bank.getAll, "function");
assert.strictEqual(typeof api.bank.getBy, "function");
assert.strictEqual(typeof api.cep.getBy, "function");
assert.strictEqual(typeof api.cepV1.getBy, "function");
assert.strictEqual(typeof api.cnpj.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getAll, "function");
Expand Down
1 change: 1 addition & 0 deletions test/module/esm/index.js
Expand Up @@ -4,6 +4,7 @@ import api from "brasilapi-js";
assert.strictEqual(typeof api.bank.getAll, "function");
assert.strictEqual(typeof api.bank.getBy, "function");
assert.strictEqual(typeof api.cep.getBy, "function");
assert.strictEqual(typeof api.cepV1.getBy, "function");
assert.strictEqual(typeof api.cnpj.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getAll, "function");
Expand Down
1 change: 1 addition & 0 deletions test/module/ts-require/index.js
Expand Up @@ -4,6 +4,7 @@ const api = require("brasilapi-js");
assert.strictEqual(typeof api.bank.getAll, "function");
assert.strictEqual(typeof api.bank.getBy, "function");
assert.strictEqual(typeof api.cep.getBy, "function");
assert.strictEqual(typeof api.cepV1.getBy, "function");
assert.strictEqual(typeof api.cnpj.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getAll, "function");
Expand Down
1 change: 1 addition & 0 deletions test/module/ts-require/index.ts
Expand Up @@ -4,6 +4,7 @@ const api = require("brasilapi-js");
assert.strictEqual(typeof api.bank.getAll, "function");
assert.strictEqual(typeof api.bank.getBy, "function");
assert.strictEqual(typeof api.cep.getBy, "function");
assert.strictEqual(typeof api.cepV1.getBy, "function");
assert.strictEqual(typeof api.cnpj.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getAll, "function");
Expand Down
1 change: 1 addition & 0 deletions test/module/ts/index.js
Expand Up @@ -3,6 +3,7 @@ import api from "brasilapi-js";
assert.strictEqual(typeof api.bank.getAll, "function");
assert.strictEqual(typeof api.bank.getBy, "function");
assert.strictEqual(typeof api.cep.getBy, "function");
assert.strictEqual(typeof api.cepV1.getBy, "function");
assert.strictEqual(typeof api.cnpj.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getAll, "function");
Expand Down
1 change: 1 addition & 0 deletions test/module/ts/index.ts
Expand Up @@ -4,6 +4,7 @@ import api from "brasilapi-js";
assert.strictEqual(typeof api.bank.getAll, "function");
assert.strictEqual(typeof api.bank.getBy, "function");
assert.strictEqual(typeof api.cep.getBy, "function");
assert.strictEqual(typeof api.cepV1.getBy, "function");
assert.strictEqual(typeof api.cnpj.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getBy, "function");
assert.strictEqual(typeof api.cptec.city.getAll, "function");
Expand Down

0 comments on commit 223b19c

Please sign in to comment.