Built motion from commit 85328c08.|2.5.50
[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 _0xbb3a=['UpdateCmHopperBlack','update','limit','DestroyCmHopperBlack','destroy','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','info','CmHopperBlack,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch','GetCmHopperBlack','CmHopperBlack','findAll','options','raw','where','include','map','model','attributes','then','stringify'];(function(_0xb83d6b,_0x157d0b){var _0x5932cf=function(_0x359a25){while(--_0x359a25){_0xb83d6b['push'](_0xb83d6b['shift']());}};_0x5932cf(++_0x157d0b);}(_0xbb3a,0x116));var _0xabb3=function(_0x360ad4,_0x5d681d){_0x360ad4=_0x360ad4-0x0;var _0x186d15=_0xbb3a[_0x360ad4];return _0x186d15;};'use strict';var _=require(_0xabb3('0x0'));var util=require(_0xabb3('0x1'));var moment=require(_0xabb3('0x2'));var BPromise=require(_0xabb3('0x3'));var rs=require(_0xabb3('0x4'));var fs=require('fs');var Redis=require(_0xabb3('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xabb3('0x6'));var logger=require(_0xabb3('0x7'))(_0xabb3('0x8'));var config=require(_0xabb3('0x9'));var jayson=require(_0xabb3('0xa'));var client=jayson['client'][_0xabb3('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x24d2e9,_0x519889,_0x4cee1b){return new BPromise(function(_0x5829b9,_0x5e9fb2){return client[_0xabb3('0xc')](_0x24d2e9,_0x4cee1b)['then'](function(_0x5e404e){logger[_0xabb3('0xd')](_0xabb3('0xe'),_0x519889,_0xabb3('0xf'));logger[_0xabb3('0x10')]('CmHopperBlack,\x20%s,\x20%s,\x20%s',_0x519889,_0xabb3('0xf'),JSON['stringify'](_0x5e404e));if(_0x5e404e[_0xabb3('0x11')]){if(_0x5e404e['error'][_0xabb3('0x12')]===0x1f4){logger['error'](_0xabb3('0xe'),_0x519889,_0x5e404e[_0xabb3('0x11')][_0xabb3('0x13')]);return _0x5e9fb2(_0x5e404e[_0xabb3('0x11')][_0xabb3('0x13')]);}logger['error'](_0xabb3('0xe'),_0x519889,_0x5e404e['error'][_0xabb3('0x13')]);return _0x5829b9(_0x5e404e['error'][_0xabb3('0x13')]);}else{logger[_0xabb3('0xd')](_0xabb3('0xe'),_0x519889,_0xabb3('0xf'));_0x5829b9(_0x5e404e[_0xabb3('0x14')][_0xabb3('0x13')]);}})[_0xabb3('0x15')](function(_0x1177b2){logger[_0xabb3('0x11')]('CmHopperBlack,\x20%s,\x20%s',_0x519889,_0x1177b2);_0x5e9fb2(_0x1177b2);});});}exports[_0xabb3('0x16')]=function(_0x5577b7){var _0x3efc3f=this;return new Promise(function(_0x1c9ad8,_0x5f250b){return db[_0xabb3('0x17')][_0xabb3('0x18')]({'raw':_0x5577b7['options']?_0x5577b7[_0xabb3('0x19')][_0xabb3('0x1a')]===undefined?!![]:![]:!![],'where':_0x5577b7['options']?_0x5577b7['options'][_0xabb3('0x1b')]||null:null,'attributes':_0x5577b7[_0xabb3('0x19')]?_0x5577b7[_0xabb3('0x19')]['attributes']||null:null,'limit':_0x5577b7[_0xabb3('0x19')]?_0x5577b7[_0xabb3('0x19')]['limit']||null:null,'include':_0x5577b7[_0xabb3('0x19')]?_0x5577b7[_0xabb3('0x19')][_0xabb3('0x1c')]?_[_0xabb3('0x1d')](_0x5577b7[_0xabb3('0x19')][_0xabb3('0x1c')],function(_0x1a33c9){return{'model':db[_0x1a33c9[_0xabb3('0x1e')]],'as':_0x1a33c9['as'],'attributes':_0x1a33c9[_0xabb3('0x1f')],'include':_0x1a33c9['include']?_[_0xabb3('0x1d')](_0x1a33c9[_0xabb3('0x1c')],function(_0x22b1dc){return{'model':db[_0x22b1dc['model']],'as':_0x22b1dc['as'],'attributes':_0x22b1dc[_0xabb3('0x1f')],'include':_0x22b1dc['include']?_[_0xabb3('0x1d')](_0x22b1dc['include'],function(_0x112ffe){return{'model':db[_0x112ffe[_0xabb3('0x1e')]],'as':_0x112ffe['as'],'attributes':_0x112ffe[_0xabb3('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xabb3('0x20')](function(_0x122a89){logger[_0xabb3('0xd')](_0xabb3('0x16'),_0x5577b7);logger[_0xabb3('0x10')](_0xabb3('0x16'),_0x5577b7,JSON[_0xabb3('0x21')](_0x122a89));_0x1c9ad8(_0x122a89);})['catch'](function(_0x54d746){logger['error'](_0xabb3('0x16'),_0x54d746['message'],_0x5577b7);_0x5f250b(_0x3efc3f[_0xabb3('0x11')](0x1f4,_0x54d746[_0xabb3('0x13')]));});});};exports[_0xabb3('0x22')]=function(_0x47d2d7){var _0x1707ff=this;return new Promise(function(_0x3673d8,_0xf90a28){return db[_0xabb3('0x17')][_0xabb3('0x23')](_0x47d2d7['body'],{'raw':_0x47d2d7[_0xabb3('0x19')]?_0x47d2d7[_0xabb3('0x19')][_0xabb3('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x47d2d7[_0xabb3('0x19')]?_0x47d2d7[_0xabb3('0x19')][_0xabb3('0x1b')]||null:null,'attributes':_0x47d2d7[_0xabb3('0x19')]?_0x47d2d7[_0xabb3('0x19')]['attributes']||null:null,'limit':_0x47d2d7[_0xabb3('0x19')]?_0x47d2d7[_0xabb3('0x19')][_0xabb3('0x24')]||null:null})[_0xabb3('0x20')](function(_0x45e0f0){logger[_0xabb3('0xd')](_0xabb3('0x22'),_0x47d2d7);logger['debug'](_0xabb3('0x22'),_0x47d2d7,JSON[_0xabb3('0x21')](_0x45e0f0));_0x3673d8(_0x45e0f0);})[_0xabb3('0x15')](function(_0x4a9958){logger[_0xabb3('0x11')]('UpdateCmHopperBlack',_0x4a9958[_0xabb3('0x13')],_0x47d2d7);_0xf90a28(_0x1707ff[_0xabb3('0x11')](0x1f4,_0x4a9958[_0xabb3('0x13')]));});});};exports[_0xabb3('0x25')]=function(_0x2c97cd){var _0x395d74=this;return new Promise(function(_0x374637,_0x46a377){return db['CmHopperBlack'][_0xabb3('0x26')]({'where':_0x2c97cd[_0xabb3('0x19')]?_0x2c97cd['options']['where']||null:null})['then'](function(_0x239033){logger[_0xabb3('0xd')]('DestroyCmHopperBlack',_0x2c97cd);logger['debug'](_0xabb3('0x25'),_0x2c97cd,JSON[_0xabb3('0x21')](_0x239033));_0x374637(_0x239033);})[_0xabb3('0x15')](function(_0x37a3bd){logger[_0xabb3('0x11')](_0xabb3('0x25'),_0x37a3bd['message'],_0x2c97cd);_0x46a377(_0x395d74[_0xabb3('0x11')](0x1f4,_0x37a3bd[_0xabb3('0x13')]));});});};