import axios from "axios"; import { BASE_URL } from "../core/env"; import { consoleLogger } from "../core/logger"; import { hashAPIPath } from "../core/hash"; export const getPersonalAccount = (contactid) => { return axios .get( BASE_URL + "/api/endpoint/getpersonalaccount_api?contactid=" + contactid ) .then((res) => { return res.data; }) .catch((error) => { consoleLogger(error); }); }; export const getLogin = (emailAddress, pwd) => { return axios .get( "/api/endpoint/getlogin_api?emailAddress=" + emailAddress + "&pwd=" + pwd ) .then((res) => res.data) .catch((error) => { consoleLogger(error); }); }; export const updatePassword = (contactId, newpassword) => { var queryUrl = "/api/endpoint/updateaccount_api?contactId=" + contactId; var data = { "pinswg_custom_password": newpassword }; var config = { method: "post", url: queryUrl, data: data }; return axios(config) .then((res) => { return res.data; }) .catch((error) => { consoleLogger(error); }); }; export const updateAccount = async (contactId, updateBody, ssr) => { var queryUrl = (ssr ? BASE_URL : "") + "/api/endpoint/updateaccount_api?contactId=" + contactId; var data = updateBody; var config = { method: "post", url: queryUrl, data: data }; return axios(config) .then((res) => { return res.data; }) .catch((error) => { consoleLogger(error); }); }; export const createAccount = (formValues) => { var data = formValues; var queryUrl = "/api/endpoint/createaccount_api"; var config = { method: "post", url: queryUrl, data: data }; return axios(config) .then((res) => { return res.data; }) .catch((error) => { consoleLogger(error); }); }; export const getEmailAccountCheck = (emailAddress) => { return axios .get( "/api/endpoint/getemailaccountcheck_api?emailAddress=" + emailAddress ) .then((res) => res.data) .catch((error) => { consoleLogger(error); }); }; export const getPortalLogin = async (emailAddress) => { var queryUrl = "/api/endpoint/getportallogin_api?emailAddress=" + emailAddress; return axios .get(BASE_URL + queryUrl + hashAPIPath(queryUrl)) .then((res) => res.data) .catch((error) => { consoleLogger(error); return JSON.stringify(error); }); }; export const getPortalLoginProxy = async (emailAddress) => { var queryUrl = "/api/endpoint/getportalloginproxy_api?emailAddress=" + emailAddress; return axios .get(queryUrl) .then((res) => res.data) .catch((error) => { consoleLogger(error); return JSON.stringify(error); }); }; export const getPreferredLanguage = async (email) => { return axios .get( BASE_URL + "/api/endpoint/getpreferredlanguage_api?emailAddress=" + email ) .then((res) => { return res.data; }) .catch((error) => { consoleLogger(error); return error.response; }); };