4c5faf3732cdf43d397bee6049d5a64a9827bbaf
[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 _0x859b=['then','info','CannedAnswer,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','catch','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','request'];(function(_0x912113,_0x11caa6){var _0x548c32=function(_0x224ae9){while(--_0x224ae9){_0x912113['push'](_0x912113['shift']());}};_0x548c32(++_0x11caa6);}(_0x859b,0x14d));var _0xb859=function(_0x3f9ed3,_0x1c318a){_0x3f9ed3=_0x3f9ed3-0x0;var _0x433841=_0x859b[_0x3f9ed3];return _0x433841;};'use strict';var _=require(_0xb859('0x0'));var util=require(_0xb859('0x1'));var moment=require(_0xb859('0x2'));var BPromise=require(_0xb859('0x3'));var rs=require(_0xb859('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb859('0x5'))['db'];var utils=require(_0xb859('0x6'));var logger=require('../../config/logger')(_0xb859('0x7'));var config=require(_0xb859('0x8'));var jayson=require(_0xb859('0x9'));var client=jayson[_0xb859('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x11998a,_0x3c111c,_0x5b5ecc){return new BPromise(function(_0x47f0fe,_0x5d2bf2){return client[_0xb859('0xb')](_0x11998a,_0x5b5ecc)[_0xb859('0xc')](function(_0x28aebf){logger[_0xb859('0xd')](_0xb859('0xe'),_0x3c111c,'request\x20sent');logger[_0xb859('0xf')]('CannedAnswer,\x20%s,\x20%s,\x20%s',_0x3c111c,_0xb859('0x10'),JSON[_0xb859('0x11')](_0x28aebf));if(_0x28aebf[_0xb859('0x12')]){if(_0x28aebf[_0xb859('0x12')][_0xb859('0x13')]===0x1f4){logger[_0xb859('0x12')](_0xb859('0xe'),_0x3c111c,_0x28aebf[_0xb859('0x12')]['message']);return _0x5d2bf2(_0x28aebf[_0xb859('0x12')]['message']);}logger[_0xb859('0x12')](_0xb859('0xe'),_0x3c111c,_0x28aebf['error'][_0xb859('0x14')]);return _0x47f0fe(_0x28aebf[_0xb859('0x12')][_0xb859('0x14')]);}else{logger['info'](_0xb859('0xe'),_0x3c111c,'request\x20sent');_0x47f0fe(_0x28aebf[_0xb859('0x15')][_0xb859('0x14')]);}})[_0xb859('0x16')](function(_0x510f58){logger[_0xb859('0x12')](_0xb859('0xe'),_0x3c111c,_0x510f58);_0x5d2bf2(_0x510f58);});});}