Options
All
  • Public
  • Public/Protected
  • All
Menu

Digital Commerce Facade to interact with Vlocity Digital Commercee functionality.

The Digital Commerce SDK is a JavaScript library that abstracts and simplifies the use of Digital Commerce API REST calls.

The SDK provides error checking and validates parameters before submitting them to the Digital Commerce APIs, ensuring that calls to the APIs are well formatted and complete. In some cases, the SDK invokes more than one API to complete a request.

Using the SDK ensures that errors are detected before API calls are made, ensuring that Vlocity data structure rules are enforced and that data is not written incorrectly to the Vlocity cart or to the product database.Using the SDK reduces UI development efforts by consolidating common application and business logic to use the Digital Commerce APIs.

SDK can be shared by different applicationsuser interfaces. SDK, like any Vlocity SDK, can be extended and overrided to customized implementations.

version

104.0.0

Hierarchy

Index

Constructors

constructor

  • Default constructor. Alwyas use getInstance() instead of default contructor to get an instance of the SDK.

    Parameters

    Returns DigitalCommerce

Properties

accountId

accountId: string

This is the account Id once user login in.

Private cartContextKey

cartContextKey: string = null

cartId

cartId: string

Identifier of cart if it exists. This will be populated after addToCart() is called.

Private cartResponse

cartResponse: any

This is addToBasket response.

Private context

context: UserContext

The UserContext used for this SDK.

currentOfferCode

currentOfferCode: string

The offer code of the offer that is being configured at the moment.

Private datasource

datasource: DataSource

The datasource connection used by this SDK.

Private offersInCart

offersInCart: any[]

Anonymous Cart. This is used only for anonymous users.

Private offersInConfiguration

offersInConfiguration: any[]

Map of offers that has been selected for configuration. This map stores the state of the configured offers.

Static Private instance

instance: DigitalCommerce

Private singleton instance of this SDK. There should always be only 1 instance.

Accessors

anonymousSiteURL

  • get anonymousSiteURL(): string
  • set anonymousSiteURL(customAnonymousSiteURL: string): void
  • getter method for anonymous config url.

    Returns string

  • set custom anonymous config url

    Parameters

    • customAnonymousSiteURL: string

    Returns void

namespace

  • get namespace(): string
  • set namespace(customNamespace: string): void
  • getter method for namespace. Provides the salesforce org namespace

    Returns string

  • setter method for namespace. Set custom namespace

    Parameters

    • customNamespace: string

    Returns void

Methods

CheckoutCartInput

  • Create a default CheckoutCartInput object.

    Returns CheckoutCartInput

UpdateItemsInCartInput

  • Create a default GetItemsInCartInput object.

    Returns UpdateItemsInCartInput

Private addSelectedOffer

  • addSelectedOffer(offer: any): void
  • Cache the selected offer in memory so that user can retrieve it at later point of time for configuration and add to cart. The selected offer JSON and its offer code will be cached by SDK.

    Parameters

    • offer: any

    Returns void

