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.

101 lines (100 loc) 3.72 kB
import { APIAbstract, Map } from "@selldone/core-js"; import { XapiExchangeRate } from "./exchange-rates/XapiExchangeRate"; import { ExchangeRate } from "@selldone/core-js"; import { Shop } from "@selldone/core-js/models/shop/shop.model"; import type { Basket } from "@selldone/core-js/models/shop/order/basket/basket.model"; import { XapiLanguage } from "./language/XapiLanguage"; import { Popup } from "@selldone/core-js/models/shop/popup/popup.model"; import type { GatewayQue } from "@selldone/core-js/models/shop/payment/gateway-que.model"; import { Club } from "@selldone/core-js/models/shop/club/club.model"; import { Transportation } from "@selldone/core-js/models/shop/transportation/transportation.model"; import { Gateway } from "@selldone/core-js/models/shop/gateway/gateway.model"; import { ShopMenu } from "@selldone/core-js/models/shop/design/menu.model"; import { ProductBadge } from "@selldone/core-js/models/shop/product/badge.model"; /** * The `XapiShop` class provides an interface to interact with the shop-related * services on the backend, particularly around retrieving shop information. * It extends the base `APIAbstract` class. * * @extends APIAbstract */ export declare class XapiShop extends APIAbstract { /** Name of the shop for which the API operations will be performed. */ shop_name: string; /** * API abstraction for exchange rate related operations. */ exchange: XapiExchangeRate; /** * API abstraction for language related operations. */ language: XapiLanguage; /** * Creates an instance of the `XapiShop`. * * @param shop_name - Name of the shop. */ constructor(shop_name: string); /** * Fetches information about a shop. * * @returns Promise that resolves with shop information. */ fetchShop(): Promise<XapiShop.IGetShopInfoResponse>; } export declare namespace XapiShop { /** * Represents the response returned when fetching shop information. */ interface IGetShopInfoResponse { success: boolean; shop: Shop & { transportations: Transportation[]; shop_exchange_rates: ExchangeRate[]; gateways: Gateway[]; menus: ShopMenu[]; product_badges: ProductBadge[]; /** * The currently active popup intended for the customer's display. * It's determined by the [S-Pops] header sent by the client (webapp). * [S-Pops] follows a JSON structure: {key(popup_id):Date, last:Current Date}. * The backend also appends this popup's ID with the current date to the `seen_pops` in the response. */ popup?: Partial<Popup>; /** * 🥶 Guest code (use for guest basket) */ guest_code?: string | null; }; baskets?: Basket[]; /** * Pending payments for the current customer. */ pending_transactions?: GatewayQue[] | null; /** * Current customer club. */ club: Club | null; /** * Represents the state of an order. */ orders_state: OrdersState[]; /** * Represents a location with longitude and latitude. */ initial_location: Map.ILocation; /** * List of viewed popups. Their stringified values should be included in the [S-Pops] header of requests. */ seen_pops?: ISeenPopup; } interface OrdersState { count: number; delivery_state: string; type: string; } interface ISeenPopup { last: string; [key: number]: string; } }