ff8c8b1d37f84060b598894d128c19c19a9352cf
[motion2.git] / server / api / automation / automation.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 _0x5236=['http','request','then','info','Automation,\x20%s,\x20%s','request\x20sent','Automation,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client'];(function(_0x2e341b,_0x4e9059){var _0x41a33f=function(_0x388da8){while(--_0x388da8){_0x2e341b['push'](_0x2e341b['shift']());}};_0x41a33f(++_0x4e9059);}(_0x5236,0x109));var _0x6523=function(_0x322a7c,_0x45b6e3){_0x322a7c=_0x322a7c-0x0;var _0x5a95f6=_0x5236[_0x322a7c];return _0x5a95f6;};'use strict';var _=require(_0x6523('0x0'));var util=require(_0x6523('0x1'));var moment=require(_0x6523('0x2'));var BPromise=require(_0x6523('0x3'));var rs=require(_0x6523('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6523('0x5'))['db'];var utils=require(_0x6523('0x6'));var logger=require('../../config/logger')(_0x6523('0x7'));var config=require(_0x6523('0x8'));var jayson=require(_0x6523('0x9'));var client=jayson[_0x6523('0xa')][_0x6523('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x53548c,_0x32e99c,_0x17b335){return new BPromise(function(_0x24550b,_0x514e29){return client[_0x6523('0xc')](_0x53548c,_0x17b335)[_0x6523('0xd')](function(_0x2afd63){logger[_0x6523('0xe')](_0x6523('0xf'),_0x32e99c,_0x6523('0x10'));logger['debug'](_0x6523('0x11'),_0x32e99c,_0x6523('0x10'),JSON[_0x6523('0x12')](_0x2afd63));if(_0x2afd63[_0x6523('0x13')]){if(_0x2afd63[_0x6523('0x13')]['code']===0x1f4){logger[_0x6523('0x13')](_0x6523('0xf'),_0x32e99c,_0x2afd63['error'][_0x6523('0x14')]);return _0x514e29(_0x2afd63['error']['message']);}logger[_0x6523('0x13')](_0x6523('0xf'),_0x32e99c,_0x2afd63[_0x6523('0x13')][_0x6523('0x14')]);return _0x24550b(_0x2afd63[_0x6523('0x13')][_0x6523('0x14')]);}else{logger['info'](_0x6523('0xf'),_0x32e99c,'request\x20sent');_0x24550b(_0x2afd63[_0x6523('0x15')][_0x6523('0x14')]);}})[_0x6523('0x16')](function(_0x34acbe){logger[_0x6523('0x13')](_0x6523('0xf'),_0x32e99c,_0x34acbe);_0x514e29(_0x34acbe);});});}