Skip to content

Commit 3d40320

Browse files
feat: using a fetch wrapper was a bad idea
1 parent ac4c9f8 commit 3d40320

File tree

38 files changed

+2424
-2358
lines changed

38 files changed

+2424
-2358
lines changed

packages/cli/src/core/sdks/brasil-api/banks.ts

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,59 @@ import { BrasilApi } from "@brasil-interface/sdks";
44
import { program } from "commander";
55

66
const brasilApiBanks = program
7-
.command("brasil-api/banks")
8-
.description("Brasil API Banks SDK");
7+
.command("brasil-api/banks")
8+
.description("Brasil API Banks SDK");
99

1010
brasilApiBanks
11-
.command("get-all")
12-
.description("Get information about all banks in Brazil.")
13-
.option("-o, --output <filepath>", "Output file path")
14-
.option("-c, --copy", "Copy the result to the clipboard.")
15-
.option("-d, --debug", "Show debug information.")
16-
.action(async (options) => {
17-
const { output, copy, debug } = options;
18-
const logger = new Logger(debug);
19-
const banks = new BrasilApi.Banks();
11+
.command("get-all")
12+
.description("Get information about all banks in Brazil.")
13+
.option("-o, --output <filepath>", "Output file path")
14+
.option("-c, --copy", "Copy the result to the clipboard.")
15+
.option("-d, --debug", "Show debug information.")
16+
.action(async (options) => {
17+
const { output, copy, debug } = options;
18+
const logger = new Logger(debug);
19+
const banks = new BrasilApi.Banks();
2020

21-
try {
22-
const result = await banks.getAllBanks();
21+
try {
22+
const result = await banks.getAllBanks();
2323

24-
OutputHelper.handleResultOutputBasedOnOptions(result, {
25-
output,
26-
copyToClipboard: copy,
27-
});
28-
} catch (error) {
29-
logger.info(`PT-BR: Não foi possível obter informações sobre os bancos.`);
30-
logger.info(`EN: Couldn't get information about the banks.`);
31-
logger.error(error);
32-
}
33-
});
24+
OutputHelper.handleResultOutputBasedOnOptions(result, {
25+
isJson: true,
26+
output,
27+
copyToClipboard: copy,
28+
});
29+
} catch (error) {
30+
logger.info(`PT-BR: Não foi possível obter informações sobre os bancos.`);
31+
logger.info(`EN: Couldn't get information about the banks.`);
32+
logger.error(error);
33+
}
34+
});
3435

3536
brasilApiBanks
36-
.command("get-by-code <code>")
37-
.description("Get information about a bank by code.")
38-
.option("-o, --output <filepath>", "Output file path")
39-
.option("-c, --copy", "Copy the result to the clipboard.")
40-
.option("-d, --debug", "Show debug information.")
41-
.action(async (code, options) => {
42-
const { output, copy, debug } = options;
43-
const logger = new Logger(debug);
44-
const banks = new BrasilApi.Banks();
37+
.command("get-by-code <code>")
38+
.description("Get information about a bank by code.")
39+
.option("-o, --output <filepath>", "Output file path")
40+
.option("-c, --copy", "Copy the result to the clipboard.")
41+
.option("-d, --debug", "Show debug information.")
42+
.action(async (code, options) => {
43+
const { output, copy, debug } = options;
44+
const logger = new Logger(debug);
45+
const banks = new BrasilApi.Banks();
4546

46-
try {
47-
const result = await banks.getBankByCode(code);
47+
try {
48+
const result = await banks.getBankByCode(code);
4849

49-
OutputHelper.handleResultOutputBasedOnOptions(result, {
50-
output,
51-
copyToClipboard: copy,
52-
});
53-
} catch (error) {
54-
logger.info(
55-
`PT-BR: Não foi possível obter informações sobre o banco ${code}.`
56-
);
57-
logger.info(`EN: Couldn't get information about the bank ${code}.`);
58-
logger.error(error);
59-
}
60-
});
50+
OutputHelper.handleResultOutputBasedOnOptions(result, {
51+
isJson: true,
52+
output,
53+
copyToClipboard: copy,
54+
});
55+
} catch (error) {
56+
logger.info(
57+
`PT-BR: Não foi possível obter informações sobre o banco ${code}.`,
58+
);
59+
logger.info(`EN: Couldn't get information about the bank ${code}.`);
60+
logger.error(error);
61+
}
62+
});

