69179521f38728bc92fd1f1b81bac52322cd6d5e
[motion2.git] / server / api / cannedAnswer / cannedAnswer.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x283d=['catch','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','debug','CannedAnswer,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','CannedAnswer,\x20%s,\x20%s','message'];(function(_0x16a245,_0x38060e){var _0x38172c=function(_0x4107c4){while(--_0x4107c4){_0x16a245['push'](_0x16a245['shift']());}};_0x38172c(++_0x38060e);}(_0x283d,0x1e5));var _0xd283=function(_0x1e920c,_0x5340a8){_0x1e920c=_0x1e920c-0x0;var _0x414368=_0x283d[_0x1e920c];return _0x414368;};'use strict';var _=require('lodash');var util=require(_0xd283('0x0'));var moment=require('moment');var BPromise=require(_0xd283('0x1'));var rs=require(_0xd283('0x2'));var fs=require('fs');var Redis=require(_0xd283('0x3'));var db=require(_0xd283('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xd283('0x5'))(_0xd283('0x6'));var config=require(_0xd283('0x7'));var jayson=require(_0xd283('0x8'));var client=jayson[_0xd283('0x9')][_0xd283('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x368374,_0x58a0cc,_0x1fbe33){return new BPromise(function(_0x930050,_0x57d68a){return client[_0xd283('0xb')](_0x368374,_0x1fbe33)[_0xd283('0xc')](function(_0xf893cd){logger[_0xd283('0xd')]('CannedAnswer,\x20%s,\x20%s',_0x58a0cc,'request\x20sent');logger[_0xd283('0xe')](_0xd283('0xf'),_0x58a0cc,_0xd283('0x10'),JSON[_0xd283('0x11')](_0xf893cd));if(_0xf893cd['error']){if(_0xf893cd[_0xd283('0x12')]['code']===0x1f4){logger[_0xd283('0x12')](_0xd283('0x13'),_0x58a0cc,_0xf893cd[_0xd283('0x12')]['message']);return _0x57d68a(_0xf893cd[_0xd283('0x12')][_0xd283('0x14')]);}logger[_0xd283('0x12')](_0xd283('0x13'),_0x58a0cc,_0xf893cd[_0xd283('0x12')]['message']);return _0x930050(_0xf893cd[_0xd283('0x12')][_0xd283('0x14')]);}else{logger[_0xd283('0xd')](_0xd283('0x13'),_0x58a0cc,'request\x20sent');_0x930050(_0xf893cd['result'][_0xd283('0x14')]);}})[_0xd283('0x15')](function(_0x4a1e7c){logger[_0xd283('0x12')]('CannedAnswer,\x20%s,\x20%s',_0x58a0cc,_0x4a1e7c);_0x57d68a(_0x4a1e7c);});});}