47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import axios from "axios";
|
|
import config from "./config/config";
|
|
import logging from "./config/logging";
|
|
import { NAME_SPACE } from "./server";
|
|
|
|
export const getJurnalJPAD = async (
|
|
startDate: string = "",
|
|
endDate: string = ""
|
|
) => {
|
|
const url = `${config.base_url}mockup/accounting/injectjurnaljpadokter/getJurnal/${startDate}/${endDate}`;
|
|
logging.info(NAME_SPACE, `\t INFO : ${url}`);
|
|
|
|
try {
|
|
const resp = await axios.get(url, {
|
|
responseType: "arraybuffer",
|
|
});
|
|
const jresp = JSON.parse(resp.data.toString());
|
|
return jresp;
|
|
} catch (e) {
|
|
if (axios.isAxiosError(e)) {
|
|
logging.error(NAME_SPACE, e.response?.data.toString());
|
|
} else if (e instanceof Error) {
|
|
logging.error(NAME_SPACE, e.message);
|
|
}
|
|
}
|
|
};
|
|
|
|
export const injectJurnalJPAD = async (prm: any) => {
|
|
const url = `${config.base_url}mockup/accounting/injectjurnaljpadokter/inject`;
|
|
logging.info(NAME_SPACE, `\t INFO : ${url}`);
|
|
|
|
try {
|
|
const resp = await axios.post(url, prm, {
|
|
headers: { "Content-Type": "application/json; charset=UTF-8" },
|
|
responseType: "arraybuffer",
|
|
});
|
|
const jresp = JSON.parse(resp.data.toString());
|
|
return jresp;
|
|
} catch (e) {
|
|
if (axios.isAxiosError(e)) {
|
|
logging.error(NAME_SPACE, e.response?.data.toString());
|
|
} else if (e instanceof Error) {
|
|
logging.error(NAME_SPACE, e.message);
|
|
}
|
|
}
|
|
};
|