ea3b98ab7153ccab9fce1094de27749886318816
[motion2.git] / server / api / cmHopperFinal / cmHopperFinal.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 _0x98cb=['../../config/utils','../../config/logger','../../config/environment','http','then','info','CmHopperFinal,\x20%s,\x20%s','request\x20sent','debug','CmHopperFinal,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','CmHopperFinal','options','raw','CreateCmHopperFinal','lodash','util','moment','bluebird','ioredis'];(function(_0x120246,_0x3db1a9){var _0x38faeb=function(_0x344122){while(--_0x344122){_0x120246['push'](_0x120246['shift']());}};_0x38faeb(++_0x3db1a9);}(_0x98cb,0x1db));var _0xb98c=function(_0xc14a86,_0x5ccae1){_0xc14a86=_0xc14a86-0x0;var _0x20484c=_0x98cb[_0xc14a86];return _0x20484c;};'use strict';var _=require(_0xb98c('0x0'));var util=require(_0xb98c('0x1'));var moment=require(_0xb98c('0x2'));var BPromise=require(_0xb98c('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb98c('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xb98c('0x5'));var logger=require(_0xb98c('0x6'))('rpc');var config=require(_0xb98c('0x7'));var jayson=require('jayson/promise');var client=jayson['client'][_0xb98c('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x43ea01,_0x520438,_0x23dc04){return new BPromise(function(_0x459215,_0x428db2){return client['request'](_0x43ea01,_0x23dc04)[_0xb98c('0x9')](function(_0x49559a){logger[_0xb98c('0xa')](_0xb98c('0xb'),_0x520438,_0xb98c('0xc'));logger[_0xb98c('0xd')](_0xb98c('0xe'),_0x520438,_0xb98c('0xc'),JSON[_0xb98c('0xf')](_0x49559a));if(_0x49559a['error']){if(_0x49559a[_0xb98c('0x10')]['code']===0x1f4){logger[_0xb98c('0x10')](_0xb98c('0xb'),_0x520438,_0x49559a[_0xb98c('0x10')][_0xb98c('0x11')]);return _0x428db2(_0x49559a[_0xb98c('0x10')]['message']);}logger[_0xb98c('0x10')](_0xb98c('0xb'),_0x520438,_0x49559a['error'][_0xb98c('0x11')]);return _0x459215(_0x49559a['error']['message']);}else{logger[_0xb98c('0xa')](_0xb98c('0xb'),_0x520438,_0xb98c('0xc'));_0x459215(_0x49559a[_0xb98c('0x12')][_0xb98c('0x11')]);}})[_0xb98c('0x13')](function(_0x34fac1){logger['error'](_0xb98c('0xb'),_0x520438,_0x34fac1);_0x428db2(_0x34fac1);});});}exports['CreateCmHopperFinal']=function(_0x423e68){var _0x52e6e3=this;return new Promise(function(_0x5d6c08,_0x16c1c2){return db[_0xb98c('0x14')]['create'](_0x423e68['body'],{'raw':_0x423e68[_0xb98c('0x15')]?_0x423e68['options'][_0xb98c('0x16')]===undefined?!![]:![]:!![]})[_0xb98c('0x9')](function(_0x4645ee){logger['info'](_0xb98c('0x17'),_0x423e68);logger[_0xb98c('0xd')](_0xb98c('0x17'),_0x423e68,JSON[_0xb98c('0xf')](_0x4645ee));_0x5d6c08(_0x4645ee);})[_0xb98c('0x13')](function(_0x4ca603){logger[_0xb98c('0x10')](_0xb98c('0x17'),_0x4ca603['message'],_0x423e68);_0x16c1c2(_0x52e6e3['error'](0x1f4,_0x4ca603[_0xb98c('0x11')]));});});};