packages/cli/src/core/sdks/brasil-api/cep-v2.ts

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,33 @@ import { BrasilApi } from "@brasil-interface/sdks";
44
import { program } from "commander";
55

66
const cepv2 = program
7-
.command("brasil-api/cep-v2")
8-
.description("Brasil API CEPv2 SDK");
7+
.command("brasil-api/cep-v2")
8+
.description("Brasil API CEPv2 SDK");
99

1010
cepv2
11-
.command("get-by-number <cep>")
12-
.description("Get information about an address by CEP number.")
13-
.option("-o, --output <filepath>", "Output file path")
14-
.option("-c, --copy", "Copy the result to the clipboard.")
15-
.option("-d, --debug", "Show debug information.")
16-
.action(async (cep, options) => {
17-
const { output, copy, debug } = options;
18-
const logger = new Logger(debug);
19-
const cepv2 = new BrasilApi.CEPv2();
11+
.command("get-by-number <cep>")
12+
.description("Get information about an address by CEP number.")
13+
.option("-o, --output <filepath>", "Output file path")
14+
.option("-c, --copy", "Copy the result to the clipboard.")
15+
.option("-d, --debug", "Show debug information.")
16+
.action(async (cep, options) => {
17+
const { output, copy, debug } = options;
18+
const logger = new Logger(debug);
19+
const cepv2 = new BrasilApi.CEPv2();
2020

21-
try {
22-
const result = await cepv2.getCepByNumber(Number(cep));
21+
try {
22+
const result = await cepv2.getCepByNumber(Number(cep));
2323

24-
OutputHelper.handleResultOutputBasedOnOptions(result, {
25-
output,
26-
copyToClipboard: copy,
27-
});
28-
} catch (error) {
29-
logger.info(
30-
`PT-BR: Não foi possível obter informações sobre o CEP ${cep}.`
31-
);
32-
logger.info(`EN: Couldn't get information about the CEP ${cep}.`);
33-
logger.error(error);
34-
}
35-
});
24+
OutputHelper.handleResultOutputBasedOnOptions(result, {
25+
isJson: true,
26+
output,
27+
copyToClipboard: copy,
28+
});
29+
} catch (error) {
30+
logger.info(
31+
`PT-BR: Não foi possível obter informações sobre o CEP ${cep}.`,
32+
);
33+
logger.info(`EN: Couldn't get information about the CEP ${cep}.`);
34+
logger.error(error);
35+
}
36+
});

packages/cli/src/core/sdks/brasil-api/cep.ts

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,33 @@ import { BrasilApi } from "@brasil-interface/sdks";
44
import { program } from "commander";
55

66
const brasilApiCep = program
7-
.command("brasil-api/cep")
8-
.description("Brasil API CEP SDK");
7+
.command("brasil-api/cep")
8+
.description("Brasil API CEP SDK");
99

