UNPKG

@scayle/storefront-core

Version:

Collection of essential utilities to work with the Storefront API

49 lines (48 loc) 2.11 kB
import type { Wishlist } from '@scayle/storefront-api'; import type { ParamRpcHandler, RpcHandler, WishlistWithOptions } from '../../types'; /** * Retrieves the wishlist. * * @param options The options for retrieving the wishlist, including optional `with` parameter. * @param options.with Optional parameter for specifying additional data to include in the wishlist response. * @param context The RPC context. * * @returns The wishlist data or an `ErrorResponse` if an error occurs. * It will return an `ErrorResponse` if no session is found or if fetching the wishlist fails. */ export declare const getWishlist: RpcHandler<WishlistWithOptions | undefined, Wishlist>; /** * Adds an item to the wishlist. * * @param options The options for adding an item, including product/variant ID and additional data. * @param options.variantId The ID of the variant to add. * @param options.productId The ID of the product to add. * @param options.with Optional parameter for specifying additional data to include in the wishlist response. * @param context The RPC context. * * @returns The updated wishlist or a `Response` object indicating the error if adding fails. * It will return an `ErrorResponse` if no session is found, * if neither productId nor variantId are provided, or if adding to the wishlist fails. */ export declare const addItemToWishlist: ParamRpcHandler<{ variantId?: number; productId?: number; with?: WishlistWithOptions; }, Wishlist | Response>; /** * Removes an item from the wishlist. * * @param options Options for removing the item. * @param options.itemKey The key of the item to remove. * @param options.with Optional parameter for specifying additional data to include in the wishlist response. * * @param context The RPC context. * * @returns The updated wishlist data. It will return an `ErrorResponse` * if no session is found or if removing the item fails. */ export declare const removeItemFromWishlist: RpcHandler<{ itemKey: string; with?: WishlistWithOptions; }, Wishlist>; export declare const clearWishlist: RpcHandler<Wishlist>;