Options
All
  • Public
  • Public/Protected
  • All
Menu

B2B Express Facade to interact with Vlocity B2B Express functionality.

The B2B Express SDK is a JavaScript library that abstracts and simplifies the use of V2 & V3 API REST calls.

The SDK provides error checking and validates parameters before submitting them to the 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 APIs.

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

version

109.0.0

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

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

    Parameters

    • config: B2BSDKConfig

      B2BSDKConfig Config to initialize this SDK.

    Returns B2BExpress

Properties

Private cartItems

cartItems: any

stores the products in the cart

Private context

context: UserContext

The UserContext used for this SDK.

Private datasource

datasource: DataSource

The datasource connection used by this SDK.

Private deleteArrayListItems

deleteArrayListItems: string[] = ["Attachments","actions","messages","childProducts","lineItems"]

Static Private instance

instance: B2BExpress

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

Accessors

apiURL

  • set apiURL(apiURL: string): void
  • Customers can override their custom anonymous URL using apiURL

    Parameters

    • apiURL: string

    Returns void

authToken

  • set authToken(authToken: string): void
  • Customers can set the anonymous URL auth token using authToken

    Parameters

    • authToken: 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

addProductToCart

  • Add the product to the cart.

    example
    
    // Instantiate the input object for addProductToCart to specify parameters
    const input = b2bexpress.createAddProductToCartInput();
    input.parentId = ""; // pass parent id if available. - optional.
    input.rootBundleId = "1234"; // pass the root bundle Id.
    input.actionObj = {}; // pass addtocart action object
    
    // Invoke /cpq/carts/:itemId/items API via method addProductToCart()
    b2bexpress
      .addProductToCart(input)
      .then(result => {
        Logger.info("Vlocity add product to cart rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity add product to cart rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

addProductToCartPostHook

  • addProductToCartPostHook(cartResponse: any, originalCartResponse?: any): Promise<any>
  • addProductToCart SDK call posthook method.

    example
    
    // How to override addProductToCartPostHook method
    VlocitySDK.b2bexpress.override({ addProductToCartPostHook(cartResponse, originalCartResponse){
      console.log("addProductToCartPostHook method is being overridden");
      return Promise.resolve(cartResponse);
    }});
    

    Parameters

    • cartResponse: any
    • Optional originalCartResponse: any

    Returns Promise<any>

addProductToCartPreHook

  • addProductToCartPreHook(input: any): Promise<any>
  • addProductToCart SDK call prehook method.

    example
    
    // How to override addProductToCartPreHook method
    VlocitySDK.b2bexpress.override({ addProductToCartPreHook(input){
      input.params1 = "abc"; // update the SDK input
      console.log("addProductToCartPreHook method is being overridden");
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

applyAdjustment

  • apply adjustments for the given cartItem.

    example
    
    // Instantiate the input object for ApplyAdjustmentInput to specify parameters
    const input = b2bexpress.createApplyAdjustmentInput();
    input.actionObj = cartItem.vlocity_cmt__RecurringCharge__c.actions.applyadjustment;
    input.adjustmentData = {'detailType':'Override','method':'ABSOLUTE', 'value':50};
    
    // Invoke /cpq/carts/:cartItemId/items/:itemId/pricing  POST API via method applyAdjustment()
    b2bexpress
      .applyAdjustment(input)
      .then(result => {
        Logger.info("Vlocity apply adjustment rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity apply adjustment rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

applyAdjustmentsPostHook

  • applyAdjustmentsPostHook(cartResponse?: any, originalCartResponse?: any): Promise<any>
  • applyAdjustment SDK call posthook method.

    example
    
    // How to override applyAdjustmentsPostHook method
    VlocitySDK.b2bexpress.override({ applyAdjustmentsPostHook(cartResponse,originalCartResponse){
      console.log("applyAdjustmentsPostHook method is being overridden");
      return Promise.resolve(cartResponse);
    }});
    

    Parameters

    • Optional cartResponse: any
    • Optional originalCartResponse: any

    Returns Promise<any>

applyAdjustmentsPreHook

  • applyAdjustmentsPreHook(input: any): Promise<any>
  • applyAdjustment SDK call prehook method.

    example
    
    // How to override applyAdjustmentsPreHook method
    VlocitySDK.b2bexpress.override({ applyAdjustmentsPreHook(input){
      console.log("applyAdjustmentsPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

cloneItems

  • Clone Line Items in the cart.

    example
    
    // Instantiate the input object for createCloneItemsInput to specify parameters
    const input = b2bexpress.createCloneItemsInput();
    input.actionObj = cartItem.actions.cloneitem;
    
    // Invoke /cpq/carts/:cartItemId/items/clone  POST API via method cloneItems()
    b2bexpress
      .cloneItems(input)
      .then(result => {
        Logger.info("Vlocity clone items in the cart rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity clone items in the cart rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

cloneItemsPostHook

  • cloneItemsPostHook(cloneItemResponse: any, originalCloneItemResponse?: any): Promise<any>
  • cloneItems SDK call posthook method.

    example
    
    // How to override cloneItemsPostHook method
    VlocitySDK.b2bexpress.override({ cloneItemsPostHook(cloneItemResponse,originalCloneItemResponse){
      console.log("cloneItemsPostHook method is being overridden");
      return Promise.resolve(cloneItemResponse);
    }});
    

    Parameters

    • cloneItemResponse: any
    • Optional originalCloneItemResponse: any

    Returns Promise<any>

cloneItemsPreHook

  • cloneItemsPreHook(input: any): Promise<any>
  • cloneItems SDK call prehook method.

    example
    
    // How to override cloneItemsPreHook method
    VlocitySDK.b2bexpress.override({ cloneItemsPreHook(input){
      console.log("cloneItemsPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

createAddProductToCartInput

  • Create a default AddToCartItemInput object.

    Returns AddProductToCartInput

createApplyAdjustmentInput

  • Create a default ApplyAdjustmentInput object.

    Returns ApplyAdjustmentInput

createCloneItemsInput

  • Create a default CloneItemsInput object.

    Returns CloneItemsInput

createDeleteCartItemInput

  • Create a default DeleteCartItemInput object.

    Returns DeleteCartItemInput

createDeletePriceAdjustmentInput

  • Create a default DeletePriceAdjustmentInput object.

    Returns DeletePriceAdjustmentInput

createGetCartItemsInput

  • Create a default GetCartItemsInput object.

    Returns GetCartItemsInput

createGetCartLineItemPricesInput

  • Create a default GetCartLineItemPricesInput object.

    Returns GetCartLineItemPricesInput

createGetCartProductsInput

  • Create a default GetCartProductsInput object.

    Returns GetCartProductsInput

createGetCartSummaryInput

  • Create a default GetCartItemsInput object.

    Returns GetCartSummaryInput

createGetCatalogsInput

  • Create a default GetCatalogsInput object.

    Returns GetCatalogsInput

createGetPriceDetailsInput

  • Create a default GetPriceDetailsInput object.

    Returns GetPriceDetailsInput

createGetTimeListsInput

  • Create a default GetTimeListsInput object.

    Returns GetTimeListsInput

createUpdateCartLineItemInput

  • Create a default UpdateCartLineItemInput object.

    Returns UpdateCartLineItemInput

createWorkingCart

  • Returns the working cart details.

    example
    
    // Instantiate the input object for createWorkingCart to specify parameters
    const input = b2bexpress.createWorkingCartInput();
    input.inputMap = {SalesQuoteId = "1234"}; // use your sales quote Id
    input.ipMethod = "create_WorkingCart"; // pass the VIP name
    
    // Invoke create_WorkingCart VIP via method createWorkingCart()
    b2bexpress
      .createWorkingCart(input)
      .then(result => {
        Logger.info("Vlocity create working cart rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity create working cart rest call failed" + error);
      });
    throws

    "CreateWorkingCartInput::getRequestPayload() must have SalesQuoteId."

    throws

    "CreateWorkingCartInput::getRequestPayload() must have ipMethod."

    Parameters

    Returns Promise<any>

createWorkingCartInput

  • Create a default createWorkingCartInput object.

    Returns CreateWorkingCartInput

createWorkingCartPostHook

  • createWorkingCartPostHook(workingCartResponse: any): Promise<any>
  • createWorkingCart SDK call posthook method.

    example
    
    // How to override createWorkingCartPostHook method
    VlocitySDK.b2bexpress.override({ createWorkingCartPostHook(workingCartResponse){
      // update the response
      console.log("createWorkingCartPostHook method is being overridden");
      return Promise.resolve(workingCartResponse);
    }});
    

    Parameters

    • workingCartResponse: any

    Returns Promise<any>

createWorkingCartPreHook

  • createWorkingCartPreHook(input: any): Promise<any>
  • createWorkingCart SDK call prehook method.

    example
    
    // How to override createWorkingCartPreHook method
    VlocitySDK.b2bexpress.override({ createWorkingCartPreHook(input){
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

deleteCartItem

  • delete the line item to the cart.

    example
    
    // Instantiate the input object for deleteCartItem to specify parameters
    const input = b2bexpress.createDeleteCartItemInput();
    input.lineItemId = "1234"; // pass the updated line item object id.
    input.parentId = "1234"; // pass the parent object id if available - optional.
    input.rootBundleId = "1234"; //  pass the root bundle Id.
    input.actionObj = {}; // pass deleteitem action object
    
    // Invoke /cpq/carts/:cartItemId/items DELETE API via method deleteCartItem()
    b2bexpress
      .deleteCartItem(input)
      .then(result => {
        Logger.info("Vlocity delete line item from cart rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity delete line item from cart rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

deleteCartItemPostHook

  • deleteCartItemPostHook(cartResponse: any, originalCartResponse?: any): Promise<any>
  • deleteCartItem SDK call posthook method.

    example
    
    // How to override deleteCartItemPostHook method
    VlocitySDK.b2bexpress.override({ deleteCartItemPostHook(cartResponse, originalCartResponse){
      console.log("deleteCartItemPostHook method is being overridden");
      return Promise.resolve(cartResponse);
    }});
    

    Parameters

    • cartResponse: any
    • Optional originalCartResponse: any

    Returns Promise<any>

deleteCartItemPreHook

  • deleteCartItemPreHook(input: any): Promise<any>
  • deleteCartItem SDK call prehook method.

    example
    
    // How to override deleteCartItemPreHook method
    VlocitySDK.b2bexpress.override({ deleteCartItemPreHook(input){
      console.log("deleteCartItemPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

deletePriceAdjustments

  • Delete Price Adjustments for the Line Items in the cart.

    example
    
    // Instantiate the input object for createDeletePriceAdjustmentInput to specify parameters
    const input = b2bexpress.createDeletePriceAdjustmentInput();
    input.actionObj = priceDetails.actions.deleteAdjustment;
    
    // Invoke "/cpq/carts/:cartId/items/:lineItemId/pricing/:adjustmentId" DELETE API via method deletePriceAdjustments()
    b2bexpress
      .deletePriceAdjustments(input)
      .then(result => {
        Logger.info("Vlocity delete adjustments rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity delete adjustments rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

deletePriceAdjustmentsPostHook

  • deletePriceAdjustmentsPostHook(priceResponse: any, originalPriceResponse?: any): Promise<any>
  • deletePriceAdjustments SDK call posthook method.

    example
    
    // How to override deletePriceAdjustmentsPostHook method
    VlocitySDK.b2bexpress.override({ deletePriceAdjustmentsPostHook(priceResponse,originalPriceResponse){
      console.log("deletePriceAdjustmentsPostHook method is being overridden");
      return Promise.resolve(priceResponse);
    }});
    

    Parameters

    • priceResponse: any
    • Optional originalPriceResponse: any

    Returns Promise<any>

deletePriceAdjustmentsPreHook

  • deletePriceAdjustmentsPreHook(input: any): Promise<any>
  • deletePriceAdjustments SDK call prehook method.

    example
    
    // How to override deletePriceAdjustmentsPreHook method
    VlocitySDK.b2bexpress.override({ deletePriceAdjustmentsPreHook(input){
      console.log("deletePriceAdjustmentsPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

getCartItems

  • get all cart items for the given cartId.

    example
    
    // Instantiate the input object for getCartItems to specify parameters
    const input = b2bexpress.createGetCartItemsInput();
    input.cartId = "123"; // pass your cardId
    
    // Invoke /cpq/carts/:cartId/items GET API via method getCartItems()
    b2bexpress
      .getCartItems(input)
      .then(result => {
        Logger.info("Vlocity get cart items rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity get cart items rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

getCartItemsPostHook

  • getCartItemsPostHook(cartItems: any, originalCartItems?: any): Promise<any>
  • getCartItems SDK call posthook method.

    example
    
    // How to override getCartItemsPostHook method
    VlocitySDK.b2bexpress.override({ getCartItemsPostHook(cartResponse, originalCartItems){
      console.log("getCartItemsPostHook method is being overridden");
      return Promise.resolve(cartItems);
    }});
    

    Parameters

    • cartItems: any
    • Optional originalCartItems: any

    Returns Promise<any>

getCartItemsPreHook

  • getCartItemsPreHook(input: any): Promise<any>
  • getCartItems SDK call prehook method.

    example
    
    // How to override getCartItemsPreHook method
    VlocitySDK.b2bexpress.override({ getCartItemsPreHook(input){
      console.log("getCartItemsPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

getCartLineItemPrices

  • get the prices for the given cartitem.

    example
    
    // Instantiate the input object for getCartLineItemPrices to specify parameters
    const input = b2bexpress.createGetCartLineItemPricesInput();
    input.actionObj = cartResponse.actions.itempricesupdated; // pass itempricesupdated action object
    
     // Invoke /cpq/carts/:cartItemId/price GET API via method getCartLineItemPrices()
    b2bexpress
      .getCartLineItemPrices(input)
      .then(result => {
        Logger.info("Vlocity get line item prices rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity get line item prices rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

getCartLineItemPricesPostHook

  • getCartLineItemPricesPostHook(cartLineItemPrices: any): Promise<any>
  • getCartLineItemPrices SDK call posthook method.

    example
    
    // How to override getCartLineItemPricesPostHook method
    VlocitySDK.b2bexpress.override({ getCartLineItemPricesPostHook(cartLineItemPrices){
      console.log("getCartLineItemPricesPostHook method is being overridden");
      return Promise.resolve(cartLineItemPrices);
    }});
    

    Parameters

    • cartLineItemPrices: any

    Returns Promise<any>

getCartLineItemPricesPreHook

  • getCartLineItemPricesPreHook(input: any): Promise<any>
  • getCartLineItemPrices SDK call prehook method.

    example
    
    // How to override getCartLineItemPricesPreHook method
    VlocitySDK.b2bexpress.override({ getCartLineItemPricesPreHook(input){
      console.log("getCartLineItemPricesPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

getCartProducts

  • Get cart products.

    example
    
    // Instantiate the input object for createGetCartProductsInput to specify parameters
    const input = b2bexpress.createGetCartProductsInput();
    input.cartId = B2BTestData.workingCartId;
    input.category = "CATEGORY_ID";
    input.includeAttributes = true;
    
    b2bexpress
      .getCartProducts(input)
      .then(result => {
        Logger.info("Vlocity Get cart products rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity Get cart products rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

getCartProductsPostHook

  • getCartProductsPostHook(cartProductsResponse: any, originalCartProductsResponse?: any): Promise<any>
  • getCartProducts SDK call posthook method.

    example
    
    // How to override getCartProductsPostHook method
    VlocitySDK.b2bexpress.override({ getCartProductsPostHook(cartProductsResponse){
      console.log("getCartProductsPostHook method is being overridden");
      return Promise.resolve(cartProductsResponse);
    }});
    

    Parameters

    • cartProductsResponse: any
    • Optional originalCartProductsResponse: any

    Returns Promise<any>

getCartProductsPreHook

  • getCartProductsPreHook(input: any): Promise<any>
  • getCartProducts SDK call prehook method.

    example
    
    // How to override getCartProductsPreHook method
    VlocitySDK.b2bexpress.override({ getCartProductsPreHook(input){
      console.log("getCartProductsPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

getCartSummary

  • get cart summary for the given cartId.

    example
    
    // Instantiate the input object for GetCartSummaryInput to specify parameters
    const input = b2bexpress.createGetCartSummaryInput();
    input.cartId = "123"; // pass your cardId
    
    // Invoke /cpq/carts/:cartId  GET API via method getCartSummary()
    b2bexpress
      .getCartSummary(input)
      .then(result => {
        Logger.info("Vlocity get cart summary rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity get cart summary rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

getCartSummaryDetails

  • getCartSummaryDetails(originalResponse: any, input: any): any
  • Returns the existing cart item details in the SDK

    Parameters

    • originalResponse: any

      optional parameter - set to TRUE if you want original API response.

    • input: any

    Returns any

getCartSummaryPostHook

  • getCartSummaryPostHook(cartSummary: any, originalcartSummary?: any): Promise<any>
  • getCartSummary SDK call posthook method.

    example
    
    // How to override getCartSummaryPostHook method
    VlocitySDK.b2bexpress.override({ getCartSummaryPostHook(cartSummary, originalcartSummary){
      console.log("getCartSummaryPostHook method is being overridden");
      return Promise.resolve(cartSummary);
    }});
    

    Parameters

    • cartSummary: any
    • Optional originalcartSummary: any

    Returns Promise<any>

getCartSummaryPreHook

  • getCartSummaryPreHook(input: any): Promise<any>
  • getCartSummary SDK call prehook method.

    example
    
    // How to override getCartSummaryPreHook method
    VlocitySDK.b2bexpress.override({ getCartSummaryPreHook(input){
      console.log("getCartSummaryPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

getCatalogs

  • Get catalogs.

    example
    
    // Instantiate the input object for createGetCatalogsInput to specify parameters
    const input = b2bexpress.createGetCatalogsInput();
    
    b2bexpress
      .getCatalogs(input)
      .then(result => {
        Logger.info("Vlocity Get Catalogs rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity Get Catalogs rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

getCatalogsPostHook

  • getCatalogsPostHook(catalogs: any): Promise<any>
  • getCatalogs SDK call posthook method.

    example
    
    // How to override getCatalogsPostHook method
    VlocitySDK.b2bexpress.override({ getCatalogsPostHook(catalogs){
      console.log("getCatalogsPostHook method is being overridden");
      return Promise.resolve(catalogs);
    }});
    

    Parameters

    • catalogs: any

    Returns Promise<any>

getCatalogsPreHook

  • getCatalogsPreHook(input: any): Promise<any>
  • getCatalogs SDK call prehook method.

    example
    
    // How to override getCatalogsPreHook method
    VlocitySDK.b2bexpress.override({ getCatalogsPreHook(input){
      console.log("getCatalogsPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

getPriceDetails

  • Get Price Adjustments Details for the Line Items in the cart.

    example
    
    // Instantiate the input object for createGetPriceDetailsInput to specify parameters
    const input = b2bexpress.createGetPriceDetailsInput();
    input.actionObj = lineItem.vlocity_cmt__OneTimeCharge__c.actions.pricedetail;
    
    // Invoke "/cpq/carts/:cartId/items/:lineItemId/pricing" GET API via method getPriceDetails()
    b2bexpress
      .getPriceDetails(input)
      .then(result => {
        Logger.info("Vlocity Get adjustment price details rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity Get adjustment price details rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

getPriceDetailsPostHook

  • getPriceDetailsPostHook(priceResponse: any, originalPriceResponse?: any): Promise<any>
  • getPriceDetails SDK call posthook method.

    example
    
    // How to override getPriceDetailsPostHook method
    VlocitySDK.b2bexpress.override({ getPriceDetailsPostHook(priceResponse, originalPriceResponse){
      console.log("getPriceDetailsPostHook method is being overridden");
      return Promise.resolve(priceResponse);
    }});
    

    Parameters

    • priceResponse: any
    • Optional originalPriceResponse: any

    Returns Promise<any>

getPriceDetailsPreHook

  • getPriceDetailsPreHook(input: any): Promise<any>
  • getPriceDetails SDK call prehook method.

    example
    
    // How to override getPriceDetailsPreHook method
    VlocitySDK.b2bexpress.override({ getPriceDetailsPreHook(input){
      console.log("getPriceDetailsPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

getTimeLists

  • Get existing time plans and policies.

    example
    
    // Instantiate the input object for createGetTimeListsInput to specify parameters
    const input = b2bexpress.createGetTimeListsInput();
    input.actionObj = lineItem.vlocity_cmt__RecurringCharge__c.actions.timelists;
    
    // Invoke "v2/listsofvalues?listkeys=TimePlans,TimePolicies" GET API via method getTimeLists()
    b2bexpress
      .getTimeLists(input)
      .then(result => {
        Logger.info("Vlocity Get Time Lists rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity Get Time Lists rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

getTimeListsPostHook

  • getTimeListsPostHook(timeListResponse: any, originalTimeListResponse?: any): Promise<any>
  • getTimeLists SDK call posthook method.

    example
    
    // How to override getTimeListsPostHook method
    VlocitySDK.b2bexpress.override({ getTimeListsPostHook(priceResponse, originalTimeListResponse){
      console.log("getTimeListsPostHook method is being overridden");
    }});
    

    Parameters

    • timeListResponse: any
    • Optional originalTimeListResponse: any

    Returns Promise<any>

getTimeListsPreHook

  • getTimeListsPreHook(input: any): Promise<any>
  • getTimeLists SDK call prehook method.

    example
    
    // How to override getTimeListsPreHook method
    VlocitySDK.b2bexpress.override({ getTimeListsPreHook(input){
      console.log("getTimeListsPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

Private invokeAPI

  • Returns a API call response.

    throws

    Error - needs to be caught

    Parameters

    Returns Promise<any>

Private invokeAction

  • invokeAction(input: any): Promise<any>
  • Invoke an action returning from previous API call.

    example
    
    // Instantiate the input object to specify parameters
    const input = b2bexpress.createUpdateCartLineItemInput();
    input.actionObj = {
        client: {
          records: [],
          params: {}
        },
        remote: {
          params: {}
        },
        rest: {
          params: {},
          method: "POST",
          link: "/v2/carts/:cartId/items"
        };
    
    // Invoke your API with invokeAction method
    b2bExpressSDK
    .invokeAction(input)
    .then(response => {
      Logger.info(
        "Invoke Action Response" + response
      );
    })
    .catch(error => {
      Logger.info(
        "Invoke Action call failed" + error
      );
    });

    Parameters

    • input: any

    Returns Promise<any>

Private invokeDataRaptor

  • invokeDataRaptor(input: B2BInput): Promise<any>
  • Returns a DataRaptor call response.

    • @example ```typescript // Instantiate the input object to specify parameters const input = { bundleName: "GetRecordTypeId", inputMap: {RecordTypeName:'Group Cart'} }

    // Invoke your API with invokeAction method b2bExpressSDK .invokeDataRaptor(input) .then(response => { Logger.info( "Invoke DataRaptor Response" + response ); }) .catch(error => { Logger.info( "Invoke DataRaptor call failed" + error ); }); ```

    throws

    Error - needs to be caught

    Parameters

    Returns Promise<any>

Private invokeIntegrationProcedure

  • Returns a VIP call response.

    • @example ```typescript const input = { ipMethod: "create_WorkingCart"; // pass the VIP name, inputMap: {SalesQuoteId = "1234"} }

    // Invoke your API with invokeAction method b2bExpressSDK .invokeIntegrationProcedure(input) .then(response => { Logger.info( "Invoke VIP Response" + response ); }) .catch(error => { Logger.info( "Invoke VIP call failed" + error ); }); ```

    throws

    Error - needs to be caught

    Parameters

    Returns Promise<any>

updateCartLineItem

  • Update the line item to the cart.

    example
    
    // Instantiate the input object for updateCartLineItem to specify parameters
    const input = b2bexpress.createUpdateCartLineItemInput();
    input.lineItemId = "1234"; // pass the updated line item product id.
    input.rootBundleId = "1234"; // pass the root bundle Id.
    input.actionObj = {}; // pass updateitems action object
    input.lineItemDetails = { action: "updateQuantity", data: { value: 2 } };
    
    // Invoke /cpq/carts/:cartItemId/items PUT API via method updateCartLineItem()
    b2bexpress
      .updateCartLineItem(input)
      .then(result => {
        Logger.info("Vlocity update product to cart rest call" + result);
      })
      .catch(error => {
        Logger.info("Vlocity update product to cart rest call failed" + error);
      });

    Parameters

    Returns Promise<any>

updateCartLineItemPostHook

  • updateCartLineItemPostHook(cartResponse: any, originalCartResponse?: any): Promise<any>
  • updateCartLineItem SDK call posthook method.

    example
    
    // How to override updateCartLineItemPostHook method
    VlocitySDK.b2bexpress.override({ updateCartLineItemPostHook(cartResponse,originalCartResponse){
      console.log("updateCartLineItemPostHook method is being overridden");
      return Promise.resolve(cartResponse);
    }});
    

    Parameters

    • cartResponse: any
    • Optional originalCartResponse: any

    Returns Promise<any>

updateCartLineItemPreHook

  • updateCartLineItemPreHook(input: any): Promise<any>
  • updateCartLineItem SDK call prehook method.

    example
    
    // How to override updateCartLineItemPreHook method
    VlocitySDK.b2bexpress.override({ updateCartLineItemPreHook(input){
      console.log("updateCartLineItemPreHook method is being overridden");
      input.params1 = "abc"; // update the SDK input
      return Promise.resolve(input);
    }});
    

    Parameters

    • input: any

    Returns Promise<any>

version

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

    Returns string

    Returns SDK version number as string

Static createConfigForAnonymousUser

  • createConfigForAnonymousUser(authToken: string): B2BSDKConfig
  • Create a B2BSDKConfig object that consists of a UserContext and a DataSourceService for anonymous user.

    example
    
    // Instantiate B2BSDKConfig for anonymous user
    const b2bSDKConfig = VlocitySDK.b2bexpress.createConfigForAnonymousUser();
    
    // Instantiate the SDK itself
    const b2bExpressSDK = VlocitySDK.b2bexpress.getInstance(b2bSDKConfig);

    Parameters

    • authToken: string

    Returns B2BSDKConfig

    Configuration object to instantiate SDK.

Static createConfigForLoginUser

  • createConfigForLoginUser(salesforceUrl: string, sessionToken: string, proxyUrl?: string): B2BSDKConfig
  • Create a B2BSDKConfig object that consists of a UserContext, DigitalCommerce and a DataSourceService for login user.

    example
    
    // Instantiate B2BSDKConfig for login user
    const b2bSDKConfig = VlocitySDK.b2bexpress.createConfigForLoginUser(salesforceUrl, sessionToken);
    
    // Instantiate the SDK itself
    const b2bExpressSDK = VlocitySDK.b2bexpress.getInstance(b2bSDKConfig);

    Parameters

    • salesforceUrl: string
    • sessionToken: string
    • Optional proxyUrl: string

      optional

    Returns B2BSDKConfig

    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 B2BSDKConfig for anonymous user
    const b2bSDKConfig = VlocitySDK.b2bexpress.createConfigForAnonymousUser();
    
    // Instantiate the SDK itself
    const b2bExpressSDK = VlocitySDK.b2bexpress.getInstance(b2bSDKConfig);
    
    OR
    
    // Instantiate B2BSDKConfig for login user
    const b2bSDKConfig = VlocitySDK.b2bexpress.createConfigForLoginUser(salesforceUrl, sessionToken);
    
    // Instantiate the SDK itself
    const b2bExpressSDK = VlocitySDK.b2bexpress.getInstance(b2bSDKConfig);
    
    Note:
    b2bExpressSDK is a Singleton object.  Calling getInstance(b2bSDKConfig) repeatedly will return the same instance instantiated the first time when getInstance(b2bSDKConfig) was called.
    
    // To instantiate a new instance of b2bExpressSDK, set create to true in the b2bSDKConfig object:
    b2bSDKConfig.create = true;
    b2bExpressSDK = VlocitySDK.b2bexpress.getInstance(b2bSDKConfig);
    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 B2BExpress

    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