feat: Investment Funds API (#528) · BrasilAPI/BrasilAPI@bec2eae · GitHub
Skip to content

Commit bec2eae

Browse files
feat: Investment Funds API (#528)
* feat: cvm funds api * test: add funds api e2e tests * docs: add funds api docs * fix: camel case to snake case and adds required fields * fix: add error for page > 200 * fix: fund pagination error message * fix: pipeline rerun * Revert "fix: pipeline rerun" This reverts commit 0d1029e. * fix: pipeline rerun --------- Co-authored-by: Lorhan Sohaky <16273730+LorhanSohaky@users.noreply.github.com>
1 parent 64f5897 commit bec2eae

5 files changed

Lines changed: 640 additions & 0 deletions

File tree

‎pages/api/cvm/fundos/v1/[cnpj].js‎

Lines changed: 26 additions & 0 deletions

‎pages/api/cvm/fundos/v1/index.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import app from '@/app';
2+
3+
import BaseError from '@/errors/BaseError';
4+
5+
import InternalError from '@/errors/InternalError';
6+
import { getFunds } from '@/services/cvm/fundos';
7+
8+
const action = async (request, response) => {
9+
try {
10+
const { page, size } = request.query;
11+
const fundData = await getFunds(size, page);
12+
response.status(200).json(fundData);
13+
} catch (err) {
14+
if (err instanceof BaseError) {
15+
throw err;
16+
}
17+
18+
throw new InternalError({
19+
message: 'Erro ao buscar informações sobre fundos',
20+
type: 'exchange_error',
21+
name: 'EXCHANGE_INTERNAL',
22+
});
23+
}
24+
};
25+
26+
export default app({ cache: 86400 }).get(action);

‎pages/docs/doc/fundos.json‎

Lines changed: 344 additions & 0 deletions

0 commit comments

Comments
 (0)