1010
brasilApiCep
11-
.command("get-by-number <cep>")
12-
.description("Get information about an address by CEP number.")
13-
.option("-o, --output <filepath>", "Output file path")
14-
.option("-c, --copy", "Copy the result to the clipboard.")
15-
.option("-d, --debug", "Show debug information.")
16-
.action(async (cep, options) => {
17-
const { output, copy, debug } = options;
18-
const logger = new Logger(debug);
19-
const CEP = new BrasilApi.CEP();
11+
.command("get-by-number <cep>")
12+
.description("Get information about an address by CEP number.")
13+
.option("-o, --output <filepath>", "Output file path")
14+
.option("-c, --copy", "Copy the result to the clipboard.")
15+
.option("-d, --debug", "Show debug information.")
16+
.action(async (cep, options) => {
17+
const { output, copy, debug } = options;
18+
const logger = new Logger(debug);
19+
const CEP = new BrasilApi.CEP();
2020

21-
try {
22-
const result = await CEP.getCepByNumber(cep).catch((error) => {
23-
console.error(error);
24-
});
21+
try {
22+
const result = await CEP.getCepByNumber(cep);
2523

26-
OutputHelper.handleResultOutputBasedOnOptions(result, {
27-
output,
28-
copyToClipboard: copy,
29-
});
30-
} catch (error) {
31-
logger.info(
32-
`PT-BR: Não foi possível obter informações sobre o CEP ${cep}.`
33-
);
34-
logger.info(`EN: Couldn't get information about the CEP ${cep}.`);
35-
logger.error(error);
36-
}
37-
});
24+
OutputHelper.handleResultOutputBasedOnOptions(result, {
25+
isJson: true,
26+
output,
27+
copyToClipboard: copy,
28+
});
29+
} catch (error) {
30+
logger.info(
31+
`PT-BR: Não foi possível obter informações sobre o CEP ${cep}.`,
32+
);
33+
logger.info(`EN: Couldn't get information about the CEP ${cep}.`);
34+
logger.error(error);
35+
}
36+
});

packages/cli/src/core/sdks/brasil-api/cnpj.ts

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,33 @@ import { BrasilApi } from "@brasil-interface/sdks";
44
import { program } from "commander";
55

66
const brasilApiCnpj = program
7-
.command("brasil-api/cnpj")
8-
.description("Brasil API CNPJ SDK");
7+
.command("brasil-api/cnpj")
8+
.description("Brasil API CNPJ SDK");
99

1010
brasilApiCnpj
11-
.command("get-by-cnpj <cnpj>")
12-
.description("Get information about a company by CNPJ.")
13-
.option("-o, --output <filepath>", "Output file path")
14-
.option("-c, --copy", "Copy the result to the clipboard.")
15-
.option("-d, --debug", "Show debug information.")
16-
.action(async (cnpj, options) => {
17-
const { output, copy, debug } = options;
18-
const logger = new Logger(debug);
19-
const CNPJ = new BrasilApi.CNPJ();
11+
.command("get-by-cnpj <cnpj>")
12+
.description("Get information about a company by CNPJ.")
13+
.option("-o, --output <filepath>", "Output file path")
14+
.option("-c, --copy", "Copy the result to the clipboard.")
15+
.option("-d, --debug", "Show debug information.")
16+
.action(async (cnpj, options) => {
17+
const { output, copy, debug } = options;
18+
const logger = new Logger(debug);
19+
const CNPJ = new BrasilApi.CNPJ();
2020

21-
try {
22-
const result = await CNPJ.getCnpjInfo(cnpj);
21+
try {
22+
const result = await CNPJ.getCnpjInfo(cnpj);
2323

24-
OutputHelper.handleResultOutputBasedOnOptions(result, {
25-
output,
26-
copyToClipboard: copy,
27-
});
28-
} catch (error) {
29-
logger.info(
30-
`PT-BR: Não foi possível obter informações sobre o CNPJ ${cnpj}.`
31-
);
32-
logger.info(`EN: Couldn't get information about the CNPJ ${cnpj}.`);
33-
logger.error(error);
34-
}
35-
});
24+
OutputHelper.handleResultOutputBasedOnOptions(result, {
25+
isJson: true,
26+
output,
27+
copyToClipboard: copy,
28+
});
29+
} catch (error) {
30+
logger.info(
31+
`PT-BR: Não foi possível obter informações sobre o CNPJ ${cnpj}.`,
32+
);
33+
logger.info(`EN: Couldn't get information about the CNPJ ${cnpj}.`);
34+
logger.error(error);
35+
}
36+
});

packages/cli/src/core/sdks/brasil-api/corretoras.ts

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,63 @@ import { BrasilApi } from "@brasil-interface/sdks";
44
import { program } from "commander";
55

66
const corretoras = program
7-
.command("brasil-api/corretoras")
8-
.description("Brasil API Corretoras SDK");
7+
.command("brasil-api/corretoras")
8+
.description("Brasil API Corretoras SDK");
99

