import axios from "axios"; import config from "./config/config"; import logging from "./config/logging"; import { NAME_SPACE } from "./server"; export const getMember = async () => { const url = config.base_url + "tools/member/Membergateway/getmemberv2"; 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 uploadV2 = async (prm: any) => { const url = config.base_url + "tools/member/Membergateway/uploadV2"; logging.info(NAME_SPACE, "\t INFO : " + url); // logging.info(NAME_SPACE, "PRM : ", prm); try { const resp = await axios.post( url, { debug: "N", data: 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); } } }; export const upload = async () => { const url = config.base_url + "tools/member/Membergateway/upload"; 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 download = async () => { const url = config.base_url + "tools/member/Membergateway/download"; 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 downloadV2 = async () => { const url = config.base_url + "tools/member/Membergateway/downloadV2"; 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 generate = async (prm: any) => { const url = config.base_url + "tools/member/Membergateway/generateV2"; logging.info(NAME_SPACE, "\t INFO : " + url); try { const resp = await axios.post( url, { data: 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); } } }; export const getDataNatInfo = async () => { const url = config.base_url + "tools/member/downloadinfo/downloadInfo"; 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 insertNatInfo = async ( nik: string, visit: string, point: string ) => { const url = config.base_url + "tools/member/downloadinfo/insertInfo/" + nik + "/" + visit + "/" + point; 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); } } };