cba9316b095c1e783ff9d4d6ee8b9cb8e0f8bc1c
[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 _0x7e31=['randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client','request','then','info','request\x20sent','Automation,\x20%s,\x20%s,\x20%s','stringify','error','message','Automation,\x20%s,\x20%s','lodash','util','moment','bluebird'];(function(_0x5c786d,_0x52d7bb){var _0x455661=function(_0x249afb){while(--_0x249afb){_0x5c786d['push'](_0x5c786d['shift']());}};_0x455661(++_0x52d7bb);}(_0x7e31,0x6e));var _0x17e3=function(_0x475aa9,_0x439aab){_0x475aa9=_0x475aa9-0x0;var _0x360bbc=_0x7e31[_0x475aa9];return _0x360bbc;};'use strict';var _=require(_0x17e3('0x0'));var util=require(_0x17e3('0x1'));var moment=require(_0x17e3('0x2'));var BPromise=require(_0x17e3('0x3'));var rs=require(_0x17e3('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x17e3('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x17e3('0x6'));var config=require(_0x17e3('0x7'));var jayson=require(_0x17e3('0x8'));var client=jayson[_0x17e3('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1395ce,_0x46794a,_0x384e99){return new BPromise(function(_0x26328f,_0x407dfc){return client[_0x17e3('0xa')](_0x1395ce,_0x384e99)[_0x17e3('0xb')](function(_0x2db52c){logger[_0x17e3('0xc')]('Automation,\x20%s,\x20%s',_0x46794a,_0x17e3('0xd'));logger['debug'](_0x17e3('0xe'),_0x46794a,_0x17e3('0xd'),JSON[_0x17e3('0xf')](_0x2db52c));if(_0x2db52c[_0x17e3('0x10')]){if(_0x2db52c['error']['code']===0x1f4){logger[_0x17e3('0x10')]('Automation,\x20%s,\x20%s',_0x46794a,_0x2db52c[_0x17e3('0x10')][_0x17e3('0x11')]);return _0x407dfc(_0x2db52c['error'][_0x17e3('0x11')]);}logger[_0x17e3('0x10')](_0x17e3('0x12'),_0x46794a,_0x2db52c['error'][_0x17e3('0x11')]);return _0x26328f(_0x2db52c[_0x17e3('0x10')][_0x17e3('0x11')]);}else{logger['info'](_0x17e3('0x12'),_0x46794a,'request\x20sent');_0x26328f(_0x2db52c['result'][_0x17e3('0x11')]);}})['catch'](function(_0x504295){logger['error']('Automation,\x20%s,\x20%s',_0x46794a,_0x504295);_0x407dfc(_0x504295);});});}