client-api.js 1.48 KB
/**
 * 客服用户端 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 = {
    lastTen: '/api/order/queryLastTenOrder',
    msgHistory: '/api/conversationMessage/pageList',
    csSetting: '/api/cs/queryByType',
    qas: ''  // TODO  功能暂缓
};

/**
 * 用户最近10笔订单
 * @function getLastTenOrders
 * @param { string } encryptedUid 用户ID
 * @return { Object } 最近10条订单
 */
const getLastTenOrders = (encryptedUid, imgSize) => {
    return api.get(urls.lastTen, {
        method: '',
        encryptedUid,
        imgSize
    });
};

/**
 * 常见问题
 * @function getQas
 * @return { Object } 问答列表
 */
const getQas = () => {
    return api.get(urls.qas, {
        method: ''
    });
};

/**
 * 客服设置
 * @param { number } type
 * @return { Object } 客服设置
 */
const getCsSetting = (type) => {
    return api.get(urls.csSetting, {
        method: '',
        type
    });
};

/**
 * 最近聊天记录
 * @function getMsgHistory
 * @param { string } encryptedUid 用户id
 * @return { Array } 历史聊天记录
 */
const getMsgHistory = (encryptedUid) => {
    return api.get(urls.msgHistory, {
        encryptedUid,
        method: ''
    });
};

module.exports = {
    getQas,
    getCsSetting,
    getMsgHistory,
    getLastTenOrders
};