addToCart

  • Save an offer to the Basket.

    example
    
    // Case a: addToCart with basketAction=AddWithNoConfig MUST have offer as input parameter
    // Instantiate the input object for addToCart to specify parameters
    const input = digitalCommerce.createAddToCartInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "Mobiles"; // use your Catalog Code
    input.basketAction = "AddWithNoConfig"; // adding an offer that has not been configured (no change in its json structure from getOfferDetails) to cart
    input.forceInvalidateCache = true;
    input.offer = "iPhone8Offer"; // use your Offer Code to be added to basket
    
    // Case b: addToCart with basketAction=AddAfterConfig MUST have productConfig as input parameter
    // Instantiate the input object for addToCart to specify parameters
    const input = digitalCommerce.createAddToCartInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "Mobiles"; // use your Catalog Code
    input.basketAction = "AddAfterConfig"; // adding an offer that has been configured (change in its json structure from getOfferDetails) to cart
    input.forceInvalidateCache = true;
    input.productConfig = {...};
    
    // Case c: addToCart with basketAction=DeleteFromBasket MUST have actionParams as input parameter
    // Instantiate the input object for addToBasket to specify parameters
    const input = digitalCommerce.createAddToCartInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "Mobiles"; // use your Catalog Code
    input.basketAction = "DeleteFromBasket"; // deleting an offer that was added to cart
    input.forceInvalidateCache = true;
    input.actionParams = {lineItemKey:'', cartContextKey:'', bundleContextKey:''}
    
    // Invoke cart API via method addToCart()
    digitalCommerce
      .addToCart(input)
     .then(response => {
        Logger.info(
          "Vlocity digital commerce addToCart with basketAction=DeleteFromBasket for anonymous user: " +
            JSON.stringify(response)
        );
      })
      .catch(error => {
        Logger.info(
          "addToCart with basketAction=DeleteFromBasket for anonymous user rest call failed" +
            error
        );
      });
    
    // Case d: addToCart with basketAction=AddChildProduct MUST have actionParams as input parameter
    // Instantiate the input object for addToBasket to specify parameters
    const input = digitalCommerce.createAddToCartInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "Mobiles"; // use your Catalog Code
    input.basketAction = "AddChildProduct"; // adding child offerto existing offer in cart.
    input.forceInvalidateCache = true;
    input.actionParams = {rootProductCode:'', parentLineKey:'', parentHierarchyPath:'', offer:'', cartContextkey:'', bundleContextKey:''}
    
    // Invoke cart API via method addToCart()
    digitalCommerce
      .addToCart(input)
     .then(response => {
        Logger.info(
          "Vlocity digital commerce addToCart with basketAction=AddChildProduct for anonymous user: " +
            JSON.stringify(response)
        );
      })
      .catch(error => {
        Logger.info(
          "addToCart with basketAction=AddChildProduct for anonymous user rest call failed" +
            error
        );
      });
    
    // Case 3: addToCart with basketAction=DeleteChildProduct MUST have actionParams as input parameter
    // Instantiate the input object for addToBasket to specify parameters
    const input = digitalCommerce.createAddToCartInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "Mobiles"; // use your Catalog Code
    input.basketAction = "DeleteChildProduct"; // adding child offerto existing offer in cart.
    input.forceInvalidateCache = true;
    input.actionParams = { lineItemKey:'', cartContextkey:'', bundleContextKey:''}
    
    // Invoke cart API via method addToCart()
    digitalCommerce
      .addToCart(input)
     .then(response => {
        Logger.info(
          "Vlocity digital commerce addToCart with basketAction=DeleteChildProduct for anonymous user: " +
            JSON.stringify(response)
        );
      })
      .catch(error => {
        Logger.info(
          "addToCart with basketAction=DeleteChildProduct for anonymous user rest call failed" +
            error
        );
      });
    
    throws

    "AddToCartInput::getAPIPath() must have catalogCode."

    throws

    "AddToCartInput::getAnonymousRestUrl() must have anonymousSiteUrl."

    throws

    "AddToCartInput::getAnonymousSiteRestUrl() must have catalogCode."

    throws"addtocartinput::getrequestpayload()

    must have basketAction."

    throws

    "AddToCartInput::getRequestPayload() must have offer when basketAction is 'AddWithNoConfig'."

    throws

    "AddToCartInput::getAPIPath() must have catalogCode."

    throws

    "AddToCartInput::getAnonymousRestUrl() must have anonymousSiteUrl."

    throws

    "AddToCartInput::getAnonymousSiteRestUrl() must have catalogCode."

    throws

    "AddToCartInput::getRequestPayload() must have basketAction."

    throws

    "AddToCartInput::getRequestPayload() must have productConfig when basketAction is 'AddAfterConfig'."=

    throws

    "AddToCartInput::getAPIPath() must have catalogCode."

    throws

    "AddToCartInput::getAnonymousRestUrl() must have anonymousSiteUrl."

    throws

    "AddToCartInput::getAnonymousSiteRestUrl() must have catalogCode."

    throws

    "AddToCartInput::getRequestPayload() must have basketAction."

    throws

    "AddToCartInput::getRequestPayload() must have deleteBundleNumber when basketAction is 'DeleteFromBasket'."

    Parameters

    Returns Promise<Cart>

