Skip to content

Commit

Permalink
Update cep.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
larnerdoj committed Mar 12, 2024
1 parent f1b1db4 commit fac4f99
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/routes/cep.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getByV1 = void 0;
exports.getByV2 = void 0;
const api_service_1 = require("../service/api.service");
const format_1 = require("../utils/format");
import { get } from "../service/api.service";
import { CepV1, CepV2 } from "../types/cep";
import { onlyNumbers } from "../utils/format";

const endpointV1 = "/cep/v1/";
const endpointV2 = "/cep/v2/";
const getByV1 = (cep) => {
return (0, api_service_1.get)(endpointV1 + (0, format_1.onlyNumbers)(cep));

export const getBy = (cep: string, version: string = 'v2') => {
(version === "v2") ? get<CepV2>(endpointV2 + onlyNumbers(cep)) : get<CepV1>(endpointV1 + onlyNumbers(cep));
};
const getByV2 = (cep) => {
return (0, api_service_1.get)(endpointV2 + (0, format_1.onlyNumbers)(cep));
};
exports.getByV1 = getByV1;
exports.getByV2 = getByV2;

0 comments on commit fac4f99

Please sign in to comment.