5d2e1228831f3ab5da8894ef9d38b94eeb7cfcf9
[motion2.git] / server / api / cmHopperBlack / cmHopperBlack.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 _0xd4c4=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','request','info','CmHopperBlack,\x20%s,\x20%s','request\x20sent','debug','CmHopperBlack,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetCmHopperBlack','CmHopperBlack','findAll','options','raw','where','attributes','limit','map','include','model','then','stringify','UpdateCmHopperBlack','update','destroy','DestroyCmHopperBlack','lodash','util','moment','bluebird','randomstring'];(function(_0x5ebc04,_0x14a363){var _0x17845c=function(_0x360850){while(--_0x360850){_0x5ebc04['push'](_0x5ebc04['shift']());}};_0x17845c(++_0x14a363);}(_0xd4c4,0x9b));var _0x4d4c=function(_0x4ec3de,_0x1c67c4){_0x4ec3de=_0x4ec3de-0x0;var _0x37478a=_0xd4c4[_0x4ec3de];return _0x37478a;};'use strict';var _=require(_0x4d4c('0x0'));var util=require(_0x4d4c('0x1'));var moment=require(_0x4d4c('0x2'));var BPromise=require(_0x4d4c('0x3'));var rs=require(_0x4d4c('0x4'));var fs=require('fs');var Redis=require(_0x4d4c('0x5'));var db=require(_0x4d4c('0x6'))['db'];var utils=require(_0x4d4c('0x7'));var logger=require(_0x4d4c('0x8'))(_0x4d4c('0x9'));var config=require('../../config/environment');var jayson=require(_0x4d4c('0xa'));var client=jayson['client'][_0x4d4c('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x166d01,_0x12b4d1,_0x259fef){return new BPromise(function(_0x54adcf,_0x5bd9d5){return client[_0x4d4c('0xc')](_0x166d01,_0x259fef)['then'](function(_0xdf1ad4){logger[_0x4d4c('0xd')](_0x4d4c('0xe'),_0x12b4d1,_0x4d4c('0xf'));logger[_0x4d4c('0x10')](_0x4d4c('0x11'),_0x12b4d1,_0x4d4c('0xf'),JSON['stringify'](_0xdf1ad4));if(_0xdf1ad4[_0x4d4c('0x12')]){if(_0xdf1ad4[_0x4d4c('0x12')][_0x4d4c('0x13')]===0x1f4){logger[_0x4d4c('0x12')](_0x4d4c('0xe'),_0x12b4d1,_0xdf1ad4[_0x4d4c('0x12')][_0x4d4c('0x14')]);return _0x5bd9d5(_0xdf1ad4['error'][_0x4d4c('0x14')]);}logger[_0x4d4c('0x12')](_0x4d4c('0xe'),_0x12b4d1,_0xdf1ad4['error'][_0x4d4c('0x14')]);return _0x54adcf(_0xdf1ad4['error']['message']);}else{logger[_0x4d4c('0xd')](_0x4d4c('0xe'),_0x12b4d1,_0x4d4c('0xf'));_0x54adcf(_0xdf1ad4[_0x4d4c('0x15')][_0x4d4c('0x14')]);}})[_0x4d4c('0x16')](function(_0x2968e4){logger['error'](_0x4d4c('0xe'),_0x12b4d1,_0x2968e4);_0x5bd9d5(_0x2968e4);});});}exports[_0x4d4c('0x17')]=function(_0x266992){var _0x285546=this;return new Promise(function(_0x5c14aa,_0x19e55f){return db[_0x4d4c('0x18')][_0x4d4c('0x19')]({'raw':_0x266992[_0x4d4c('0x1a')]?_0x266992[_0x4d4c('0x1a')][_0x4d4c('0x1b')]===undefined?!![]:![]:!![],'where':_0x266992['options']?_0x266992[_0x4d4c('0x1a')][_0x4d4c('0x1c')]||null:null,'attributes':_0x266992[_0x4d4c('0x1a')]?_0x266992[_0x4d4c('0x1a')][_0x4d4c('0x1d')]||null:null,'limit':_0x266992[_0x4d4c('0x1a')]?_0x266992['options'][_0x4d4c('0x1e')]||null:null,'include':_0x266992[_0x4d4c('0x1a')]?_0x266992[_0x4d4c('0x1a')]['include']?_[_0x4d4c('0x1f')](_0x266992[_0x4d4c('0x1a')][_0x4d4c('0x20')],function(_0x5372a2){return{'model':db[_0x5372a2[_0x4d4c('0x21')]],'as':_0x5372a2['as'],'attributes':_0x5372a2[_0x4d4c('0x1d')],'include':_0x5372a2[_0x4d4c('0x20')]?_[_0x4d4c('0x1f')](_0x5372a2[_0x4d4c('0x20')],function(_0x1c2ea5){return{'model':db[_0x1c2ea5[_0x4d4c('0x21')]],'as':_0x1c2ea5['as'],'attributes':_0x1c2ea5[_0x4d4c('0x1d')],'include':_0x1c2ea5['include']?_['map'](_0x1c2ea5[_0x4d4c('0x20')],function(_0x2e7a6c){return{'model':db[_0x2e7a6c['model']],'as':_0x2e7a6c['as'],'attributes':_0x2e7a6c[_0x4d4c('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x4d4c('0x22')](function(_0x2e006e){logger[_0x4d4c('0xd')](_0x4d4c('0x17'),_0x266992);logger[_0x4d4c('0x10')](_0x4d4c('0x17'),_0x266992,JSON[_0x4d4c('0x23')](_0x2e006e));_0x5c14aa(_0x2e006e);})[_0x4d4c('0x16')](function(_0x5e35ac){logger['error'](_0x4d4c('0x17'),_0x5e35ac['message'],_0x266992);_0x19e55f(_0x285546['error'](0x1f4,_0x5e35ac[_0x4d4c('0x14')]));});});};exports[_0x4d4c('0x24')]=function(_0x155262){var _0x160daf=this;return new Promise(function(_0x11419b,_0x48d013){return db[_0x4d4c('0x18')][_0x4d4c('0x25')](_0x155262['body'],{'raw':_0x155262['options']?_0x155262[_0x4d4c('0x1a')][_0x4d4c('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x155262[_0x4d4c('0x1a')]?_0x155262[_0x4d4c('0x1a')][_0x4d4c('0x1c')]||null:null,'attributes':_0x155262[_0x4d4c('0x1a')]?_0x155262[_0x4d4c('0x1a')][_0x4d4c('0x1d')]||null:null,'limit':_0x155262[_0x4d4c('0x1a')]?_0x155262[_0x4d4c('0x1a')][_0x4d4c('0x1e')]||null:null})['then'](function(_0x3102c9){logger['info'](_0x4d4c('0x24'),_0x155262);logger[_0x4d4c('0x10')]('UpdateCmHopperBlack',_0x155262,JSON[_0x4d4c('0x23')](_0x3102c9));_0x11419b(_0x3102c9);})[_0x4d4c('0x16')](function(_0xa45d3){logger[_0x4d4c('0x12')](_0x4d4c('0x24'),_0xa45d3[_0x4d4c('0x14')],_0x155262);_0x48d013(_0x160daf[_0x4d4c('0x12')](0x1f4,_0xa45d3[_0x4d4c('0x14')]));});});};exports['DestroyCmHopperBlack']=function(_0x59bdcf){var _0x436617=this;return new Promise(function(_0x422349,_0x1f9178){return db['CmHopperBlack'][_0x4d4c('0x26')]({'where':_0x59bdcf[_0x4d4c('0x1a')]?_0x59bdcf[_0x4d4c('0x1a')]['where']||null:null})['then'](function(_0xd51775){logger[_0x4d4c('0xd')](_0x4d4c('0x27'),_0x59bdcf);logger[_0x4d4c('0x10')](_0x4d4c('0x27'),_0x59bdcf,JSON[_0x4d4c('0x23')](_0xd51775));_0x422349(_0xd51775);})[_0x4d4c('0x16')](function(_0x493687){logger[_0x4d4c('0x12')](_0x4d4c('0x27'),_0x493687['message'],_0x59bdcf);_0x1f9178(_0x436617[_0x4d4c('0x12')](0x1f4,_0x493687[_0x4d4c('0x14')]));});});};