checkoutCart

  • Creates an actual cart as per items user has configured in the basket.

    example
    
    // Instantiate the input object for checkoutCart() to specify parameters
    const input = digitalCommerce.CheckoutCartInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "tv"; // use your Catalog Code
    input.accountId = "001f200001eSlhe";
    // use your account id
    
    // content of basket items
    input.JSONResult = {...};
    
    // Used in Checkout process to persist shopping cart content into SF Database
    digitalCommerce
      .checkoutCart(input)
      .then(result => {
        Logger.info(
          "Checkout cart anonymous user rest call" + JSON.stringify(result)
        );
      })
      .catch(error => {
        Logger.info("Checkout cart for anonymous user rest call failed" + error);
      });
    throws

    Error - needs to be caught

    Parameters

    Returns Promise<any>

createAddToCartInput

  • Create a default AddToCartInput object.

    Returns AddToCartInput

createGetItemsInCartInput

  • Create a default GetItemsInCartInput object.

    Returns GetItemsInCartInput

createGetOfferInput

  • Create a default GetOfferInput object.

    Returns GetOfferInput

createGetOffersInput

  • Create a default createGetOffersInput object.

    Returns GetOffersInput

createValidateOfferInput

  • Create a default ValidateOfferInput object.

    Returns ValidateOfferInput

    ValidateOfferInput default ValidateOfferInput.

deleteCartItemInput

  • Create a default GetItemsInCartInput object.

    Returns DeleteCartItemInput

deleteItemsInCart

  • example
    
    // Instantiate the input object for delete item in cart to specify parameters
    const input = digitalCommerce.deleteCartItemInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "Mobiles"; // use your Catalog Code
    input.basketAction = "DeleteFromCart"; // deleting an offer that was added to cart
    input.id = "802f20000094rSaAAI"; // pass the id of offer
    
    // Invoke Get Basket API via method deleteItemsInCart()
    digitalCommerce
      .deleteItemsInCart(input)
     .then(response => {
        Logger.info(
          "Vlocity digital commerce deleteItemsInCart for anonymous user: " +
            JSON.stringify(response)
        );
      })
      .catch(error => {
        Logger.info(
          "deleteItemsInCart for anonymous user rest call failed" +
            error
        );
      });
    

    Parameters

    Returns Promise<any>

deleteSelectedOffer

  • deleteSelectedOffer(offerCode: string): Promise<any>
  • Delete a selected offer from SDK cache. If the offer exists, it will be deleted from SDK cache. Otherwise, it will do nothing.

    Parameters

    • offerCode: string

      to be deleted.

    Returns Promise<any>

Private deleteSeletedOffer

  • deleteSeletedOffer(offerCode: string): any
  • Parameters

    • offerCode: string

    Returns any

Private findSelectedOfferIndex

  • findSelectedOfferIndex(offerCode: string): number
  • Find the selected offer array index for the given offer code.

    Parameters

    • offerCode: string

      to find the selected offer.

    Returns number

    the index of the offer if existed. Otherwise, returns -1.

getAllSelectedOffers

  • getAllSelectedOffers(): Promise<any>
  • Get all the selected offer from SDK cache.

    Returns Promise<any>

    Promise with all selected offerConfigurations.

getCurrentSelectedOffer

  • getCurrentSelectedOffer(): Promise<any>
  • Get the most recent selected offer from SDK cache.

    Returns Promise<any>

    Promise with offerConfiguration.

getItemsInCart

  • Get the basket details.

    example
    
    // Instantiate the input object for getItemsInCart to specify parameters
    const input = digitalCommerce.createGetItemsInCartInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "Mobiles"; // use your Catalog Code
    input.cartContextKey = "01tf2000007Rb9JAAS"; // use your cart context key
    input.forceInvalidateCache = true;
    
    // Invoke Get Basket API via method getItemsInCart()
    digitalCommerce
      .getItemsInCart(input)
     .then(response => {
        Logger.info(
          "Vlocity digital commerce getItemsInCart for anonymous user: " +
            JSON.stringify(response)
        );
      })
      .catch(error => {
        Logger.info(
          "getItemsInCart for anonymous user rest call failed" +
            error
        );
      });
    
    throws

    "GetItemsInCartInput::getAPIPath() must have catalogCode."

    throws

    "GetItemsInCartInput::getAPIPath() must have cartContextKey."

    throws

    "GetItemsInCartInput::getAnonymousRestUrl() must have anonymousSiteUrl."

    throws

    "GetItemsInCartInput::getAnonymousSiteRestUrl() must have catalogCode."

    throws

    "GetItemsInCartInput::getAnonymousSiteRestUrl() must have cartContextKey."

    Parameters

    Returns Promise<any>

