4.0.18 • Published 19 days ago

demo-dev-sdk v4.0.18

Weekly downloads
-
License
ISC
Repository
-
Last release
19 days ago

AuroCX SDK

The AuroCX SDK package enables AuroCX products to be added to your applications. Through this package, an AuroCX product is exported as a wrapped classes that is responsible for initializing shared cross-product functionalities and using specific AuroCX products.

Installation

npm install aurocx-sdk

Usage

Prerequisite:

  1. Create AuroCx connect instance by signing up with Aurocx
  2. API key received while onboarding merchant.
  3. Adding your origin URL to the list of approved origins.

Use the following steps to add AuroCX widget to your application:

  1. Import AuroCx from the AuroCX SDK and init a instance.
import { AuroCx } from "aurocx-sdk";

const config={
    apiKey: "your-api-key",         // Api key
    env: "dev",                     // Environment, default 'dev'
    mountOptions: {
      float: true,                  // Default 'true'
      containerId: "html-div-id",   // Container to mount widget in, 
                                    // if not provided it would be mounted to body.
      defaultWidgetSize: "DOCKED"   // Default "DOCKED"
    },
    onLoad: ()=>{ console.log("Initiated...") } // Callback Function when loaded.
}

const auroCXInstane = new AuroCx(config);
  1. Defining the config of AuroCx.

    • apiKey (required) - Use the api key received while onboarding a new merchant in AuroCX.
    • env: "prod" | "uat"| "qa" | "dev" (required) - Environment to be used for api key.
    • mountOptions (Optional) - The integration options to display widget in your app.

      • float: Boolean (Optional) - Defines the behaviour of the widget either to display in a specific location of always visible on screen when initiated, Default true.

      • containerId: String (Optional) - Use this option to mount widget in specified div container, if not specified the widget will be mounted in body tag.

      • defaultWidgetSize: "DOCKED" | "HIDDEN" (Optional) - Defines the default view size of widget after init if hidden widget will only appear on connect events(chat/call), Default "DOCKED".

    • onLoad: Function (Optional) - This is the callback function which will be called after widget is initiated.

Interact with AuroCX instance

Connect with contact

Attributes

    // Required attributes
    id:string, 
    firstName:string,
    lastName:string,

    // Optional attributes
    middleName?:string,
    email?:string,
    mobileNumber?:string,
    phoneNumber?:string,
    address?:string,
    avatarUrl?:string,

To connect to specific customer use the connectCX method provided by SDK to initiate a connection.

import { connectCX } from "aurocx-sdk";

connectCX({
    id:"1",
    firstName: "John",
    middleName: "A",
    lastName: "Doe",
    phoneNumber: "+12323342443",
    mobileNumber: "+12323342443",
    email: "john@example.com",
    address: "addres",
    avatarUrl: "url",
    });

Instance Methods

const auroCXInstane = new AuroCx(config);

// connect with specific customer
auroCXInstane.connectCX({
    id:"1",
    firstName: "John",
    middleName: "A",
    lastName: "Doe",
    phoneNumber: "+12323342443",
    mobileNumber: "+12323342443",
    email: "john@example.com",
    address: "addres",
    avatarUrl: "url",
});

// Terminate method will end the connection with AuroCx widget instance.
auroCXInstane.terminate();

Note: Please make sure to terminate instance when user access is revoked

  • Below will take effect if config.float is not set to false.
// Minimizes the floating widget 
auroCXInstane.minimize();

// Maximizes the floating widget 
auroCXInstane.minimize();

Api Client

  1. Import ApiClient from the AuroCX SDK and init a instance.
import { ApiClient } from "aurocx-sdk";

const config={
    apiKey: "your-api-key",         // Api key
    env: "dev",                     // Environment, default 'dev'
}

const apiClient = new ApiClient(config)
  1. Defining the config of AuroCx.
    • apiKey (required) - Use the api key received while from AuroCX.
    • env: "prod" | "uat"| "qa" | "dev" (required) - Environment to be used for api.

Create Merchant

Attributes

// Required attributes
firstName: string,
lastName: string,
email: string,
companyPhone: string,
companyName: string,
timeZone: string,

// Optional attributes
addressLine1?: string,
addressLine2?: string,
country?: string,
state?: string,
city?: string,
postalCode?: number

Use createMerchant method provided in ApiClient instance to create new merchant in AuroCX.

await apiClient.createMerchant("resellerId", {
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@gmail.com",
    "companyPhone": "+919191919191",
    "companyName": "AuroCX",
    "timeZone": "Asia/Calcutta",
    "addressLine1": "address line 1",
    "addressLine2": "address line 1",
    "country": "country name",
    "state": "state name",
    "city": "ity name",
    "postalCode": 12345
});

Note: method will return merchant id and api key

Get Merchant API key

Fetch merchant api key using getMerchantKey method provided in ApiClient instance.

await apiClient.getMerchantKey("resellerId", "merchantId");

Get merchant details

Get merchant details using the getMerchantDetails method provided in ApiClient instance.

await apiClient.getMerchantDetails("resellerId", "merchantId");
4.0.18

19 days ago

4.0.16

23 days ago