Built motion from commit a61a4a20.|2.5.46
[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 _0xcf8f=['lodash','util','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','request','then','info','CmHopperBlack,\x20%s,\x20%s','request\x20sent','debug','CmHopperBlack,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetCmHopperBlack','options','raw','where','attributes','limit','include','model','map','UpdateCmHopperBlack','CmHopperBlack','update','body','DestroyCmHopperBlack','destroy'];(function(_0x585059,_0x442f8f){var _0x582ca=function(_0x54f541){while(--_0x54f541){_0x585059['push'](_0x585059['shift']());}};_0x582ca(++_0x442f8f);}(_0xcf8f,0x120));var _0xfcf8=function(_0x1b2c60,_0x53b096){_0x1b2c60=_0x1b2c60-0x0;var _0x1b6b7e=_0xcf8f[_0x1b2c60];return _0x1b6b7e;};'use strict';var _=require(_0xfcf8('0x0'));var util=require(_0xfcf8('0x1'));var moment=require('moment');var BPromise=require(_0xfcf8('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xfcf8('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xfcf8('0x4'));var logger=require(_0xfcf8('0x5'))(_0xfcf8('0x6'));var config=require(_0xfcf8('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xfcf8('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0xa240cd,_0x2564f1,_0x2f049d){return new BPromise(function(_0x326d67,_0x3fc7ff){return client[_0xfcf8('0x9')](_0xa240cd,_0x2f049d)[_0xfcf8('0xa')](function(_0x720a70){logger[_0xfcf8('0xb')](_0xfcf8('0xc'),_0x2564f1,_0xfcf8('0xd'));logger[_0xfcf8('0xe')](_0xfcf8('0xf'),_0x2564f1,'request\x20sent',JSON[_0xfcf8('0x10')](_0x720a70));if(_0x720a70[_0xfcf8('0x11')]){if(_0x720a70[_0xfcf8('0x11')]['code']===0x1f4){logger[_0xfcf8('0x11')](_0xfcf8('0xc'),_0x2564f1,_0x720a70[_0xfcf8('0x11')][_0xfcf8('0x12')]);return _0x3fc7ff(_0x720a70[_0xfcf8('0x11')][_0xfcf8('0x12')]);}logger[_0xfcf8('0x11')]('CmHopperBlack,\x20%s,\x20%s',_0x2564f1,_0x720a70[_0xfcf8('0x11')][_0xfcf8('0x12')]);return _0x326d67(_0x720a70[_0xfcf8('0x11')][_0xfcf8('0x12')]);}else{logger['info']('CmHopperBlack,\x20%s,\x20%s',_0x2564f1,'request\x20sent');_0x326d67(_0x720a70[_0xfcf8('0x13')][_0xfcf8('0x12')]);}})[_0xfcf8('0x14')](function(_0x14263c){logger[_0xfcf8('0x11')](_0xfcf8('0xc'),_0x2564f1,_0x14263c);_0x3fc7ff(_0x14263c);});});}exports[_0xfcf8('0x15')]=function(_0x291468){var _0x7c3ff9=this;return new Promise(function(_0x32b8a2,_0x45651e){return db['CmHopperBlack']['findAll']({'raw':_0x291468[_0xfcf8('0x16')]?_0x291468[_0xfcf8('0x16')][_0xfcf8('0x17')]===undefined?!![]:![]:!![],'where':_0x291468[_0xfcf8('0x16')]?_0x291468['options'][_0xfcf8('0x18')]||null:null,'attributes':_0x291468[_0xfcf8('0x16')]?_0x291468['options'][_0xfcf8('0x19')]||null:null,'limit':_0x291468['options']?_0x291468['options'][_0xfcf8('0x1a')]||null:null,'include':_0x291468[_0xfcf8('0x16')]?_0x291468[_0xfcf8('0x16')][_0xfcf8('0x1b')]?_['map'](_0x291468['options'][_0xfcf8('0x1b')],function(_0x168421){return{'model':db[_0x168421[_0xfcf8('0x1c')]],'as':_0x168421['as'],'attributes':_0x168421[_0xfcf8('0x19')],'include':_0x168421[_0xfcf8('0x1b')]?_[_0xfcf8('0x1d')](_0x168421[_0xfcf8('0x1b')],function(_0x7d1d12){return{'model':db[_0x7d1d12[_0xfcf8('0x1c')]],'as':_0x7d1d12['as'],'attributes':_0x7d1d12[_0xfcf8('0x19')],'include':_0x7d1d12[_0xfcf8('0x1b')]?_[_0xfcf8('0x1d')](_0x7d1d12[_0xfcf8('0x1b')],function(_0x287ee5){return{'model':db[_0x287ee5[_0xfcf8('0x1c')]],'as':_0x287ee5['as'],'attributes':_0x287ee5['attributes']};}):[]};}):[]};}):[]:[]})[_0xfcf8('0xa')](function(_0x57369f){logger['info'](_0xfcf8('0x15'),_0x291468);logger['debug'](_0xfcf8('0x15'),_0x291468,JSON[_0xfcf8('0x10')](_0x57369f));_0x32b8a2(_0x57369f);})['catch'](function(_0x548eaf){logger[_0xfcf8('0x11')](_0xfcf8('0x15'),_0x548eaf[_0xfcf8('0x12')],_0x291468);_0x45651e(_0x7c3ff9[_0xfcf8('0x11')](0x1f4,_0x548eaf[_0xfcf8('0x12')]));});});};exports[_0xfcf8('0x1e')]=function(_0x19a004){var _0x43ae13=this;return new Promise(function(_0x37a6a8,_0x3cc314){return db[_0xfcf8('0x1f')][_0xfcf8('0x20')](_0x19a004[_0xfcf8('0x21')],{'raw':_0x19a004[_0xfcf8('0x16')]?_0x19a004[_0xfcf8('0x16')][_0xfcf8('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x19a004[_0xfcf8('0x16')]?_0x19a004[_0xfcf8('0x16')][_0xfcf8('0x18')]||null:null,'attributes':_0x19a004[_0xfcf8('0x16')]?_0x19a004[_0xfcf8('0x16')][_0xfcf8('0x19')]||null:null,'limit':_0x19a004[_0xfcf8('0x16')]?_0x19a004['options'][_0xfcf8('0x1a')]||null:null})[_0xfcf8('0xa')](function(_0x800ed){logger[_0xfcf8('0xb')](_0xfcf8('0x1e'),_0x19a004);logger[_0xfcf8('0xe')](_0xfcf8('0x1e'),_0x19a004,JSON['stringify'](_0x800ed));_0x37a6a8(_0x800ed);})['catch'](function(_0x5e3a0d){logger[_0xfcf8('0x11')]('UpdateCmHopperBlack',_0x5e3a0d['message'],_0x19a004);_0x3cc314(_0x43ae13[_0xfcf8('0x11')](0x1f4,_0x5e3a0d[_0xfcf8('0x12')]));});});};exports[_0xfcf8('0x22')]=function(_0x433ae1){var _0x58aabe=this;return new Promise(function(_0x358a1b,_0xf61946){return db['CmHopperBlack'][_0xfcf8('0x23')]({'where':_0x433ae1[_0xfcf8('0x16')]?_0x433ae1['options'][_0xfcf8('0x18')]||null:null})[_0xfcf8('0xa')](function(_0x29ec58){logger[_0xfcf8('0xb')](_0xfcf8('0x22'),_0x433ae1);logger[_0xfcf8('0xe')](_0xfcf8('0x22'),_0x433ae1,JSON['stringify'](_0x29ec58));_0x358a1b(_0x29ec58);})['catch'](function(_0xb51af9){logger[_0xfcf8('0x11')]('DestroyCmHopperBlack',_0xb51af9[_0xfcf8('0x12')],_0x433ae1);_0xf61946(_0x58aabe[_0xfcf8('0x11')](0x1f4,_0xb51af9[_0xfcf8('0x12')]));});});};