1010
corretoras
11-
.command("get-all")
12-
.description("Get information about active brokers listed in CVM.")
13-
.option("-o, --output <filepath>", "Output file path")
14-
.option("-c, --copy", "Copy the result to the clipboard.")
15-
.option("-d, --debug", "Show debug information.")
16-
.action(async (options) => {
17-
const { output, copy, debug } = options;
18-
const logger = new Logger(debug);
19-
const corretoras = new BrasilApi.Corretoras();
11+
.command("get-all")
12+
.description("Get information about active brokers listed in CVM.")
13+
.option("-o, --output <filepath>", "Output file path")
14+
.option("-c, --copy", "Copy the result to the clipboard.")
15+
.option("-d, --debug", "Show debug information.")
16+
.action(async (options) => {
17+
const { output, copy, debug } = options;
18+
const logger = new Logger(debug);
19+
const corretoras = new BrasilApi.Corretoras();
2020

21-
try {
22-
const result = await corretoras.getCorretoras();
21+
try {
22+
const result = await corretoras.getCorretoras();
2323

24-
OutputHelper.handleResultOutputBasedOnOptions(result, {
25-
output,
26-
copyToClipboard: copy,
27-
});
28-
} catch (error) {
29-
logger.info(
30-
`PT-BR: Não foi possível obter informações sobre as corretoras.`
31-
);
32-
logger.info(`EN: Couldn't get information about the brokers.`);
33-
logger.error(error);
34-
}
35-
});
24+
OutputHelper.handleResultOutputBasedOnOptions(result, {
25+
isJson: true,
26+
output,
27+
copyToClipboard: copy,
28+
});
29+
} catch (error) {
30+
logger.info(
31+
`PT-BR: Não foi possível obter informações sobre as corretoras.`,
32+
);
33+
logger.info(`EN: Couldn't get information about the brokers.`);
34+
logger.error(error);
35+
}
36+
});
3637

3738
corretoras
38-
.command("get-by-cnpj <cnpj>")
39-
.description("Get information about an active broker listed in CVM by CNPJ.")
40-
.option("-o, --output <filepath>", "Output file path")
41-
.option("-c, --copy", "Copy the result to the clipboard.")
42-
.option("-d, --debug", "Show debug information.")
43-
.action(async (cnpj, options) => {
44-
const { output, copy, debug } = options;
45-
const logger = new Logger(debug);
46-
const corretoras = new BrasilApi.Corretoras();
39+
.command("get-by-cnpj <cnpj>")
40+
.description("Get information about an active broker listed in CVM by CNPJ.")
41+
.option("-o, --output <filepath>", "Output file path")
42+
.option("-c, --copy", "Copy the result to the clipboard.")
43+
.option("-d, --debug", "Show debug information.")
44+
.action(async (cnpj, options) => {
45+
const { output, copy, debug } = options;
46+
const logger = new Logger(debug);
47+
const corretoras = new BrasilApi.Corretoras();
4748

48-
try {
49-
const result = await corretoras.getCorretoraByCnpj(cnpj);
49+
try {
50+
const result = await corretoras.getCorretoraByCnpj(cnpj);
5051

51-
OutputHelper.handleResultOutputBasedOnOptions(result, {
52-
output,
53-
copyToClipboard: copy,
54-
});
55-
} catch (error) {
56-
logger.info(
57-
`PT-BR: Não foi possível obter informações sobre a corretora com CNPJ ${cnpj}.`
58-
);
59-
logger.info(
60-
`EN: Couldn't get information about the broker with CNPJ ${cnpj}.`
61-
);
62-
logger.error(error);
63-
}
64-
});
52+
OutputHelper.handleResultOutputBasedOnOptions(result, {
53+
isJson: true,
54+
output,
55+
copyToClipboard: copy,
56+
});
57+
} catch (error) {
58+
logger.info(
59+
`PT-BR: Não foi possível obter informações sobre a corretora com CNPJ ${cnpj}.`,
60+
);
61+
logger.info(
62+
`EN: Couldn't get information about the broker with CNPJ ${cnpj}.`,
63+
);
64+
logger.error(error);
65+
}
66+
});

0 commit comments

Comments
 (0)