Options
All
  • Public
  • Public/Protected
  • All
Menu

Digital Commerce Proxy SDK is to interact with Vlocity Digital Commerce SDK functionality hosted in node server.

The Digital Commerce Proxy SDK is a JavaScript library that act as Proxy between UI and Digital Commerce SDK hosted in server.

The Digital Commerce Proxy SDK contains all Input instance creation methods & invoke API methods. It will validate input before sending to Server SDK.

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

Hierarchy

Index

Constructors

constructor

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

    Parameters

    • config: any

      DigitalCommerceProxyConfig Config to initialize this SDK.

    Returns DigitalCommerceProxy

Properties

Private cartContextKey

cartContextKey: string = null

context

context: any

Private datasource

datasource: DataSource

The datasource connection used by this SDK.

Private secureServerRequestCredentials

secureServerRequestCredentials: RequestCredentials

Credentials to set in request header for API call to Secure Server. it can be "omit" | "same-origin" | "include" by default it will be "same-origin"

Private secureServerUrl

secureServerUrl: string

Private secureServerUrl

Static Private instance

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

Accessors

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

addToCart

  • Proxy addToCart method calls Server SDK addToCart method with given input

    throws

    "AddToCartInput::getAPIPath() 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::getRequestPayload() must have basketAction."

    throws

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

    throws

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

    throws

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

    throws

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

    Parameters

    Returns Promise<any>

assetToBasket

  • Proxy method calls Server SDK submitOrder method with given input

    Parameters

    Returns Promise<any>

authenticateUser

  • Proxy authenticateUser method calls Server SDK signIn method with given input

    throws

    "AuthenticateUserInput::getRequestPayload() must have email."

    throws

    "AuthenticateUserInput::getRequestPayload() must have sessionToken."

    throws

    "AuthenticateUserInput::getRequestPayload() must have phoneNumber."

    throws

    "AuthenticateUserInput::getRequestPayload() must have firstName."

    throws

    "AuthenticateUserInput::getRequestPayload() must have lastName."

    Parameters

    Returns Promise<any>

createAddToCartInput

  • Create a default AddToCartInput object.

    Returns AddToCartInput

createAssetToBasketInput

  • Create a default AssetToBasketInput object.

    Returns AssetToBasketInput

createAuthenticateUserInput

  • Create a default AuthenticateUserInput object.

    Returns AuthenticateUserInput

createGetItemsInCartInput

  • Create a default GetItemsInCartInput object.

    Returns GetItemsInCartInput

createGetOfferInput

  • Create a default GetOfferInput object.

    Returns GetOfferInput

createGetOffersInput

  • Create a default createGetOffersInput object.

    Returns GetOffersInput

createSaveCartInput

  • Create a default SaveCartInput object.

    Returns SaveCartInput

createSignOutUserInput

  • Create a default createSignOutUserInput object.

    Returns SignOutUserInput

createSubmitOrderInput

  • Create a default SubmitOrderInput object.

    Returns SubmitOrderInput

createUpdateBillingDetailsInput

  • Create a default UpdateBillingDetailsInput object.

    Returns UpdateBillingDetailsInput

createUpdateItemsInCartInput

  • Create a default UpdateItemsInCartInput object.

    Returns UpdateItemsInCartInput

createValidateOfferInput

  • Create a default ValidateOfferInput object.

    Returns ValidateOfferInput

    ValidateOfferInput default ValidateOfferInput.

fire

  • fire(eventName: any, action: any, payload: any): void
  • Fires an event to listeners.

    example

    firing the event

    this.digitalCommerceSDK.fire("event-name",action,payloadObject);

    Parameters

    • eventName: any

      Name of the event to fire.

    • action: any

      Name of the event to fire.

    • payload: any

      Payload of the event to fire.

    Returns void

getCurrencyDetails

  • getCurrencyDetails(): Promise<void>
  • Gets the currency details from Server SDK

    Returns Promise<void>

getFilteredOffersList

  • Proxy getFilteredOffersList method calls Server SDK getFilteredOffersList method with given input

    throws

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

    throws

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

    Parameters

    Returns Promise<any>

getItemsInCart

  • Proxy getItemsInCart method calls Server SDK getItemsInCart method with given input

    throws

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

    throws

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

    Parameters

    Returns Promise<any>

getOffer

  • Proxy getFilteredOffersList method calls Server SDK getFilteredOffersList method with given input

    throws

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

    throws

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

    Parameters

    Returns Promise<any>

getOffers

  • Proxy getOffers method calls Server SDK getOffers method with given input

    throws

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

    throws

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

    Parameters

    Returns Promise<any>

getPromotions

  • Proxy getPromotions method calls Server SDK getPromotions method with given input

    throws

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

    throws

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

    Parameters

    Returns Promise<any>

