diff --git a/README.md b/README.md index 069b38f..0aebdf4 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package-lock.json b/package-lock.json index 0d09251..c20d5ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "brasilapi-js", - "version": "0.0.1", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "brasilapi-js", - "version": "0.0.1", + "version": "1.0.0", "license": "MIT", "dependencies": { "axios": "^1.5.1" diff --git a/package.json b/package.json index a9dc539..8061f83 100644 --- a/package.json +++ b/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", diff --git a/src/index.ts b/src/index.ts index f8418f7..208485d 100644 --- a/src/index.ts +++ b/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"; @@ -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, diff --git a/src/routes/cepV1.ts b/src/routes/cepV1.ts new file mode 100644 index 0000000..e5bb9d1 --- /dev/null +++ b/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(endpointV1 + onlyNumbers(cep)); +}; diff --git a/test/module/cjs/index.js b/test/module/cjs/index.js index 8edb729..aed7415 100644 --- a/test/module/cjs/index.js +++ b/test/module/cjs/index.js @@ -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"); diff --git a/test/module/esm/index.js b/test/module/esm/index.js index c574fc7..5879775 100644 --- a/test/module/esm/index.js +++ b/test/module/esm/index.js @@ -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"); diff --git a/test/module/ts-require/index.js b/test/module/ts-require/index.js index aebbf11..6397623 100644 --- a/test/module/ts-require/index.js +++ b/test/module/ts-require/index.js @@ -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"); diff --git a/test/module/ts-require/index.ts b/test/module/ts-require/index.ts index 8edb729..aed7415 100644 --- a/test/module/ts-require/index.ts +++ b/test/module/ts-require/index.ts @@ -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"); diff --git a/test/module/ts/index.js b/test/module/ts/index.js index 13c5607..49e8ded 100644 --- a/test/module/ts/index.js +++ b/test/module/ts/index.js @@ -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"); diff --git a/test/module/ts/index.ts b/test/module/ts/index.ts index c574fc7..5879775 100644 --- a/test/module/ts/index.ts +++ b/test/module/ts/index.ts @@ -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");