/* *--------------------------------------------------- * Licensed Materials - Property of HCL Technologies * * HCL Commerce * * (C) Copyright HCL Technologies Limited 2021 * *--------------------------------------------------- * * *THIS IS A SAMPLE FILE. NOT A PRODUCTION READY SERVICE FILE. * */ import axios, { AxiosPromise } from "axios"; //Foundation libraries import { getSite } from "../../hooks/useSite"; import { storageSessionHandler } from "../../utils/storageUtil"; const graphQLService = { getCart(parameters: any): AxiosPromise { const siteInfo = getSite(); const { storeId = siteInfo?.storeID } = parameters; const header = axios.defaults.headers; const currentUser = storageSessionHandler.getCurrentUserAndLoadAccount(); if (currentUser) { if (!header["WCTrustedToken"]) { header["WCTrustedToken"] = currentUser.WCTrustedToken; } if (!header["WCToken"]) { header["WCToken"] = currentUser.WCToken; } if (!header["WCPersonalization"]) { header["WCPersonalization"] = currentUser.personalizationID; } } return axios({ url: "/graphQL", method: "POST", data: { query: ` { cartGetCart(storeId: "${storeId}") { totalShippingCharge, resourceId, grandTotalCurrency, totalShippingChargeCurrency, storeUniqueID, resourceName, recordSetTotal, shipAsComplete, totalAdjustment, totalShippingTaxCurrency, orderItem { orderItemId, productId, quantity } usableshippinginfo { usableShippingMode { carrier shipModeId } usableShippingAddress { addressId nickName } } usablePaymentInfo { usablePaymentInformation { paymentMethodName paymentTermConditionId } } } } `, }, }); }, }; export default graphQLService;