aurocx-sdk
v1.0.48
Published
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 p
Downloads
435
Readme
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@1.0.41
Usage
Prerequisite:
- Create AuroCx connect instance by signing up with Aurocx
- API key received while onboarding merchant.
- Adding your origin URL to the list of approved origins.
Use the following steps to add AuroCX widget to your application:
- 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'
usePortal: false // Flag for opening portal window, default false
themeOptions:{
colors:{
primary:"#004CFC", // primary color for widget
accent:"#ffffff" // Accent of the widget
},
fontFamily:"'Roboto', sans-serif" // font family
},
mountOptions: {
float: true, // Default 'true'
containerId: "<your-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.
onTerminate: ()=>{ console.log("Terminated") } // Callback Function when terminated.
}
const auroCXInstane = new AuroCx(config);
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.
usePortal : Boolean (Optional) - Defines the initializing behaviour as if to initialize widget in your application keep this falg as false, otheriwse when this flag is true the current widget do not initiates to connet with.
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".
themeOptions (Optional) - The theme color options to display widget in your app.
colors: Object (Optional)
- primary: string - Primary widget color to match your brand
- accent : string - accent color to match with your brand.
fontFamily: String (Optional) - Use this option to pass your font family to widget.
onLoad: Function (Optional) - This is the callback function which will be called after widget is initiated.
onTerminate: Function (Optional) - This is the callback function which will be called after widget is terminated.
Interact with auroCX instance
Connect with contact
Attributes
// Required attributes
id:string,
firstName:string,
lastName:string,
// Optional attributes
email?:string,
mobileNumber?:string,
phoneNumber?:string,
avatarUrl?:string,
addressLine1?: string,
addressLine2?: string,
country?: string,
state?: string,
city?: string,
postalCode?: number
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",
lastName: "Doe",
phoneNumber: "+12323342443",
mobileNumber: "+12323342443",
email: "john@example.com",
address: "addres",
avatarUrl: "https://example.com/img",
addressLine1: "123/4 Streets",
addressLine2: "Wall of Fame",
country: "US",
state: "NY",
city: "Torento",
postalCode: "12401"
});
Instance Methods
Connect with specific customer
Note: If contact syncing source is any CRM (e.g Salesforce, Zoho) then it's important to pass the CRM unique "id" as the "customer.id" to connectCX method else SDK would ask to sync contacts, if not sure use alternate method to connect.
const auroCXInstane = new AuroCx(config);
// connect with specific customer
auroCXInstane.connectCX({
id:"1",
firstName: "John",
lastName: "Doe",
phoneNumber: "+12323342443",
mobileNumber: "+12323342443",
email: "john@example.com",
avatarUrl: "https://example.com/img",
addressLine1: "123/4 Streets",
addressLine2: "Wall of Fame",
country: "US",
state: "NY",
city: "Torento",
postalCode: "12401"
});
// Terminate method will end the connection with AuroCx widget instance.
auroCXInstane.terminate();
Note: Multiple initiation of auroCx instance should be avoided.
Open workspace without specifying a customer
const auroCXInstane = new AuroCx(config);
// connect method to open workspace as floating modal.
auroCXInstane.connect();
Note: Please make sure to terminate instance when user access is revoked
Below will take effect if config.float is set to true.
// Minimizes the floating widget
auroCXInstane.minimize();
// Maximizes the floating widget
auroCXInstane.minimize();
auroCx Portal window.
Note : auroCx portal window would be used only for detailed access of your activity, setting, & enhance features.
Opening auroCx Portal window
- set the usePortal flag in config as true to launch the portal window.
import { AuroCx } from "aurocx-sdk";
const config={
apiKey: "your-api-key",
env: "dev",
usePortal: true // Flag for opening portal window, default false
// Set to true for launching portal window.
}
const auroCXInstane = new AuroCx(config);
Api Client
- 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)
- 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");