Built motion from commit (unavailable).|2.2.0
[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 _0x9fca=['GetCmHopperBlack','CmHopperBlack','options','raw','where','attributes','limit','include','model','map','debug','UpdateCmHopperBlack','DestroyCmHopperBlack','destroy','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','then','CmHopperBlack,\x20%s,\x20%s','CmHopperBlack,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','request\x20sent','result','catch'];(function(_0x56cb7a,_0x4ca053){var _0x3e548d=function(_0x16bf65){while(--_0x16bf65){_0x56cb7a['push'](_0x56cb7a['shift']());}};_0x3e548d(++_0x4ca053);}(_0x9fca,0x1e2));var _0xa9fc=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x9fca[_0x122ef9];return _0x42fba0;};'use strict';var _=require(_0xa9fc('0x0'));var util=require(_0xa9fc('0x1'));var moment=require(_0xa9fc('0x2'));var BPromise=require(_0xa9fc('0x3'));var rs=require(_0xa9fc('0x4'));var fs=require('fs');var Redis=require(_0xa9fc('0x5'));var db=require(_0xa9fc('0x6'))['db'];var utils=require(_0xa9fc('0x7'));var logger=require('../../config/logger')(_0xa9fc('0x8'));var config=require(_0xa9fc('0x9'));var jayson=require(_0xa9fc('0xa'));var client=jayson[_0xa9fc('0xb')][_0xa9fc('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x4ccf5a,_0x2bfa99,_0x1ac1ad){return new BPromise(function(_0x4dd907,_0x17997f){return client[_0xa9fc('0xd')](_0x4ccf5a,_0x1ac1ad)[_0xa9fc('0xe')](function(_0xc821b4){logger['info'](_0xa9fc('0xf'),_0x2bfa99,'request\x20sent');logger['debug'](_0xa9fc('0x10'),_0x2bfa99,'request\x20sent',JSON[_0xa9fc('0x11')](_0xc821b4));if(_0xc821b4[_0xa9fc('0x12')]){if(_0xc821b4[_0xa9fc('0x12')][_0xa9fc('0x13')]===0x1f4){logger[_0xa9fc('0x12')](_0xa9fc('0xf'),_0x2bfa99,_0xc821b4['error']['message']);return _0x17997f(_0xc821b4[_0xa9fc('0x12')][_0xa9fc('0x14')]);}logger['error'](_0xa9fc('0xf'),_0x2bfa99,_0xc821b4[_0xa9fc('0x12')][_0xa9fc('0x14')]);return _0x4dd907(_0xc821b4[_0xa9fc('0x12')][_0xa9fc('0x14')]);}else{logger[_0xa9fc('0x15')]('CmHopperBlack,\x20%s,\x20%s',_0x2bfa99,_0xa9fc('0x16'));_0x4dd907(_0xc821b4[_0xa9fc('0x17')][_0xa9fc('0x14')]);}})[_0xa9fc('0x18')](function(_0x2e23b6){logger['error'](_0xa9fc('0xf'),_0x2bfa99,_0x2e23b6);_0x17997f(_0x2e23b6);});});}exports[_0xa9fc('0x19')]=function(_0x162f0d){var _0x1dae59=this;return new Promise(function(_0x36584d,_0x53c634){return db[_0xa9fc('0x1a')]['findAll']({'raw':_0x162f0d[_0xa9fc('0x1b')]?_0x162f0d[_0xa9fc('0x1b')][_0xa9fc('0x1c')]===undefined?!![]:![]:!![],'where':_0x162f0d[_0xa9fc('0x1b')]?_0x162f0d[_0xa9fc('0x1b')][_0xa9fc('0x1d')]||null:null,'attributes':_0x162f0d[_0xa9fc('0x1b')]?_0x162f0d[_0xa9fc('0x1b')][_0xa9fc('0x1e')]||null:null,'limit':_0x162f0d[_0xa9fc('0x1b')]?_0x162f0d['options'][_0xa9fc('0x1f')]||null:null,'include':_0x162f0d[_0xa9fc('0x1b')]?_0x162f0d[_0xa9fc('0x1b')]['include']?_['map'](_0x162f0d['options'][_0xa9fc('0x20')],function(_0x3b231c){return{'model':db[_0x3b231c[_0xa9fc('0x21')]],'as':_0x3b231c['as'],'attributes':_0x3b231c[_0xa9fc('0x1e')],'include':_0x3b231c[_0xa9fc('0x20')]?_[_0xa9fc('0x22')](_0x3b231c['include'],function(_0x54da36){return{'model':db[_0x54da36[_0xa9fc('0x21')]],'as':_0x54da36['as'],'attributes':_0x54da36[_0xa9fc('0x1e')],'include':_0x54da36['include']?_[_0xa9fc('0x22')](_0x54da36[_0xa9fc('0x20')],function(_0x5e1225){return{'model':db[_0x5e1225['model']],'as':_0x5e1225['as'],'attributes':_0x5e1225[_0xa9fc('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xa9fc('0xe')](function(_0x486b19){logger[_0xa9fc('0x15')](_0xa9fc('0x19'),_0x162f0d);logger[_0xa9fc('0x23')](_0xa9fc('0x19'),_0x162f0d,JSON[_0xa9fc('0x11')](_0x486b19));_0x36584d(_0x486b19);})[_0xa9fc('0x18')](function(_0x332325){logger[_0xa9fc('0x12')](_0xa9fc('0x19'),_0x332325[_0xa9fc('0x14')],_0x162f0d);_0x53c634(_0x1dae59[_0xa9fc('0x12')](0x1f4,_0x332325[_0xa9fc('0x14')]));});});};exports[_0xa9fc('0x24')]=function(_0xd55985){var _0x52b0c4=this;return new Promise(function(_0x104ada,_0x3abb0d){return db['CmHopperBlack']['update'](_0xd55985['body'],{'raw':_0xd55985[_0xa9fc('0x1b')]?_0xd55985[_0xa9fc('0x1b')][_0xa9fc('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xd55985[_0xa9fc('0x1b')]?_0xd55985['options'][_0xa9fc('0x1d')]||null:null,'attributes':_0xd55985[_0xa9fc('0x1b')]?_0xd55985[_0xa9fc('0x1b')][_0xa9fc('0x1e')]||null:null,'limit':_0xd55985[_0xa9fc('0x1b')]?_0xd55985[_0xa9fc('0x1b')][_0xa9fc('0x1f')]||null:null})['then'](function(_0x2eeff5){logger[_0xa9fc('0x15')](_0xa9fc('0x24'),_0xd55985);logger['debug'](_0xa9fc('0x24'),_0xd55985,JSON[_0xa9fc('0x11')](_0x2eeff5));_0x104ada(_0x2eeff5);})[_0xa9fc('0x18')](function(_0x2bd56d){logger[_0xa9fc('0x12')](_0xa9fc('0x24'),_0x2bd56d[_0xa9fc('0x14')],_0xd55985);_0x3abb0d(_0x52b0c4['error'](0x1f4,_0x2bd56d['message']));});});};exports[_0xa9fc('0x25')]=function(_0x6c5d4b){var _0x55944b=this;return new Promise(function(_0x5206b9,_0xecd932){return db[_0xa9fc('0x1a')][_0xa9fc('0x26')]({'where':_0x6c5d4b[_0xa9fc('0x1b')]?_0x6c5d4b[_0xa9fc('0x1b')][_0xa9fc('0x1d')]||null:null})[_0xa9fc('0xe')](function(_0x49355c){logger[_0xa9fc('0x15')](_0xa9fc('0x25'),_0x6c5d4b);logger['debug'](_0xa9fc('0x25'),_0x6c5d4b,JSON['stringify'](_0x49355c));_0x5206b9(_0x49355c);})[_0xa9fc('0x18')](function(_0x40b4da){logger['error']('DestroyCmHopperBlack',_0x40b4da[_0xa9fc('0x14')],_0x6c5d4b);_0xecd932(_0x55944b[_0xa9fc('0x12')](0x1f4,_0x40b4da[_0xa9fc('0x14')]));});});};