demo-sdk-dev
v4.0.10
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
122
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
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'
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);
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
- 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");