Built motion from commit 7158bc59.|2.5.42
[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 _0x95cb=['code','message','info','GetCmHopperBlack','findAll','options','attributes','limit','include','map','model','catch','CmHopperBlack','body','raw','where','UpdateCmHopperBlack','DestroyCmHopperBlack','destroy','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','http','then','CmHopperBlack,\x20%s,\x20%s','request\x20sent','debug','CmHopperBlack,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x313df3,_0x4fca45){var _0x241d59=function(_0x452786){while(--_0x452786){_0x313df3['push'](_0x313df3['shift']());}};_0x241d59(++_0x4fca45);}(_0x95cb,0x1b7));var _0xb95c=function(_0x11aa5e,_0x1e0a06){_0x11aa5e=_0x11aa5e-0x0;var _0x205672=_0x95cb[_0x11aa5e];return _0x205672;};'use strict';var _=require(_0xb95c('0x0'));var util=require(_0xb95c('0x1'));var moment=require(_0xb95c('0x2'));var BPromise=require('bluebird');var rs=require(_0xb95c('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb95c('0x4'))['db'];var utils=require(_0xb95c('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0xb95c('0x6'));var jayson=require(_0xb95c('0x7'));var client=jayson['client'][_0xb95c('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x5bc686,_0x1df559,_0xbd40b){return new BPromise(function(_0x353264,_0x76badf){return client['request'](_0x5bc686,_0xbd40b)[_0xb95c('0x9')](function(_0x4e5b5e){logger['info'](_0xb95c('0xa'),_0x1df559,_0xb95c('0xb'));logger[_0xb95c('0xc')](_0xb95c('0xd'),_0x1df559,_0xb95c('0xb'),JSON[_0xb95c('0xe')](_0x4e5b5e));if(_0x4e5b5e['error']){if(_0x4e5b5e[_0xb95c('0xf')][_0xb95c('0x10')]===0x1f4){logger[_0xb95c('0xf')](_0xb95c('0xa'),_0x1df559,_0x4e5b5e[_0xb95c('0xf')]['message']);return _0x76badf(_0x4e5b5e[_0xb95c('0xf')][_0xb95c('0x11')]);}logger['error']('CmHopperBlack,\x20%s,\x20%s',_0x1df559,_0x4e5b5e[_0xb95c('0xf')][_0xb95c('0x11')]);return _0x353264(_0x4e5b5e[_0xb95c('0xf')][_0xb95c('0x11')]);}else{logger[_0xb95c('0x12')](_0xb95c('0xa'),_0x1df559,_0xb95c('0xb'));_0x353264(_0x4e5b5e['result'][_0xb95c('0x11')]);}})['catch'](function(_0x3834c3){logger[_0xb95c('0xf')](_0xb95c('0xa'),_0x1df559,_0x3834c3);_0x76badf(_0x3834c3);});});}exports[_0xb95c('0x13')]=function(_0x3618b1){var _0x3b392d=this;return new Promise(function(_0x250823,_0x33272d){return db['CmHopperBlack'][_0xb95c('0x14')]({'raw':_0x3618b1[_0xb95c('0x15')]?_0x3618b1[_0xb95c('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x3618b1['options']?_0x3618b1['options']['where']||null:null,'attributes':_0x3618b1[_0xb95c('0x15')]?_0x3618b1[_0xb95c('0x15')][_0xb95c('0x16')]||null:null,'limit':_0x3618b1[_0xb95c('0x15')]?_0x3618b1[_0xb95c('0x15')][_0xb95c('0x17')]||null:null,'include':_0x3618b1[_0xb95c('0x15')]?_0x3618b1[_0xb95c('0x15')][_0xb95c('0x18')]?_[_0xb95c('0x19')](_0x3618b1[_0xb95c('0x15')][_0xb95c('0x18')],function(_0x3c3ea3){return{'model':db[_0x3c3ea3['model']],'as':_0x3c3ea3['as'],'attributes':_0x3c3ea3[_0xb95c('0x16')],'include':_0x3c3ea3[_0xb95c('0x18')]?_[_0xb95c('0x19')](_0x3c3ea3['include'],function(_0x37adc6){return{'model':db[_0x37adc6['model']],'as':_0x37adc6['as'],'attributes':_0x37adc6[_0xb95c('0x16')],'include':_0x37adc6[_0xb95c('0x18')]?_[_0xb95c('0x19')](_0x37adc6['include'],function(_0x5c26be){return{'model':db[_0x5c26be[_0xb95c('0x1a')]],'as':_0x5c26be['as'],'attributes':_0x5c26be[_0xb95c('0x16')]};}):[]};}):[]};}):[]:[]})[_0xb95c('0x9')](function(_0x41d984){logger[_0xb95c('0x12')](_0xb95c('0x13'),_0x3618b1);logger[_0xb95c('0xc')](_0xb95c('0x13'),_0x3618b1,JSON[_0xb95c('0xe')](_0x41d984));_0x250823(_0x41d984);})[_0xb95c('0x1b')](function(_0x10208f){logger[_0xb95c('0xf')](_0xb95c('0x13'),_0x10208f[_0xb95c('0x11')],_0x3618b1);_0x33272d(_0x3b392d[_0xb95c('0xf')](0x1f4,_0x10208f[_0xb95c('0x11')]));});});};exports['UpdateCmHopperBlack']=function(_0x1d6f6e){var _0x1b8298=this;return new Promise(function(_0x4d9fce,_0xceba5b){return db[_0xb95c('0x1c')]['update'](_0x1d6f6e[_0xb95c('0x1d')],{'raw':_0x1d6f6e[_0xb95c('0x15')]?_0x1d6f6e['options'][_0xb95c('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1d6f6e[_0xb95c('0x15')]?_0x1d6f6e[_0xb95c('0x15')][_0xb95c('0x1f')]||null:null,'attributes':_0x1d6f6e[_0xb95c('0x15')]?_0x1d6f6e[_0xb95c('0x15')][_0xb95c('0x16')]||null:null,'limit':_0x1d6f6e[_0xb95c('0x15')]?_0x1d6f6e[_0xb95c('0x15')][_0xb95c('0x17')]||null:null})['then'](function(_0x5f08dd){logger[_0xb95c('0x12')](_0xb95c('0x20'),_0x1d6f6e);logger[_0xb95c('0xc')](_0xb95c('0x20'),_0x1d6f6e,JSON[_0xb95c('0xe')](_0x5f08dd));_0x4d9fce(_0x5f08dd);})[_0xb95c('0x1b')](function(_0x4723eb){logger['error'](_0xb95c('0x20'),_0x4723eb[_0xb95c('0x11')],_0x1d6f6e);_0xceba5b(_0x1b8298[_0xb95c('0xf')](0x1f4,_0x4723eb[_0xb95c('0x11')]));});});};exports[_0xb95c('0x21')]=function(_0x21438b){var _0x13834c=this;return new Promise(function(_0x179315,_0x5901aa){return db['CmHopperBlack'][_0xb95c('0x22')]({'where':_0x21438b[_0xb95c('0x15')]?_0x21438b['options'][_0xb95c('0x1f')]||null:null})[_0xb95c('0x9')](function(_0x2cfadb){logger[_0xb95c('0x12')](_0xb95c('0x21'),_0x21438b);logger[_0xb95c('0xc')]('DestroyCmHopperBlack',_0x21438b,JSON['stringify'](_0x2cfadb));_0x179315(_0x2cfadb);})['catch'](function(_0x10f7a5){logger[_0xb95c('0xf')](_0xb95c('0x21'),_0x10f7a5['message'],_0x21438b);_0x5901aa(_0x13834c[_0xb95c('0xf')](0x1f4,_0x10f7a5[_0xb95c('0x11')]));});});};