287d536fa75de9877880faf1e09737f729768408
[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 _0xd05a=['info','result','catch','util','moment','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','request','then','Automation,\x20%s,\x20%s','debug','Automation,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message'];(function(_0x57b54c,_0x54ce0d){var _0x59cc19=function(_0xa33bc6){while(--_0xa33bc6){_0x57b54c['push'](_0x57b54c['shift']());}};_0x59cc19(++_0x54ce0d);}(_0xd05a,0x143));var _0xad05=function(_0x3d97ae,_0x1afe32){_0x3d97ae=_0x3d97ae-0x0;var _0x262043=_0xd05a[_0x3d97ae];return _0x262043;};'use strict';var _=require('lodash');var util=require(_0xad05('0x0'));var moment=require(_0xad05('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xad05('0x2'));var logger=require(_0xad05('0x3'))(_0xad05('0x4'));var config=require(_0xad05('0x5'));var jayson=require(_0xad05('0x6'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x39ddaf,_0x45303c,_0xd12d76){return new BPromise(function(_0x565f85,_0x17ec26){return client[_0xad05('0x7')](_0x39ddaf,_0xd12d76)[_0xad05('0x8')](function(_0x573acb){logger['info'](_0xad05('0x9'),_0x45303c,'request\x20sent');logger[_0xad05('0xa')](_0xad05('0xb'),_0x45303c,_0xad05('0xc'),JSON[_0xad05('0xd')](_0x573acb));if(_0x573acb[_0xad05('0xe')]){if(_0x573acb[_0xad05('0xe')][_0xad05('0xf')]===0x1f4){logger[_0xad05('0xe')](_0xad05('0x9'),_0x45303c,_0x573acb[_0xad05('0xe')]['message']);return _0x17ec26(_0x573acb[_0xad05('0xe')]['message']);}logger[_0xad05('0xe')]('Automation,\x20%s,\x20%s',_0x45303c,_0x573acb[_0xad05('0xe')][_0xad05('0x10')]);return _0x565f85(_0x573acb[_0xad05('0xe')]['message']);}else{logger[_0xad05('0x11')]('Automation,\x20%s,\x20%s',_0x45303c,_0xad05('0xc'));_0x565f85(_0x573acb[_0xad05('0x12')][_0xad05('0x10')]);}})[_0xad05('0x13')](function(_0x43ab03){logger[_0xad05('0xe')]('Automation,\x20%s,\x20%s',_0x45303c,_0x43ab03);_0x17ec26(_0x43ab03);});});}