import { MyPageApiID } from "."; type MyPageApiResponse = { result: "SUCCESS" | "FAILED"; }; export const getUrl = (apiId: MyPageApiID) => { return [process.env.MYPAGE_BASE_URL ?? "", "api-from-kintone", apiId].join( "/" ); }; export const send = async (apiId: MyPageApiID, data: object) => { const url = getUrl(apiId); const sendData = { ...data, token: process.env.MYPAGE_TOKEN ?? "", }; console.info("MyPageAPICall", url, data); const res: any = await kintone.proxy( url, "POST", { "Content-Type": "application/json" }, sendData ); const status = res[1]; if (status !== 200) { console.error("http status not 200", res); return false; } const obj = JSON.parse(res[0]); if (obj.result === "SUCCESS") { return true; } else { console.error("処理失敗", res); return false; } };