Built motion from commit (unavailable).|2.0.75
[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 _0x9082=['request','info','Automation,\x20%s,\x20%s','debug','Automation,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','util','moment','bluebird','../../mysqldb','../../config/logger','jayson/promise','client'];(function(_0x49fcfc,_0x104175){var _0x4ab162=function(_0x2fb28b){while(--_0x2fb28b){_0x49fcfc['push'](_0x49fcfc['shift']());}};_0x4ab162(++_0x104175);}(_0x9082,0x161));var _0x2908=function(_0x5af59e,_0x3771c1){_0x5af59e=_0x5af59e-0x0;var _0x4240df=_0x9082[_0x5af59e];return _0x4240df;};'use strict';var _=require('lodash');var util=require(_0x2908('0x0'));var moment=require(_0x2908('0x1'));var BPromise=require(_0x2908('0x2'));var rs=require('randomstring');var fs=require('fs');var db=require(_0x2908('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x2908('0x4'))('rpc');var config=require('../../config/environment');var jayson=require(_0x2908('0x5'));var client=jayson[_0x2908('0x6')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5f56ef,_0x426c4e,_0x4df611){return new BPromise(function(_0x2d1a65,_0x2d8a79){return client[_0x2908('0x7')](_0x5f56ef,_0x4df611)['then'](function(_0x8773cc){logger[_0x2908('0x8')](_0x2908('0x9'),_0x426c4e,'request\x20sent');logger[_0x2908('0xa')](_0x2908('0xb'),_0x426c4e,'request\x20sent',JSON[_0x2908('0xc')](_0x8773cc));if(_0x8773cc[_0x2908('0xd')]){if(_0x8773cc[_0x2908('0xd')][_0x2908('0xe')]===0x1f4){logger['error']('Automation,\x20%s,\x20%s',_0x426c4e,_0x8773cc['error']['message']);return _0x2d8a79(_0x8773cc[_0x2908('0xd')][_0x2908('0xf')]);}logger[_0x2908('0xd')](_0x2908('0x9'),_0x426c4e,_0x8773cc[_0x2908('0xd')][_0x2908('0xf')]);return _0x2d1a65(_0x8773cc[_0x2908('0xd')][_0x2908('0xf')]);}else{logger[_0x2908('0x8')](_0x2908('0x9'),_0x426c4e,'request\x20sent');_0x2d1a65(_0x8773cc[_0x2908('0x10')][_0x2908('0xf')]);}})[_0x2908('0x11')](function(_0x22905a){logger[_0x2908('0xd')](_0x2908('0x9'),_0x426c4e,_0x22905a);_0x2d8a79(_0x22905a);});});}