getOffer

  • Returns offer and its details.

    example
    
    // Instantiate the input object for getOfferDetails to specify parameters
    const input = digitalCommerce.createGetOfferInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "Phones"; // use your Catalog Code
    input.offerCode = "iPhoneXS"; // use your Offer Code
    input.refetch = false;
    input.useLocalCache = true;
    
    // Invoke GetOfferDetails API via method getOfferDetails()
    digitalCommerce
      .getOffer(input)
      .then(response => {
        Logger.info(
          "vlocity get offer anonymous user rest call" + response
        );
      })
      .catch(error => {
        Logger.info("get offer anonymous user rest call failed" + error);
      });
    throws

    "GetOfferInput::getAPIPath() must have catalogCode."

    throws

    "GetOfferInput::getAPIPath() must have offerCode."

    throws

    "GetOfferInput::getAnonymousRestUrl() must have anonymousSiteUrl."

    Parameters

    Returns Promise<any>

getOffers

  • Returns a list of offers.

    example
    
    // getOffers without the contains parameter
    
    // Instantiate the input object for getOffers to specify parameters
    const input = digitalCommerce.createGetOffersInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "Phones"; // use your Catalog Code
    input.offset = 0; // use for pagination
    input.pageSize = 5; // use for pagination
    
    // Invoke GetOffersByCatalog API via method getOffers()
    digitalCommerce
      .getOffers(input)
      .then(result => {
        Logger.info("vlocity get catalog offers anonymous user rest call" + result);
      })
      .catch(error => {
        Logger.info("get catalog offers anonymous user rest call failed" + error);
      });
    
    // getOffers without the contains parameter
    
    // Instantiate the input object for getOffers to specify parameters.
    const input = digitalCommerce.createGetOffersInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "Phones"; // use your Catalog Code
    input.offset = 0; // use for pagination
    input.pageSize = 5; // use for pagination
    input.contains = "iPhone8"; // find all offers that CONTAIN "iPhone8"
    
    // Invoke GetOffersByCatalog API via method getOffers()
    digitalCommerce
      .getOffers(input)
      .then(result => {
        Logger.info("vlocity get catalog offers anonymous user rest call" + result);
      })
      .catch(error => {
        Logger.info("get catalog offers anonymous user rest call failed" + error);
      });
    throws

    "GetCatalogOffersInput::getAPIPath() must have catalogCode."

    throws

    "GetCatalogOffersInput::getAnonymousRestUrl() must have anonymousSiteUrl."

    throws

    "GetCatalogOffersInput::getAnonymousRestUrl() must have anonymousSiteUrl."

    throws

    "GetCatalogOffersContainsInput::getAPIPath() should not have both sortBy and contains."

    throws

    "GetCatalogOffersContainsInput::getAnonymousRestUrl() should not have both sortBy and contains."

    Parameters

    Returns Promise<OfferList>

Private getSelectedOffer

  • getSelectedOffer(offerCode: string, parseOffer?: boolean): any
  • Returns the offer for given code that are being configured. Undefined if offer not exists.

    Parameters

    • offerCode: string

      offer code of the selected offer in memory to be retrieved.

    • Optional parseOffer: boolean

    Returns any

Private invokeAPI

  • Returns a list of catalog offers.

    throws

    Error - needs to be caught

    Parameters

    Returns Promise<any>

