1cb6c889903a3ececb33dc7ca8cd4f31cf38dfa7
[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 _0x0137=['http','then','info','Automation,\x20%s,\x20%s','debug','Automation,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x3b231a,_0x53a00d){var _0x18d67a=function(_0x5e14c6){while(--_0x5e14c6){_0x3b231a['push'](_0x3b231a['shift']());}};_0x18d67a(++_0x53a00d);}(_0x0137,0x1d8));var _0x7013=function(_0x4287e9,_0x31f01c){_0x4287e9=_0x4287e9-0x0;var _0x2f8390=_0x0137[_0x4287e9];return _0x2f8390;};'use strict';var _=require(_0x7013('0x0'));var util=require(_0x7013('0x1'));var moment=require(_0x7013('0x2'));var BPromise=require(_0x7013('0x3'));var rs=require(_0x7013('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7013('0x5'))['db'];var utils=require(_0x7013('0x6'));var logger=require(_0x7013('0x7'))(_0x7013('0x8'));var config=require(_0x7013('0x9'));var jayson=require(_0x7013('0xa'));var client=jayson['client'][_0x7013('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x346a4d,_0x4e2460,_0x16c0c8){return new BPromise(function(_0x16dae3,_0x1b748c){return client['request'](_0x346a4d,_0x16c0c8)[_0x7013('0xc')](function(_0x551b8a){logger[_0x7013('0xd')](_0x7013('0xe'),_0x4e2460,'request\x20sent');logger[_0x7013('0xf')](_0x7013('0x10'),_0x4e2460,_0x7013('0x11'),JSON[_0x7013('0x12')](_0x551b8a));if(_0x551b8a[_0x7013('0x13')]){if(_0x551b8a[_0x7013('0x13')]['code']===0x1f4){logger[_0x7013('0x13')](_0x7013('0xe'),_0x4e2460,_0x551b8a[_0x7013('0x13')][_0x7013('0x14')]);return _0x1b748c(_0x551b8a[_0x7013('0x13')][_0x7013('0x14')]);}logger[_0x7013('0x13')](_0x7013('0xe'),_0x4e2460,_0x551b8a[_0x7013('0x13')][_0x7013('0x14')]);return _0x16dae3(_0x551b8a[_0x7013('0x13')]['message']);}else{logger['info'](_0x7013('0xe'),_0x4e2460,_0x7013('0x11'));_0x16dae3(_0x551b8a[_0x7013('0x15')][_0x7013('0x14')]);}})[_0x7013('0x16')](function(_0x48614e){logger['error'](_0x7013('0xe'),_0x4e2460,_0x48614e);_0x1b748c(_0x48614e);});});}