1.0.6 • Published 7 years ago
dhl-core v1.0.6
dhl-core
Create your DHL(Dui Hua Liu) services on Web.
📦 Install
npm install dhl-core --saveyarn add dhl-core<script src="https://dhl-sdk.oss-cn-beijing.aliyuncs.com/web_sdk/1.0.0/dhl.js"></script>🔨 Usage
from node_modules
import { DHL } from 'dhl-core';
const client = new DHL({
agentId: '<your agent id>',
agentName: '<your agent name>'
});from CDN
<script src="https://dhl-sdk.oss-cn-beijing.aliyuncs.com/web_sdk/1.0.0/dhl.js"></script>
<script>
var client = new DHL({
agentId: '<your agent id>',
agentName: '<your agent name>'
});
</script>🌈 Methods
- async verify(app: DHLAppInfo, callback?: (token: string) => void);
Get authentication token.interface DHLAppInfo {
appId: string;
appKey: string;
appSecret: string;
}- connectWebsocket(params: DHLConnectParams, onMessage: (message: string, messageType: string, res: any) => void, onOpen?: () => void, onClose?: () => void, onError?: (error: any) => void)
Connect Websocket and listen messages from server.interface DHLConnectParams {
userId: string;
isCustomerService: boolean;
userName?: string;
}- send(params: SendMessageParamsInfo, callback: (message: string, messageType: string, res: any) => void)
Send messages.interface SendMessageParamsInfo {
message: string;
messageContentType: dhlmixer.MessageContentType;
forceHandleManually: boolean;
}uploadImage(file: any, callback: (res: any) => void)
Upload an image and get the URI
✨ Features
- Written in TypeScript with complete define types
License
MIT License.