Private invokeAction

  • Invoke an action returning from previous API call.

    example
    
    // Instantiate the input object for getOfferDetails to specify parameters
    const input = digitalCommerce.createGetOfferInput();
    input.anonymousSiteUrl = "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.apiNamespace = "cacheableapi";
    input.actionObj = {
        client: {
          records: [],
          params: {}
        },
        remote: {
          params: {}
        },
        rest: {
          params: {},
          method: "GET",
          link: "/v3/catalogs/Phones/offers/iPhone6"
        };
    
    // Invoke GetOfferDetails API via method getOfferDetails()
    digitalCommerce
    .invokeAction(input)
    .then(response => {
      Logger.info(
        "vlocity get catalog offers anonymous user rest call" + response
      );
    })
    .catch(error => {
      Logger.info(
        "get catalog offers anonymous user rest call failed" + error
      );
    });

    Parameters

    Returns Promise<any>

parseCart

  • parseCart(cartResponse: any): Cart
  • Method to parse cart response

    Parameters

    • cartResponse: any

    Returns Cart

parseOffer

  • parseOffer(offerResponse: any): Offer
  • Method to parse offer response

    Parameters

    • offerResponse: any

    Returns Offer

parseOfferList

  • parseOfferList(offersResponse: any): OfferList
  • Method to parse offers response

    Parameters

    • offersResponse: any

    Returns OfferList

updateItemsInCart

  • example
    
    // Instantiate the input object for update item in cart to specify parameters
    const input = digitalCommerce.UpdateItemsInCartInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.lineItemKey = "23053efb4bff132b1d84992a81d10469"; // use your cart context key
    input.quantity = 2;
    
    // Invoke Get Basket API via method updateItemsInCart()
    digitalCommerce
      .updateItemsInCart(input)
     .then(response => {
        Logger.info(
          "Vlocity digital commerce updateItemsInCart for anonymous user: " +
            JSON.stringify(response)
        );
      })
      .catch(error => {
        Logger.info(
          "updateItemsInCart for anonymous user rest call failed" +
            error
        );
      });
    

    Replace the item in cart with the provided offer configurations.

    Parameters

    Returns Promise<any>

Private updateSelectedOffer

  • updateSelectedOffer(offer: any): void
  • Parameters

    • offer: any

    Returns void

validateOffer

  • Validate an offer. After configuring the offer by setting attributes' values, adding/removing child product, updating quantity, developer can call this function to validate the offer.

    example
    
    // Instantiate the input object for configureOfferDetails to specify parameters
    const input = digitalCommerce.createConfigureOfferDetailsInput();
    input.anonymousSiteUrl =
      "https://myaws.execute-api.us-west-2.amazonaws.com/prod/dc"; // use your AWS gateway
    input.catalogCode = "Phones"; // use your Catalog Code
    input.offerCode = "iPhone8Offer"; // use your Offer Code
    input.forceInvalidateCache = true;
    
    // use the json structure from getOffer() or the cached offer
    input.offerConfiguration = digitalCommerce.getSelectedOffer(offerCode);
    
    // Invoke ConfigureOfferDetails API to validate offer
    digitalCommerce
      .validateOffer(input)
      .then(response => {
        Logger.info(
          "Validated offer response: " +
            JSON.stringify(response)
        );
      })
      .catch(error => {
        Logger.info(
          "validate offer failed: " + error
        );
      });
    throws

    "ValidateOfferInput::isValid() error in validating the input."

    throws

    "ValidateOfferInput::getAPIPath() must have catalogCode."

    throws

    "ValidateOfferInput::getAPIPath() must have offerCode."

    throws

    "ValidateOfferInput::getAnonymousRestUrl() must have anonymousSiteUrl."

    throws

    "ValidateOfferInput::getRequestPayload() must have productConfiguration."

    Parameters

    Returns Promise<any>

    a Promise with validated offer JSON.

version

  • version(): string
  • Returns the version number of SDK.

    Returns string

    Returns SDK version number as string

Static createConfigForAnonymousUser

  • Create a DigitalCommerceSDKConfig object that consists of a UserContext and a DataSourceService for anonymous user.

    example
    
    // Instantiate DigitalCommerceSDKConfig for anonymous user
    const digitalCommerceSDKConfig = VlocitySDK.digitalcommerce.createConfigForAnonymousUser();
    
    // Instantiate the SDK itself
    const digitalCommerce = VlocitySDK.digitalcommerce.getInstance(digitalCommerceSDKConfig);

    Returns DigitalCommerceSDKConfig

    Configuration object to instantiate SDK.

Static createConfigForLoginUser

  • Create a DigitalCommerceSDKConfig object that consists of a UserContext and a DataSourceService for login user.

    example
    
    // Instantiate DigitalCommerceSDKConfig for login user
    const digitalCommerceSDKConfig = VlocitySDK.digitalcommerce.createConfigForLoginUser(salesforceUrl, sessionToken);
    
    // Instantiate the SDK itself
    const digitalCommerce = VlocitySDK.digitalcommerce.getInstance(digitalCommerceSDKConfig);

    Parameters

    • salesforceUrl: string
    • sessionToken: string

    Returns DigitalCommerceSDKConfig

    Configuration object to instantiate SDK.

Static extend

  • extend(extendObj: object): void
  • Adds all the enumerable string keyed function properties of a source object to the sdk prototype. .extend should only be used to add new methods and it won't override the existing methods.

    Note: If the property already exists, it will be not be added.

    Custom functions which are being extended should have proper namespaces to avoid issues during upgrades. When Vlocity releases new changes it won't impact if unique namespaces are used.

    Example: myCompanyOrFeatureMethodName

    example

    How to extend an sdk?

    VlocitySDK.datasource.extend({ myCompanySayHello(){
         console.log("Hello World");
      }, sayTime() {
         console.log(new Date().myCompanyGetTime());
      }});
    
    const dataSource = VlocitySDK.datasource.getInstance({'create':true});
    console.log(daSource.myCompanySayHello())

    Parameters

    • extendObj: object

      The object of functions

    Returns void

Static getInstance

  • Get a singleton instance of this SDK.

    example
    
    // Instantiate DigitalCommerceSDKConfig for anonymous user
    const digitalCommerceSDKConfig = VlocitySDK.digitalcommerce.createConfigForAnonymousUser();
    
    // Instantiate the SDK itself
    const digitalCommerce = VlocitySDK.digitalcommerce.getInstance(digitalCommerceSDKConfig);
    
    OR
    
    // Instantiate DigitalCommerceSDKConfig for login user
    const digitalCommerceSDKConfig = VlocitySDK.digitalcommerce.createConfigForLoginUser(salesforceUrl, sessionToken);
    
    // Instantiate the SDK itself
    const digitalCommerce = VlocitySDK.digitalcommerce.getInstance(digitalCommerceSDKConfig);
    
    Note:
    digitalCommerce is a Singleton object.  Calling getInstance(digitalCommerceSDKConfig) repeatedly will return the same instance instantiated the first time when getInstance(digitalCommerceSDKConfig) was called.
    
    // To instantiate a new instance of digitalCommerce, set create to true in the digitalCommerceSDKConfig object:
    digitalCommerceSDKConfig.create = true;
    digitalCommerce = VlocitySDK.digitalcommerce.getInstance(digitalCommerceSDKConfig);
    throws

    "DigitalCommerce:: getInstance: Config object must be given in argument to create an instance the first time."

    throws

    "DigitalCommerce::constructor: DigitalCommerce cannot be instantiated properly. Both datasource and user context objects have to be in Config object as argument."

    Parameters

    Returns DigitalCommerce

    SDK instance.

Static override

  • override(overrideObj: object): void
  • Adds all the enumerable string keyed function properties of a source object to the sdk prototype.

    .override method should only be used to override the existing methods and should only be used in rare cases. Overriding the existing or default methods may cause unintended consequences and may also impact during upgrades.

    Please be cautious while using this

    example

    How to override methods in an sdk?

    VlocitySDK.datasource.override({ soql(){
         console.log("This code overrides the default soql function");
         // code goes here...
      }, sosl() {
         console.log("This code overrides the default soql function");
         // code goes here...
      }});
    
    const dataSource = VlocitySDK.datasource.getInstance({'create':true});
    console.log(dataSource.soql()); // prints "This code overrides the default soql function"

    Parameters

    • overrideObj: object

      The object of functions

    Returns void

Generated using TypeDoc