85 lines
2.3 KiB
TypeScript
85 lines
2.3 KiB
TypeScript
import axios from "axios";
|
|
import config from "./config/config";
|
|
import logging from "./config/logging";
|
|
import { NAME_SPACE } from "./server";
|
|
|
|
export const upload = async () => {
|
|
const url = config.base_url + "tools/member/Membergateway/upload";
|
|
logging.info(NAME_SPACE, "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, "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 getDataNatInfo = async () => {
|
|
const url = config.base_url + "tools/member/downloadinfo/downloadInfo";
|
|
logging.info(NAME_SPACE, "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, "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);
|
|
}
|
|
}
|
|
};
|