Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ShopperContexts<ConfigParameters>

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.29
Last Updated:

Type parameters

Hierarchy

  • ShopperContexts

Index

Constructors

constructor

Properties

clientConfig

clientConfig: ClientConfig<ConfigParameters> & { baseUri: string }

Static Readonly defaultBaseUri

defaultBaseUri: "https://{shortCode}.api.commercecloud.salesforce.com/shopper/shopper-context/{version}" = "https://{shortCode}.api.commercecloud.salesforce.com/shopper/shopper-context/{version}"

Static Readonly paramKeys

paramKeys: { createShopperContext: ["organizationId", "usid", "siteId", "evaluateContextWithClientIp"]; createShopperContextRequired: ["organizationId", "usid"]; deleteShopperContext: ["organizationId", "usid", "siteId"]; deleteShopperContextRequired: ["organizationId", "usid"]; getShopperContext: ["organizationId", "usid", "siteId"]; getShopperContextRequired: ["organizationId", "usid"]; updateShopperContext: ["organizationId", "usid", "siteId", "evaluateContextWithClientIp"]; updateShopperContextRequired: ["organizationId", "usid"] } = {getShopperContext: ['organizationId','usid','siteId',],getShopperContextRequired: ['organizationId','usid',],createShopperContext: ['organizationId','usid','siteId','evaluateContextWithClientIp',],createShopperContextRequired: ['organizationId','usid',],deleteShopperContext: ['organizationId','usid','siteId',],deleteShopperContextRequired: ['organizationId','usid',],updateShopperContext: ['organizationId','usid','siteId','evaluateContextWithClientIp',],updateShopperContextRequired: ['organizationId','usid',],} as const

Type declaration

  • createShopperContext: ["organizationId", "usid", "siteId", "evaluateContextWithClientIp"]
  • createShopperContextRequired: ["organizationId", "usid"]
  • deleteShopperContext: ["organizationId", "usid", "siteId"]
  • deleteShopperContextRequired: ["organizationId", "usid"]
  • getShopperContext: ["organizationId", "usid", "siteId"]
  • getShopperContextRequired: ["organizationId", "usid"]
  • updateShopperContext: ["organizationId", "usid", "siteId", "evaluateContextWithClientIp"]
  • updateShopperContextRequired: ["organizationId", "usid"]

Methods

createShopperContext

  • Creates the shopper's context based on shopperJWT.

    With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.

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

    Parameters

    Returns Promise<void | void>

    A promise of type void | void.

  • Creates the shopper's context based on shopperJWT.

    With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.

    Type parameters

    • T: boolean

    Parameters

    • options: RequireParametersUnlessAllAreOptional<{ body: ShopperContext; headers?: undefined | {}; parameters?: CompositeParameters<{ evaluateContextWithClientIp?: undefined | false | true; organizationId: string; siteId?: undefined | string; usid: string } & {}, ConfigParameters> }>

      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 | void>

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

deleteShopperContext

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

    With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.

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

    Parameters

    Returns Promise<void>

    A promise of type void.

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

    With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.

    Type parameters

    • T: boolean

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{ headers?: undefined | {}; parameters?: CompositeParameters<{ organizationId: string; siteId?: undefined | string; usid: string } & {}, ConfigParameters> }>

      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.

getShopperContext

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

    With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.

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

    Parameters

    Returns Promise<ShopperContext>

    A promise of type ShopperContext.

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

    With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.

    Type parameters

    • T: boolean

    Parameters

    • Optional options: RequireParametersUnlessAllAreOptional<{ headers?: undefined | {}; parameters?: CompositeParameters<{ organizationId: string; siteId?: undefined | string; usid: string } & {}, ConfigParameters> }>

      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.

updateShopperContext

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

    With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.

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

    Parameters

    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 custom qualifier/assignment qualifer or an effectiveDateTime or a sourceCode or a customerGroupIds is already present in the existing shopper context, its value is replaced by the corresponding value from the patch body. If a custom qualifers' or a assignment qualifiers' value is set to null, it's deleted from existing shopper context. If effectiveDateTime or sourceCode value is set to an empty string (""), it's deleted from existing shopper context. If effectiveDateTime or sourceCode value is set to null, it's ignored. If an effectiveDateTime or sourceCode or custom/assignment qualifiiers' value is new, it's added to the existing Shopper context. If customerGroupIds is set to empty array [] the existing value in shopper context is deleted.

    With B2C Commerce release 24.5, all endpoints in the Shopper context API will require the siteId parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025.

    Type parameters

    • T: boolean

    Parameters

    • options: RequireParametersUnlessAllAreOptional<{ body: ShopperContext; headers?: undefined | {}; parameters?: CompositeParameters<{ evaluateContextWithClientIp?: undefined | false | true; organizationId: string; siteId?: undefined | string; usid: string } & {}, ConfigParameters> }>

      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.

Generated using TypeDoc