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.30
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. If a shopper context already exists, it replaces the entire existing context.

    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. If a shopper context already exists, it replaces the entire existing context.

    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 an existing shopper's context based on the Shopper JWT. If the shopper context exists, it's updated with the patch body.

    • If a new attribute that does not exist in the existing shopper context is present, it is added to the context.
    • If an attribute is already present in the existing shopper context, its value is replaced by the corresponding value from the new shopper context in the request body as follows:
    • custom qualifiers or assignment qualifiers:

    If the individual qualifier key exists, it is overwritten with the new value.

    If the value of the key is set to null, it is deleted from the existing shopper context.

    If an empty custom qualifiers or assignment qualifiers object \{\} is passed, the entire qualifier object is deleted.

    • effectiveDateTime or sourceCode or clientIp:

    If the new value is set to an empty string (""), it is deleted from the existing shopper context.

    If the new value is set to null, it is ignored.

    If the new value is not empty or null, it overwrites the existing value.

    • customerGroupIds:

    If a list of customerGroupIds exists, it is replaced by the new list of customer group IDs from the request.

    If customerGroupIds is set to an empty array [], the existing list in the shopper context is deleted.

    • geoLocation:

    If it exists, the entire geoLocation object is replaced with the new value.

    If the new value is set to null, it is ignored.

    If an empty geoLocation object \{\} is passed, it 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 an existing shopper's context based on the Shopper JWT. If the shopper context exists, it's updated with the patch body.

    • If a new attribute that does not exist in the existing shopper context is present, it is added to the context.
    • If an attribute is already present in the existing shopper context, its value is replaced by the corresponding value from the new shopper context in the request body as follows:
    • custom qualifiers or assignment qualifiers:

    If the individual qualifier key exists, it is overwritten with the new value.

    If the value of the key is set to null, it is deleted from the existing shopper context.

    If an empty custom qualifiers or assignment qualifiers object \{\} is passed, the entire qualifier object is deleted.

    • effectiveDateTime or sourceCode or clientIp:

    If the new value is set to an empty string (""), it is deleted from the existing shopper context.

    If the new value is set to null, it is ignored.

    If the new value is not empty or null, it overwrites the existing value.

    • customerGroupIds:

    If a list of customerGroupIds exists, it is replaced by the new list of customer group IDs from the request.

    If customerGroupIds is set to an empty array [], the existing list in the shopper context is deleted.

    • geoLocation:

    If it exists, the entire geoLocation object is replaced with the new value.

    If the new value is set to null, it is ignored.

    If an empty geoLocation object \{\} is passed, it 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.

Object literals

Static Readonly apiPaths

apiPaths: object

createShopperContext

createShopperContext: string = "/organizations/{organizationId}/shopper-context/{usid}"

deleteShopperContext

deleteShopperContext: string = "/organizations/{organizationId}/shopper-context/{usid}"

getShopperContext

getShopperContext: string = "/organizations/{organizationId}/shopper-context/{usid}"

updateShopperContext

updateShopperContext: string = "/organizations/{organizationId}/shopper-context/{usid}"

Generated using TypeDoc