Built motion from commit 753c950e.|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 _0xfdbd=['update','body','destroy','DestroyCmHopperBlack','lodash','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','request','then','CmHopperBlack,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','GetCmHopperBlack','CmHopperBlack','findAll','options','raw','where','limit','include','map','model','attributes','UpdateCmHopperBlack'];(function(_0x1fc4e2,_0x493c3b){var _0x2ba184=function(_0x58e64f){while(--_0x58e64f){_0x1fc4e2['push'](_0x1fc4e2['shift']());}};_0x2ba184(++_0x493c3b);}(_0xfdbd,0x1c0));var _0xdfdb=function(_0x2da402,_0x14a691){_0x2da402=_0x2da402-0x0;var _0x31a57d=_0xfdbd[_0x2da402];return _0x31a57d;};'use strict';var _=require(_0xdfdb('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xdfdb('0x1'));var fs=require('fs');var Redis=require(_0xdfdb('0x2'));var db=require(_0xdfdb('0x3'))['db'];var utils=require(_0xdfdb('0x4'));var logger=require('../../config/logger')('rpc');var config=require(_0xdfdb('0x5'));var jayson=require(_0xdfdb('0x6'));var client=jayson[_0xdfdb('0x7')][_0xdfdb('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x591f6c,_0x2697e4,_0xece4bd){return new BPromise(function(_0x5c6b54,_0x4b6020){return client[_0xdfdb('0x9')](_0x591f6c,_0xece4bd)[_0xdfdb('0xa')](function(_0x1111d2){logger['info'](_0xdfdb('0xb'),_0x2697e4,_0xdfdb('0xc'));logger[_0xdfdb('0xd')]('CmHopperBlack,\x20%s,\x20%s,\x20%s',_0x2697e4,'request\x20sent',JSON[_0xdfdb('0xe')](_0x1111d2));if(_0x1111d2[_0xdfdb('0xf')]){if(_0x1111d2[_0xdfdb('0xf')][_0xdfdb('0x10')]===0x1f4){logger[_0xdfdb('0xf')](_0xdfdb('0xb'),_0x2697e4,_0x1111d2['error']['message']);return _0x4b6020(_0x1111d2[_0xdfdb('0xf')][_0xdfdb('0x11')]);}logger[_0xdfdb('0xf')](_0xdfdb('0xb'),_0x2697e4,_0x1111d2[_0xdfdb('0xf')][_0xdfdb('0x11')]);return _0x5c6b54(_0x1111d2['error'][_0xdfdb('0x11')]);}else{logger[_0xdfdb('0x12')](_0xdfdb('0xb'),_0x2697e4,_0xdfdb('0xc'));_0x5c6b54(_0x1111d2[_0xdfdb('0x13')][_0xdfdb('0x11')]);}})[_0xdfdb('0x14')](function(_0x392dad){logger['error'](_0xdfdb('0xb'),_0x2697e4,_0x392dad);_0x4b6020(_0x392dad);});});}exports[_0xdfdb('0x15')]=function(_0x23ae03){var _0x4de6fd=this;return new Promise(function(_0x51474f,_0x5557ad){return db[_0xdfdb('0x16')][_0xdfdb('0x17')]({'raw':_0x23ae03[_0xdfdb('0x18')]?_0x23ae03['options'][_0xdfdb('0x19')]===undefined?!![]:![]:!![],'where':_0x23ae03[_0xdfdb('0x18')]?_0x23ae03[_0xdfdb('0x18')][_0xdfdb('0x1a')]||null:null,'attributes':_0x23ae03[_0xdfdb('0x18')]?_0x23ae03[_0xdfdb('0x18')]['attributes']||null:null,'limit':_0x23ae03[_0xdfdb('0x18')]?_0x23ae03[_0xdfdb('0x18')][_0xdfdb('0x1b')]||null:null,'include':_0x23ae03['options']?_0x23ae03[_0xdfdb('0x18')][_0xdfdb('0x1c')]?_['map'](_0x23ae03['options'][_0xdfdb('0x1c')],function(_0x3dd477){return{'model':db[_0x3dd477['model']],'as':_0x3dd477['as'],'attributes':_0x3dd477['attributes'],'include':_0x3dd477[_0xdfdb('0x1c')]?_[_0xdfdb('0x1d')](_0x3dd477[_0xdfdb('0x1c')],function(_0x35f6f3){return{'model':db[_0x35f6f3[_0xdfdb('0x1e')]],'as':_0x35f6f3['as'],'attributes':_0x35f6f3[_0xdfdb('0x1f')],'include':_0x35f6f3[_0xdfdb('0x1c')]?_['map'](_0x35f6f3['include'],function(_0x429bab){return{'model':db[_0x429bab[_0xdfdb('0x1e')]],'as':_0x429bab['as'],'attributes':_0x429bab['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x4e4e67){logger[_0xdfdb('0x12')](_0xdfdb('0x15'),_0x23ae03);logger['debug'](_0xdfdb('0x15'),_0x23ae03,JSON[_0xdfdb('0xe')](_0x4e4e67));_0x51474f(_0x4e4e67);})[_0xdfdb('0x14')](function(_0x131594){logger[_0xdfdb('0xf')](_0xdfdb('0x15'),_0x131594[_0xdfdb('0x11')],_0x23ae03);_0x5557ad(_0x4de6fd[_0xdfdb('0xf')](0x1f4,_0x131594[_0xdfdb('0x11')]));});});};exports[_0xdfdb('0x20')]=function(_0x237c8a){var _0xe01a86=this;return new Promise(function(_0x437d6b,_0x181f67){return db[_0xdfdb('0x16')][_0xdfdb('0x21')](_0x237c8a[_0xdfdb('0x22')],{'raw':_0x237c8a[_0xdfdb('0x18')]?_0x237c8a[_0xdfdb('0x18')][_0xdfdb('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x237c8a[_0xdfdb('0x18')]?_0x237c8a[_0xdfdb('0x18')][_0xdfdb('0x1a')]||null:null,'attributes':_0x237c8a[_0xdfdb('0x18')]?_0x237c8a['options'][_0xdfdb('0x1f')]||null:null,'limit':_0x237c8a['options']?_0x237c8a[_0xdfdb('0x18')][_0xdfdb('0x1b')]||null:null})[_0xdfdb('0xa')](function(_0x169cf3){logger[_0xdfdb('0x12')]('UpdateCmHopperBlack',_0x237c8a);logger[_0xdfdb('0xd')](_0xdfdb('0x20'),_0x237c8a,JSON[_0xdfdb('0xe')](_0x169cf3));_0x437d6b(_0x169cf3);})[_0xdfdb('0x14')](function(_0x54e2fb){logger[_0xdfdb('0xf')](_0xdfdb('0x20'),_0x54e2fb[_0xdfdb('0x11')],_0x237c8a);_0x181f67(_0xe01a86['error'](0x1f4,_0x54e2fb[_0xdfdb('0x11')]));});});};exports['DestroyCmHopperBlack']=function(_0x48d3af){var _0x38816c=this;return new Promise(function(_0x35c6c0,_0x32eb3f){return db[_0xdfdb('0x16')][_0xdfdb('0x23')]({'where':_0x48d3af[_0xdfdb('0x18')]?_0x48d3af[_0xdfdb('0x18')][_0xdfdb('0x1a')]||null:null})[_0xdfdb('0xa')](function(_0x18100d){logger[_0xdfdb('0x12')](_0xdfdb('0x24'),_0x48d3af);logger[_0xdfdb('0xd')]('DestroyCmHopperBlack',_0x48d3af,JSON[_0xdfdb('0xe')](_0x18100d));_0x35c6c0(_0x18100d);})['catch'](function(_0x25723d){logger[_0xdfdb('0xf')](_0xdfdb('0x24'),_0x25723d[_0xdfdb('0x11')],_0x48d3af);_0x32eb3f(_0x38816c[_0xdfdb('0xf')](0x1f4,_0x25723d[_0xdfdb('0x11')]));});});};