first commit
This commit is contained in:
commit
c9fb67e751
423 files changed
+53287
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import axios from "axios";
|
||||
import { MovimentacaoTribunal } from "@prisma/client";
|
||||
|
||||
export class TribunalService {
|
||||
private apiKey: string;
|
||||
|
||||
constructor(apiKey: string) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
async consultarProcesso(
|
||||
numero: string,
|
||||
tribunal: string,
|
||||
): Promise<MovimentacaoTribunal[]> {
|
||||
const endpoints = {
|
||||
TJ: "https://api.tribunal.jus.br/processo",
|
||||
TRT: "https://api.trt.jus.br/processo",
|
||||
TRF: "https://api.trf.jus.br/processo",
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await axios.get(`${endpoints[tribunal]}/${numero}`, {
|
||||
headers: { Authorization: `Bearer ${this.apiKey}` },
|
||||
});
|
||||
|
||||
return this.formatarMovimentacoes(response.data);
|
||||
} catch (error) {
|
||||
console.error(`Erro ao consultar ${tribunal}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private formatarMovimentacoes(data: any): MovimentacaoTribunal[] {
|
||||
// Implementar formatação específica para cada tribunal
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user