Built motion from commit (unavailable).|2.5.4
[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 _0x0085=['destroy','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info','request\x20sent','debug','CmHopperBlack,\x20%s,\x20%s,\x20%s','stringify','error','code','message','CmHopperBlack,\x20%s,\x20%s','result','catch','GetCmHopperBlack','CmHopperBlack','findAll','options','raw','where','limit','include','model','attributes','map','UpdateCmHopperBlack','update','body','DestroyCmHopperBlack'];(function(_0x42a206,_0x2b1612){var _0x35eb3b=function(_0x3e5c46){while(--_0x3e5c46){_0x42a206['push'](_0x42a206['shift']());}};_0x35eb3b(++_0x2b1612);}(_0x0085,0xf7));var _0x5008=function(_0x1db929,_0x270726){_0x1db929=_0x1db929-0x0;var _0x111a43=_0x0085[_0x1db929];return _0x111a43;};'use strict';var _=require(_0x5008('0x0'));var util=require(_0x5008('0x1'));var moment=require(_0x5008('0x2'));var BPromise=require(_0x5008('0x3'));var rs=require(_0x5008('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5008('0x5'))['db'];var utils=require(_0x5008('0x6'));var logger=require(_0x5008('0x7'))(_0x5008('0x8'));var config=require('../../config/environment');var jayson=require(_0x5008('0x9'));var client=jayson[_0x5008('0xa')][_0x5008('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x52e5b5,_0x481038,_0x4c29b2){return new BPromise(function(_0x2ebc94,_0x1918c){return client[_0x5008('0xc')](_0x52e5b5,_0x4c29b2)[_0x5008('0xd')](function(_0x152a2e){logger[_0x5008('0xe')]('CmHopperBlack,\x20%s,\x20%s',_0x481038,_0x5008('0xf'));logger[_0x5008('0x10')](_0x5008('0x11'),_0x481038,_0x5008('0xf'),JSON[_0x5008('0x12')](_0x152a2e));if(_0x152a2e[_0x5008('0x13')]){if(_0x152a2e[_0x5008('0x13')][_0x5008('0x14')]===0x1f4){logger[_0x5008('0x13')]('CmHopperBlack,\x20%s,\x20%s',_0x481038,_0x152a2e[_0x5008('0x13')][_0x5008('0x15')]);return _0x1918c(_0x152a2e[_0x5008('0x13')][_0x5008('0x15')]);}logger[_0x5008('0x13')](_0x5008('0x16'),_0x481038,_0x152a2e[_0x5008('0x13')]['message']);return _0x2ebc94(_0x152a2e[_0x5008('0x13')][_0x5008('0x15')]);}else{logger[_0x5008('0xe')]('CmHopperBlack,\x20%s,\x20%s',_0x481038,_0x5008('0xf'));_0x2ebc94(_0x152a2e[_0x5008('0x17')]['message']);}})[_0x5008('0x18')](function(_0x5da9a2){logger[_0x5008('0x13')](_0x5008('0x16'),_0x481038,_0x5da9a2);_0x1918c(_0x5da9a2);});});}exports[_0x5008('0x19')]=function(_0x5969de){var _0xc6fc59=this;return new Promise(function(_0x3aed40,_0x36cf39){return db[_0x5008('0x1a')][_0x5008('0x1b')]({'raw':_0x5969de['options']?_0x5969de[_0x5008('0x1c')][_0x5008('0x1d')]===undefined?!![]:![]:!![],'where':_0x5969de[_0x5008('0x1c')]?_0x5969de[_0x5008('0x1c')][_0x5008('0x1e')]||null:null,'attributes':_0x5969de[_0x5008('0x1c')]?_0x5969de[_0x5008('0x1c')]['attributes']||null:null,'limit':_0x5969de[_0x5008('0x1c')]?_0x5969de[_0x5008('0x1c')][_0x5008('0x1f')]||null:null,'include':_0x5969de[_0x5008('0x1c')]?_0x5969de['options'][_0x5008('0x20')]?_['map'](_0x5969de[_0x5008('0x1c')][_0x5008('0x20')],function(_0x4f57b5){return{'model':db[_0x4f57b5[_0x5008('0x21')]],'as':_0x4f57b5['as'],'attributes':_0x4f57b5[_0x5008('0x22')],'include':_0x4f57b5[_0x5008('0x20')]?_[_0x5008('0x23')](_0x4f57b5['include'],function(_0x8e995a){return{'model':db[_0x8e995a[_0x5008('0x21')]],'as':_0x8e995a['as'],'attributes':_0x8e995a[_0x5008('0x22')],'include':_0x8e995a[_0x5008('0x20')]?_[_0x5008('0x23')](_0x8e995a[_0x5008('0x20')],function(_0x3915cb){return{'model':db[_0x3915cb[_0x5008('0x21')]],'as':_0x3915cb['as'],'attributes':_0x3915cb[_0x5008('0x22')]};}):[]};}):[]};}):[]:[]})[_0x5008('0xd')](function(_0x4622a2){logger[_0x5008('0xe')]('GetCmHopperBlack',_0x5969de);logger[_0x5008('0x10')](_0x5008('0x19'),_0x5969de,JSON[_0x5008('0x12')](_0x4622a2));_0x3aed40(_0x4622a2);})[_0x5008('0x18')](function(_0x72605f){logger[_0x5008('0x13')](_0x5008('0x19'),_0x72605f[_0x5008('0x15')],_0x5969de);_0x36cf39(_0xc6fc59[_0x5008('0x13')](0x1f4,_0x72605f[_0x5008('0x15')]));});});};exports[_0x5008('0x24')]=function(_0x545bea){var _0x48db1a=this;return new Promise(function(_0x2a6959,_0x3764a4){return db['CmHopperBlack'][_0x5008('0x25')](_0x545bea[_0x5008('0x26')],{'raw':_0x545bea['options']?_0x545bea[_0x5008('0x1c')][_0x5008('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x545bea[_0x5008('0x1c')]?_0x545bea['options'][_0x5008('0x1e')]||null:null,'attributes':_0x545bea[_0x5008('0x1c')]?_0x545bea[_0x5008('0x1c')][_0x5008('0x22')]||null:null,'limit':_0x545bea['options']?_0x545bea[_0x5008('0x1c')]['limit']||null:null})[_0x5008('0xd')](function(_0x3bf782){logger['info'](_0x5008('0x24'),_0x545bea);logger[_0x5008('0x10')]('UpdateCmHopperBlack',_0x545bea,JSON[_0x5008('0x12')](_0x3bf782));_0x2a6959(_0x3bf782);})['catch'](function(_0x5ec227){logger[_0x5008('0x13')]('UpdateCmHopperBlack',_0x5ec227[_0x5008('0x15')],_0x545bea);_0x3764a4(_0x48db1a['error'](0x1f4,_0x5ec227['message']));});});};exports[_0x5008('0x27')]=function(_0x21b5ac){var _0x5a6532=this;return new Promise(function(_0xc115a4,_0x4283a0){return db[_0x5008('0x1a')][_0x5008('0x28')]({'where':_0x21b5ac[_0x5008('0x1c')]?_0x21b5ac['options']['where']||null:null})[_0x5008('0xd')](function(_0x2bc4d5){logger[_0x5008('0xe')](_0x5008('0x27'),_0x21b5ac);logger[_0x5008('0x10')](_0x5008('0x27'),_0x21b5ac,JSON[_0x5008('0x12')](_0x2bc4d5));_0xc115a4(_0x2bc4d5);})[_0x5008('0x18')](function(_0x2101bb){logger[_0x5008('0x13')]('DestroyCmHopperBlack',_0x2101bb[_0x5008('0x15')],_0x21b5ac);_0x4283a0(_0x5a6532[_0x5008('0x13')](0x1f4,_0x2101bb[_0x5008('0x15')]));});});};