getSelectedOffer

  • getSelectedOffer(offerCode: string, parseOffer?: boolean, input?: any, secureServerEndPointUrl?: string): Promise<any>
  • Proxy getSelectedOffer method calls Server SDK getSelectedOffer method to get the configured offer bundle

    Parameters

    • offerCode: string
    • Optional parseOffer: boolean
    • Optional input: any
    • Optional secureServerEndPointUrl: string

    Returns Promise<any>

Private invokeAPI

  • Returns a API call response.

    Parameters

    Returns Promise<any>

register

  • register(eventName: any, callbackobj: any): void
  • Registers a callback for an event

    example
    example

    registering the event

    this.digitalCommerceSDK.register("event-name",{action: this.callbackFunction.bind(this)});

    Parameters

    • eventName: any

      Name of the event to listen for.

    • callbackobj: any

      Contains callback function.

    Returns void

saveCart

  • Proxy saveCart method calls Server SDK saveCart method with given input

    throws

    "SaveCartInput::getRequestPayload() must have catalogCode."

    throws

    "SaveCartInput::getRequestPayload() must have cartContextKey."

    Parameters

    Returns Promise<any>

signOutUser

  • Proxy authenticateUser method calls Server SDK signIn method with given input

    throws

    "SignOutUserInput::getAnonymousRestUrl() must have secureServerUrl."

    Parameters

    Returns Promise<any>

submitOrder

  • Proxy submitOrder method calls Server SDK submitOrder method with given input

    throws

    "SubmitOrderInput::getRequestPayload() must have catalogCode."

    throws

    "SubmitOrderInput::getRequestPayload() must have cartContextKey."

    Parameters

    Returns Promise<any>

unregister

  • unregister(eventName: any, callbackobj: any): void
  • Unregisters a callback for an event

    example

    unregistering the event

    this.digitalCommerceSDK.unregiter("event-name",{action: this.callbackFunction.bind(this)});

    Parameters

    • eventName: any

      Name of the event to unregister from.

    • callbackobj: any

      Contains callback function.

    Returns void

updateBillingDetails

  • Proxy updateBillingDetails method calls Server SDK updateBillingDetails method with given input

    throws

    "UpdateBillingDetailsInput::getRequestPayload() must have billingCity."

    throws

    "UpdateBillingDetailsInput::getRequestPayload() must have billingState."

    throws

    "UpdateBillingDetailsInput::getRequestPayload() must have billingAddress."

    throws

    "UpdateBillingDetailsInput::getRequestPayload() must have billingZipCode."

    throws

    "UpdateBillingDetailsInput::getRequestPayload() must have shippingCity."

    throws

    "UpdateBillingDetailsInput::getRequestPayload() must have shippingState."

    throws

    "UpdateBillingDetailsInput::getRequestPayload() must have shippingAddress."

    throws

    "UpdateBillingDetailsInput::getRequestPayload() must have shippingZipCode."

    Parameters

    Returns Promise<any>

updateItemsInCart

  • Proxy updateItemsInCart method calls Server SDK updateItemsInCart method with given input

    throws

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

    throws

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

    throws

    "UpdateItemsInCart::getRequestPayload() must have bundleContextKey"

    throws

    "UpdateItemsInCart::getRequestPayload() must have lineItemKey."

    Parameters

    Returns Promise<any>

validateOffer

  • Proxy validateOffer method calls Server SDK validateOffer method with given input

    throws

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

    throws

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

    Parameters

    Returns Promise<any>

version

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

    Returns string

    Returns SDK version number as string

Static createConfig

  • Create a DigitalCommerceProxyConfig object that consists of a secureServerUrl and a DataSourceService.

    example
    
    // Instantiate DigitalCommerceProxyConfig
    const digitalCommerceProxyConfig = VlocitySDK.digitalcommerce.createConfig();
    
    // Instantiate the SDK itself
    const digitalCommerce = VlocitySDK.digitalcommerce.getInstance(digitalCommerceProxyConfig);

    Parameters

    • config: any

    Returns DigitalCommerceProxyConfig

    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 DigitalCommerceProxySDKConfig
    const digitalCommerceProxyConfig = VlocitySDK.digitalcommerce.createConfig();
    
    // Instantiate the SDK itself
    const digitalCommerce = VlocitySDK.digitalcommerce.getInstance(digitalCommerceProxyConfig);
    
    Note:
    digitalCommerce is a Singleton object.  Calling getInstance(digitalCommerceProxyConfig) repeatedly will return the same instance instantiated the first time when getInstance(digitalCommerceProxyConfig) was called.
    
    // To instantiate a new instance of digitalCommerce, set create to true in the digitalCommerceProxyConfig object:
    digitalCommerceProxyConfig.create = true;
    digitalCommerce = VlocitySDK.digitalcommerce.getInstance(digitalCommerceProxyConfig);
    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 DigitalCommerceProxy

    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