fb08063f2ebcd5248f13c576f7e5825fb17d6a6e
[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 _0x5050=['../../config/logger','rpc','jayson/promise','client','http','request','then','info','debug','request\x20sent','stringify','error','code','Automation,\x20%s,\x20%s','message','result','catch','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x58886b,_0x5612b6){var _0x4f5360=function(_0x46d4fb){while(--_0x46d4fb){_0x58886b['push'](_0x58886b['shift']());}};_0x4f5360(++_0x5612b6);}(_0x5050,0x10e));var _0x0505=function(_0x2330ea,_0x93ba71){_0x2330ea=_0x2330ea-0x0;var _0x4c7533=_0x5050[_0x2330ea];return _0x4c7533;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x0505('0x0'));var BPromise=require(_0x0505('0x1'));var rs=require(_0x0505('0x2'));var fs=require('fs');var Redis=require(_0x0505('0x3'));var db=require(_0x0505('0x4'))['db'];var utils=require(_0x0505('0x5'));var logger=require(_0x0505('0x6'))(_0x0505('0x7'));var config=require('../../config/environment');var jayson=require(_0x0505('0x8'));var client=jayson[_0x0505('0x9')][_0x0505('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x136f9,_0x4fdc48,_0x3c4157){return new BPromise(function(_0x32d194,_0x6ce746){return client[_0x0505('0xb')](_0x136f9,_0x3c4157)[_0x0505('0xc')](function(_0x5c6c2b){logger[_0x0505('0xd')]('Automation,\x20%s,\x20%s',_0x4fdc48,'request\x20sent');logger[_0x0505('0xe')]('Automation,\x20%s,\x20%s,\x20%s',_0x4fdc48,_0x0505('0xf'),JSON[_0x0505('0x10')](_0x5c6c2b));if(_0x5c6c2b[_0x0505('0x11')]){if(_0x5c6c2b[_0x0505('0x11')][_0x0505('0x12')]===0x1f4){logger[_0x0505('0x11')](_0x0505('0x13'),_0x4fdc48,_0x5c6c2b['error'][_0x0505('0x14')]);return _0x6ce746(_0x5c6c2b['error'][_0x0505('0x14')]);}logger[_0x0505('0x11')](_0x0505('0x13'),_0x4fdc48,_0x5c6c2b[_0x0505('0x11')]['message']);return _0x32d194(_0x5c6c2b[_0x0505('0x11')][_0x0505('0x14')]);}else{logger['info']('Automation,\x20%s,\x20%s',_0x4fdc48,'request\x20sent');_0x32d194(_0x5c6c2b[_0x0505('0x15')]['message']);}})[_0x0505('0x16')](function(_0x5de831){logger['error']('Automation,\x20%s,\x20%s',_0x4fdc48,_0x5de831);_0x6ce746(_0x5de831);});});}