Class ShopperContexts<ConfigParameters>

Shopper Context

The Shopper Context API enables developers to build highly contextualized shopping experiences for shoppers.

Simple example:

  import { ShopperContexts } from "commerce-sdk-isomorphic";

const clientConfig = {
parameters: {
clientId: "XXXXXX",
organizationId: "XXXX",
shortCode: "XXX",
siteId: "XX"
}
};
const shopperContextsClient = new ShopperContexts(clientConfig);
API Version: 0.0.19
Last Updated:

Type Parameters

Hierarchy

  • ShopperContexts

Constructors

Methods

  • Creates the shopper's context based on shopperJWT.

    If you would like to get a raw Response object use the other createShopperContext function.

    Parameters

    • options: RequireParametersUnlessAllAreOptional<{
          body: ShopperContext;
          headers?: {
              [key: string]: string;
          };
          parameters?: {
              [K in "organizationId" | "siteId" | "usid"]: (Omit<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }, keyof ConfigParameters> & Partial<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }>)[K]
          };
      }>

      An object containing the options for this method.

    Returns Promise<void>

    A promise of type void | void.

  • Creates the shopper's context based on shopperJWT.

    Type Parameters

    • T extends boolean

    Parameters

    • options: RequireParametersUnlessAllAreOptional<{
          body: ShopperContext;
          headers?: {
              [key: string]: string;
          };
          parameters?: {
              [K in "organizationId" | "siteId" | "usid"]: (Omit<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }, keyof ConfigParameters> & Partial<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }>)[K]
          };
      }>

      An object containing the options for this method.

    • Optional rawResponse: T

      Set to true to return entire Response object instead of DTO.

    Returns Promise<T extends true
        ? Response
        : void>

    A promise of type Response if rawResponse is true, a promise of type void | void otherwise.

  • Gets the shopper's context based on the shopperJWT.

    If you would like to get a raw Response object use the other deleteShopperContext function.

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{
          headers?: {
              [key: string]: string;
          };
          parameters?: {
              [K in "organizationId" | "siteId" | "usid"]: (Omit<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }, keyof ConfigParameters> & Partial<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }>)[K]
          };
      }>

      An object containing the options for this method.

    Returns Promise<void>

    A promise of type void.

  • Gets the shopper's context based on the shopperJWT.

    Type Parameters

    • T extends boolean

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{
          headers?: {
              [key: string]: string;
          };
          parameters?: {
              [K in "organizationId" | "siteId" | "usid"]: (Omit<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }, keyof ConfigParameters> & Partial<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }>)[K]
          };
      }>

      An object containing the options for this method.

    • Optional rawResponse: T

      Set to true to return entire Response object instead of DTO.

    Returns Promise<T extends true
        ? Response
        : void>

    A promise of type Response if rawResponse is true, a promise of type void otherwise.

  • Gets the shopper's context based on the shopperJWT.

    If you would like to get a raw Response object use the other getShopperContext function.

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{
          headers?: {
              [key: string]: string;
          };
          parameters?: {
              [K in "organizationId" | "siteId" | "usid"]: (Omit<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }, keyof ConfigParameters> & Partial<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }>)[K]
          };
      }>

      An object containing the options for this method.

    Returns Promise<ShopperContext>

    A promise of type ShopperContext.

  • Gets the shopper's context based on the shopperJWT.

    Type Parameters

    • T extends boolean

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{
          headers?: {
              [key: string]: string;
          };
          parameters?: {
              [K in "organizationId" | "siteId" | "usid"]: (Omit<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }, keyof ConfigParameters> & Partial<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }>)[K]
          };
      }>

      An object containing the options for this method.

    • Optional rawResponse: T

      Set to true to return entire Response object instead of DTO.

    Returns Promise<T extends true
        ? Response
        : ShopperContext>

    A promise of type Response if rawResponse is true, a promise of type ShopperContext otherwise.

  • Updates the shopper's context based on the Shopper JWT. If the shopper context exists, it's updated with the patch body. If a customer qualifier or an effectiveDateTime is already present in the existing shopper context, its value is replaced by the corresponding value from the patch body. If a customer qualifers' value is set to null it's deleted from existing shopper context. If effectiveDateTime value is set to set to an empty string (""), it's deleted from existing shopper context. If effectiveDateTime value is set to null it's ignored. If an effectiveDateTime or customer qualifiiers' value is new, it's added to the existing Shopper context.

    If you would like to get a raw Response object use the other updateShopperContext function.

    Parameters

    • options: RequireParametersUnlessAllAreOptional<{
          body: ShopperContext;
          headers?: {
              [key: string]: string;
          };
          parameters?: {
              [K in "organizationId" | "siteId" | "usid"]: (Omit<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }, keyof ConfigParameters> & Partial<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }>)[K]
          };
      }>

      An object containing the options for this method.

    Returns Promise<ShopperContext>

    A promise of type ShopperContext.

  • Updates the shopper's context based on the Shopper JWT. If the shopper context exists, it's updated with the patch body. If a customer qualifier or an effectiveDateTime is already present in the existing shopper context, its value is replaced by the corresponding value from the patch body. If a customer qualifers' value is set to null it's deleted from existing shopper context. If effectiveDateTime value is set to set to an empty string (""), it's deleted from existing shopper context. If effectiveDateTime value is set to null it's ignored. If an effectiveDateTime or customer qualifiiers' value is new, it's added to the existing Shopper context.

    Type Parameters

    • T extends boolean

    Parameters

    • options: RequireParametersUnlessAllAreOptional<{
          body: ShopperContext;
          headers?: {
              [key: string]: string;
          };
          parameters?: {
              [K in "organizationId" | "siteId" | "usid"]: (Omit<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }, keyof ConfigParameters> & Partial<{
                  organizationId: string;
                  siteId?: string;
                  usid: string;
              }>)[K]
          };
      }>

      An object containing the options for this method.

    • Optional rawResponse: T

      Set to true to return entire Response object instead of DTO.

    Returns Promise<T extends true
        ? Response
        : ShopperContext>

    A promise of type Response if rawResponse is true, a promise of type ShopperContext otherwise.

Properties

clientConfig: ClientConfig<ConfigParameters> & {
    baseUri: string;
}
defaultBaseUri: "https://{shortCode}.api.commercecloud.salesforce.com/shopper/shopper-context/{version}" = "https://{shortCode}.api.commercecloud.salesforce.com/shopper/shopper-context/{version}"