client-api.js
2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**
* 客服用户端 api
*
* @author: liqi <qi.li@yoho.cn>
* @date: 2016/11/4
*/
'use strict';
let config = require('../../../config/common');
let api = new global.yoho.ApiBase(config.domains.imCs, {
name: 'imCs',
cache: global.yoho.cache,
useCache: false
});
// api urls
let urls = {
qas: '/api/helper/queryAllHelper',
csSetting: '/api/cs/queryByType',
makeEval: '/api/evalute/saveEvalute',
lastTen: '/api/order/queryLastTenOrder',
leaveMsg: '/api/leavemessage/saveLeavemessage',
msgHistory: '/api/conversationMessage/pageList',
evalReason: '/api/evalute/queryReasonByConversationId'
};
/**
* 用户最近10笔订单
* @function getLastTenOrders
* @param { string } encryptedUid 用户ID
* @return { Object } 最近10条订单
*/
const getLastTenOrders = (encryptedUid) => {
return api.post(urls.lastTen, {
encryptedUid
});
};
/**
* 常见问题
* @function getQas
* @return { Object } 问答列表
*/
const getQas = () => {
return api.post(urls.qas, {});
};
/**
* 客服设置
* @param { number } type
* @return { Object } 客服设置
*/
const getCsSetting = (type) => {
return api.get(urls.csSetting, {
type
});
};
/**
* 最近聊天记录
* @function getMsgHistory
* @param { string } encryptedUid 用户id
* @param { string } endTime 截止时间
* @return { Array } 历史聊天记录
*/
const getMsgHistory = (encryptedUid, endTime) => {
let params = {
encryptedUid
};
if (endTime) {
params.endTime = endTime;
}
return api.post(urls.msgHistory, params, {timeout: 5000});
};
/**
* 保存评价
* @param params
* @returns {*}
*/
const saveEval = (params) => {
return api.post(urls.makeEval, params);
};
/**
* 评价原因
* @param cvId
* @returns {*}
*/
const queryReason = (cvId) => {
const params = {
conversationId: cvId
};
return api.post(urls.evalReason, params);
};
/**
* 留言
* @param content 内容
* @param encId 加密UID
* @param cvId 会话ID
* @returns {*}
*/
const saveMessage = (content, encId, cvId) => {
const params = {
content,
encryptedUid: encId,
conversationId: cvId
};
return api.post(urls.leaveMsg, params);
};
module.exports = {
getQas,
queryReason,
saveMessage,
getCsSetting,
saveEval,
getMsgHistory,
getLastTenOrders
};