Built motion from commit cafec4f3.|2.6.31
[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 _0xf100=['catch','UpdateCmHopperBlack','CmHopperBlack','update','body','raw','stringify','DestroyCmHopperBlack','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','CmHopperBlack,\x20%s,\x20%s','request\x20sent','CmHopperBlack,\x20%s,\x20%s,\x20%s','error','code','message','result','GetCmHopperBlack','findAll','options','where','attributes','include','map','model','then','debug'];(function(_0x5ea82f,_0x41ef96){var _0x2f38b6=function(_0x5b084e){while(--_0x5b084e){_0x5ea82f['push'](_0x5ea82f['shift']());}};_0x2f38b6(++_0x41ef96);}(_0xf100,0xf2));var _0x0f10=function(_0x507074,_0x21f900){_0x507074=_0x507074-0x0;var _0x1e987e=_0xf100[_0x507074];return _0x1e987e;};'use strict';var _=require(_0x0f10('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x0f10('0x1'));var rs=require(_0x0f10('0x2'));var fs=require('fs');var Redis=require(_0x0f10('0x3'));var db=require(_0x0f10('0x4'))['db'];var utils=require(_0x0f10('0x5'));var logger=require(_0x0f10('0x6'))(_0x0f10('0x7'));var config=require(_0x0f10('0x8'));var jayson=require(_0x0f10('0x9'));var client=jayson[_0x0f10('0xa')][_0x0f10('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x16957a,_0x96a851,_0x2d0393){return new BPromise(function(_0x3de1af,_0x1c6695){return client[_0x0f10('0xc')](_0x16957a,_0x2d0393)['then'](function(_0x3d0253){logger[_0x0f10('0xd')](_0x0f10('0xe'),_0x96a851,_0x0f10('0xf'));logger['debug'](_0x0f10('0x10'),_0x96a851,'request\x20sent',JSON['stringify'](_0x3d0253));if(_0x3d0253[_0x0f10('0x11')]){if(_0x3d0253[_0x0f10('0x11')][_0x0f10('0x12')]===0x1f4){logger[_0x0f10('0x11')](_0x0f10('0xe'),_0x96a851,_0x3d0253[_0x0f10('0x11')][_0x0f10('0x13')]);return _0x1c6695(_0x3d0253[_0x0f10('0x11')][_0x0f10('0x13')]);}logger[_0x0f10('0x11')](_0x0f10('0xe'),_0x96a851,_0x3d0253['error'][_0x0f10('0x13')]);return _0x3de1af(_0x3d0253[_0x0f10('0x11')]['message']);}else{logger['info']('CmHopperBlack,\x20%s,\x20%s',_0x96a851,_0x0f10('0xf'));_0x3de1af(_0x3d0253[_0x0f10('0x14')][_0x0f10('0x13')]);}})['catch'](function(_0x4fa1d6){logger['error'](_0x0f10('0xe'),_0x96a851,_0x4fa1d6);_0x1c6695(_0x4fa1d6);});});}exports[_0x0f10('0x15')]=function(_0x4730ca){var _0xc1aff9=this;return new Promise(function(_0x55ff0c,_0x2eb0c2){return db['CmHopperBlack'][_0x0f10('0x16')]({'raw':_0x4730ca[_0x0f10('0x17')]?_0x4730ca['options']['raw']===undefined?!![]:![]:!![],'where':_0x4730ca['options']?_0x4730ca['options'][_0x0f10('0x18')]||null:null,'attributes':_0x4730ca['options']?_0x4730ca[_0x0f10('0x17')][_0x0f10('0x19')]||null:null,'limit':_0x4730ca[_0x0f10('0x17')]?_0x4730ca[_0x0f10('0x17')]['limit']||null:null,'include':_0x4730ca[_0x0f10('0x17')]?_0x4730ca[_0x0f10('0x17')][_0x0f10('0x1a')]?_[_0x0f10('0x1b')](_0x4730ca[_0x0f10('0x17')]['include'],function(_0x4ca15c){return{'model':db[_0x4ca15c[_0x0f10('0x1c')]],'as':_0x4ca15c['as'],'attributes':_0x4ca15c[_0x0f10('0x19')],'include':_0x4ca15c[_0x0f10('0x1a')]?_[_0x0f10('0x1b')](_0x4ca15c['include'],function(_0x343db1){return{'model':db[_0x343db1[_0x0f10('0x1c')]],'as':_0x343db1['as'],'attributes':_0x343db1[_0x0f10('0x19')],'include':_0x343db1['include']?_['map'](_0x343db1['include'],function(_0x501033){return{'model':db[_0x501033[_0x0f10('0x1c')]],'as':_0x501033['as'],'attributes':_0x501033[_0x0f10('0x19')]};}):[]};}):[]};}):[]:[]})[_0x0f10('0x1d')](function(_0x4ebb73){logger[_0x0f10('0xd')]('GetCmHopperBlack',_0x4730ca);logger[_0x0f10('0x1e')](_0x0f10('0x15'),_0x4730ca,JSON['stringify'](_0x4ebb73));_0x55ff0c(_0x4ebb73);})[_0x0f10('0x1f')](function(_0x5cb02){logger['error'](_0x0f10('0x15'),_0x5cb02[_0x0f10('0x13')],_0x4730ca);_0x2eb0c2(_0xc1aff9['error'](0x1f4,_0x5cb02[_0x0f10('0x13')]));});});};exports[_0x0f10('0x20')]=function(_0x58a540){var _0x57ab4b=this;return new Promise(function(_0x23aa5e,_0x479cff){return db[_0x0f10('0x21')][_0x0f10('0x22')](_0x58a540[_0x0f10('0x23')],{'raw':_0x58a540[_0x0f10('0x17')]?_0x58a540[_0x0f10('0x17')][_0x0f10('0x24')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x58a540[_0x0f10('0x17')]?_0x58a540[_0x0f10('0x17')][_0x0f10('0x18')]||null:null,'attributes':_0x58a540[_0x0f10('0x17')]?_0x58a540[_0x0f10('0x17')][_0x0f10('0x19')]||null:null,'limit':_0x58a540['options']?_0x58a540[_0x0f10('0x17')]['limit']||null:null})[_0x0f10('0x1d')](function(_0x11e818){logger['info']('UpdateCmHopperBlack',_0x58a540);logger[_0x0f10('0x1e')](_0x0f10('0x20'),_0x58a540,JSON[_0x0f10('0x25')](_0x11e818));_0x23aa5e(_0x11e818);})[_0x0f10('0x1f')](function(_0x568390){logger[_0x0f10('0x11')](_0x0f10('0x20'),_0x568390[_0x0f10('0x13')],_0x58a540);_0x479cff(_0x57ab4b[_0x0f10('0x11')](0x1f4,_0x568390['message']));});});};exports['DestroyCmHopperBlack']=function(_0x14fb90){var _0x58df18=this;return new Promise(function(_0x489d66,_0xcf7234){return db[_0x0f10('0x21')]['destroy']({'where':_0x14fb90[_0x0f10('0x17')]?_0x14fb90['options']['where']||null:null})['then'](function(_0x553174){logger[_0x0f10('0xd')](_0x0f10('0x26'),_0x14fb90);logger[_0x0f10('0x1e')](_0x0f10('0x26'),_0x14fb90,JSON[_0x0f10('0x25')](_0x553174));_0x489d66(_0x553174);})[_0x0f10('0x1f')](function(_0x2ba4b1){logger[_0x0f10('0x11')](_0x0f10('0x26'),_0x2ba4b1['message'],_0x14fb90);_0xcf7234(_0x58df18['error'](0x1f4,_0x2ba4b1[_0x0f10('0x13')]));});});};