UNPKG

@selldone/sdk-storefront

Version:

A TypeScript SDK to connect to your shop and build a fully functional storefront and website by simply developing a frontend web application. All backend operations are seamlessly managed by the serverless Selldone solution.

50 lines 2.38 kB
/* * Copyright (c) 2023. Selldone® Business OS™ * * Author: M.Pajuhaan * Web: https://selldone.com * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ * * All rights reserved. In the weave of time, where traditions and innovations intermingle, this content was crafted. * From the essence of thought, through the corridors of creativity, each word, and sentiment has been molded. * Not just to exist, but to inspire. Like an artist's stroke or a sculptor's chisel, every nuance is deliberate. * Our journey is not just about reaching a destination, but about creating a masterpiece. * Tread carefully, for you're treading on dreams. */ import { StorefrontLocalStorages } from "@selldone/core-js/helper/local-storage/StorefrontLocalStorages"; import { APIAbstract, } from "@selldone/core-js/server/APIAbstract"; import setUserCurrency from "./requests/xapi.user.currency.put"; import setFcmToken from "./requests/xapi.user.fcm.post"; export class XapiUser extends APIAbstract { /** Name of the shop for which the API operations will be performed. */ shop_name; setUserCurrency = setUserCurrency; setFcmToken = setFcmToken; constructor(shop_name) { super(); this.shop_name = shop_name; } fetchMyInfo(onSuccess, onError) { this.setCurrentUser(null); const params = { codes: StorefrontLocalStorages.GetShopHistoryGuestAllCodes(), guest_code: StorefrontLocalStorages.GetShopGuestCode(), }; const url = window.XAPI.GET_USER(); this.getDebounce(url, params, (data) => { // Set current user information this.setCurrentUser(data); onSuccess(data); }, onError, { max_valid_status_code: 500 /*We assume any error response except 5xx (server error) as success response to be able auto logout user!*/, }); } /** * Important set current user information! * @param user */ setCurrentUser(user) { window.$storefront.USER = user; } } //█████████████████████████████████████████████████████████████ //# sourceMappingURL=XapiUser.js.map