Built motion from commit 19a84241.|2.5.34
[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 _0x3d6a=['moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','CmHopperBlack,\x20%s,\x20%s','request\x20sent','error','message','info','catch','GetCmHopperBlack','options','raw','attributes','limit','include','map','model','debug','stringify','UpdateCmHopperBlack','CmHopperBlack','update','where','destroy','DestroyCmHopperBlack','util'];(function(_0xaa41f8,_0x4af5ab){var _0x349f74=function(_0x3d4bcd){while(--_0x3d4bcd){_0xaa41f8['push'](_0xaa41f8['shift']());}};_0x349f74(++_0x4af5ab);}(_0x3d6a,0x1e9));var _0xa3d6=function(_0x34efbe,_0x4ef500){_0x34efbe=_0x34efbe-0x0;var _0x44d931=_0x3d6a[_0x34efbe];return _0x44d931;};'use strict';var _=require('lodash');var util=require(_0xa3d6('0x0'));var moment=require(_0xa3d6('0x1'));var BPromise=require(_0xa3d6('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa3d6('0x3'));var db=require(_0xa3d6('0x4'))['db'];var utils=require(_0xa3d6('0x5'));var logger=require(_0xa3d6('0x6'))(_0xa3d6('0x7'));var config=require(_0xa3d6('0x8'));var jayson=require(_0xa3d6('0x9'));var client=jayson['client'][_0xa3d6('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x1fff05,_0x179c2c,_0x25ebad){return new BPromise(function(_0x74a2a6,_0x171364){return client[_0xa3d6('0xb')](_0x1fff05,_0x25ebad)[_0xa3d6('0xc')](function(_0x16b403){logger['info'](_0xa3d6('0xd'),_0x179c2c,_0xa3d6('0xe'));logger['debug']('CmHopperBlack,\x20%s,\x20%s,\x20%s',_0x179c2c,_0xa3d6('0xe'),JSON['stringify'](_0x16b403));if(_0x16b403[_0xa3d6('0xf')]){if(_0x16b403['error']['code']===0x1f4){logger['error'](_0xa3d6('0xd'),_0x179c2c,_0x16b403[_0xa3d6('0xf')][_0xa3d6('0x10')]);return _0x171364(_0x16b403[_0xa3d6('0xf')][_0xa3d6('0x10')]);}logger[_0xa3d6('0xf')](_0xa3d6('0xd'),_0x179c2c,_0x16b403[_0xa3d6('0xf')][_0xa3d6('0x10')]);return _0x74a2a6(_0x16b403[_0xa3d6('0xf')]['message']);}else{logger[_0xa3d6('0x11')](_0xa3d6('0xd'),_0x179c2c,_0xa3d6('0xe'));_0x74a2a6(_0x16b403['result'][_0xa3d6('0x10')]);}})[_0xa3d6('0x12')](function(_0x4f7c6b){logger[_0xa3d6('0xf')](_0xa3d6('0xd'),_0x179c2c,_0x4f7c6b);_0x171364(_0x4f7c6b);});});}exports[_0xa3d6('0x13')]=function(_0x2facc7){var _0xd0bb40=this;return new Promise(function(_0x3eea5f,_0x2f8770){return db['CmHopperBlack']['findAll']({'raw':_0x2facc7['options']?_0x2facc7[_0xa3d6('0x14')][_0xa3d6('0x15')]===undefined?!![]:![]:!![],'where':_0x2facc7[_0xa3d6('0x14')]?_0x2facc7[_0xa3d6('0x14')]['where']||null:null,'attributes':_0x2facc7[_0xa3d6('0x14')]?_0x2facc7['options'][_0xa3d6('0x16')]||null:null,'limit':_0x2facc7[_0xa3d6('0x14')]?_0x2facc7[_0xa3d6('0x14')][_0xa3d6('0x17')]||null:null,'include':_0x2facc7[_0xa3d6('0x14')]?_0x2facc7[_0xa3d6('0x14')][_0xa3d6('0x18')]?_[_0xa3d6('0x19')](_0x2facc7[_0xa3d6('0x14')][_0xa3d6('0x18')],function(_0x369ed8){return{'model':db[_0x369ed8[_0xa3d6('0x1a')]],'as':_0x369ed8['as'],'attributes':_0x369ed8['attributes'],'include':_0x369ed8['include']?_['map'](_0x369ed8[_0xa3d6('0x18')],function(_0x14a1e0){return{'model':db[_0x14a1e0[_0xa3d6('0x1a')]],'as':_0x14a1e0['as'],'attributes':_0x14a1e0[_0xa3d6('0x16')],'include':_0x14a1e0['include']?_[_0xa3d6('0x19')](_0x14a1e0[_0xa3d6('0x18')],function(_0xddf84e){return{'model':db[_0xddf84e[_0xa3d6('0x1a')]],'as':_0xddf84e['as'],'attributes':_0xddf84e[_0xa3d6('0x16')]};}):[]};}):[]};}):[]:[]})[_0xa3d6('0xc')](function(_0x3c3946){logger['info'](_0xa3d6('0x13'),_0x2facc7);logger[_0xa3d6('0x1b')](_0xa3d6('0x13'),_0x2facc7,JSON[_0xa3d6('0x1c')](_0x3c3946));_0x3eea5f(_0x3c3946);})['catch'](function(_0x18fdc3){logger['error']('GetCmHopperBlack',_0x18fdc3[_0xa3d6('0x10')],_0x2facc7);_0x2f8770(_0xd0bb40[_0xa3d6('0xf')](0x1f4,_0x18fdc3[_0xa3d6('0x10')]));});});};exports[_0xa3d6('0x1d')]=function(_0x246bdf){var _0x18c402=this;return new Promise(function(_0x19738f,_0x3fa4da){return db[_0xa3d6('0x1e')][_0xa3d6('0x1f')](_0x246bdf['body'],{'raw':_0x246bdf['options']?_0x246bdf[_0xa3d6('0x14')][_0xa3d6('0x15')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x246bdf[_0xa3d6('0x14')]?_0x246bdf['options'][_0xa3d6('0x20')]||null:null,'attributes':_0x246bdf[_0xa3d6('0x14')]?_0x246bdf[_0xa3d6('0x14')][_0xa3d6('0x16')]||null:null,'limit':_0x246bdf[_0xa3d6('0x14')]?_0x246bdf[_0xa3d6('0x14')][_0xa3d6('0x17')]||null:null})['then'](function(_0x16e3f0){logger[_0xa3d6('0x11')](_0xa3d6('0x1d'),_0x246bdf);logger[_0xa3d6('0x1b')]('UpdateCmHopperBlack',_0x246bdf,JSON[_0xa3d6('0x1c')](_0x16e3f0));_0x19738f(_0x16e3f0);})[_0xa3d6('0x12')](function(_0x30a6ee){logger[_0xa3d6('0xf')](_0xa3d6('0x1d'),_0x30a6ee[_0xa3d6('0x10')],_0x246bdf);_0x3fa4da(_0x18c402[_0xa3d6('0xf')](0x1f4,_0x30a6ee[_0xa3d6('0x10')]));});});};exports['DestroyCmHopperBlack']=function(_0x3cdb79){var _0x5b1280=this;return new Promise(function(_0x3755a0,_0x101357){return db[_0xa3d6('0x1e')][_0xa3d6('0x21')]({'where':_0x3cdb79['options']?_0x3cdb79['options'][_0xa3d6('0x20')]||null:null})[_0xa3d6('0xc')](function(_0x449780){logger[_0xa3d6('0x11')](_0xa3d6('0x22'),_0x3cdb79);logger[_0xa3d6('0x1b')](_0xa3d6('0x22'),_0x3cdb79,JSON[_0xa3d6('0x1c')](_0x449780));_0x3755a0(_0x449780);})['catch'](function(_0x31aafd){logger[_0xa3d6('0xf')](_0xa3d6('0x22'),_0x31aafd[_0xa3d6('0x10')],_0x3cdb79);_0x101357(_0x5b1280['error'](0x1f4,_0x31aafd[_0xa3d6('0x10')]));});});};