Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intDeskAccount / intDeskAccount.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 _0xb98a=['client','http','request','then','info','DeskAccount,\x20%s,\x20%s','request\x20sent','debug','DeskAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetDeskAccount','findAll','options','attributes','limit','include','map','model','ShowDeskAccount','DeskAccount','find','raw','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise'];(function(_0x318837,_0x5f2ae1){var _0x258c33=function(_0x105806){while(--_0x105806){_0x318837['push'](_0x318837['shift']());}};_0x258c33(++_0x5f2ae1);}(_0xb98a,0x67));var _0xab98=function(_0x411bd1,_0x416106){_0x411bd1=_0x411bd1-0x0;var _0x320464=_0xb98a[_0x411bd1];return _0x320464;};'use strict';var _=require(_0xab98('0x0'));var util=require(_0xab98('0x1'));var moment=require(_0xab98('0x2'));var BPromise=require(_0xab98('0x3'));var rs=require(_0xab98('0x4'));var fs=require('fs');var Redis=require(_0xab98('0x5'));var db=require(_0xab98('0x6'))['db'];var utils=require(_0xab98('0x7'));var logger=require(_0xab98('0x8'))(_0xab98('0x9'));var config=require('../../config/environment');var jayson=require(_0xab98('0xa'));var client=jayson[_0xab98('0xb')][_0xab98('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x1b5db0,_0x2313db,_0x499fde){return new BPromise(function(_0x3d44f3,_0x13b72b){return client[_0xab98('0xd')](_0x1b5db0,_0x499fde)[_0xab98('0xe')](function(_0x33fdf1){logger[_0xab98('0xf')](_0xab98('0x10'),_0x2313db,_0xab98('0x11'));logger[_0xab98('0x12')](_0xab98('0x13'),_0x2313db,_0xab98('0x11'),JSON['stringify'](_0x33fdf1));if(_0x33fdf1[_0xab98('0x14')]){if(_0x33fdf1[_0xab98('0x14')][_0xab98('0x15')]===0x1f4){logger[_0xab98('0x14')](_0xab98('0x10'),_0x2313db,_0x33fdf1[_0xab98('0x14')][_0xab98('0x16')]);return _0x13b72b(_0x33fdf1['error']['message']);}logger['error'](_0xab98('0x10'),_0x2313db,_0x33fdf1[_0xab98('0x14')]['message']);return _0x3d44f3(_0x33fdf1[_0xab98('0x14')]['message']);}else{logger[_0xab98('0xf')]('DeskAccount,\x20%s,\x20%s',_0x2313db,'request\x20sent');_0x3d44f3(_0x33fdf1[_0xab98('0x17')]['message']);}})[_0xab98('0x18')](function(_0x84a8a4){logger['error'](_0xab98('0x10'),_0x2313db,_0x84a8a4);_0x13b72b(_0x84a8a4);});});}exports[_0xab98('0x19')]=function(_0x12d408){var _0x5ed720=this;return new Promise(function(_0x455fc3,_0x38a5b7){return db['DeskAccount'][_0xab98('0x1a')]({'raw':_0x12d408[_0xab98('0x1b')]?_0x12d408['options']['raw']===undefined?!![]:![]:!![],'where':_0x12d408[_0xab98('0x1b')]?_0x12d408[_0xab98('0x1b')]['where']||null:null,'attributes':_0x12d408[_0xab98('0x1b')]?_0x12d408[_0xab98('0x1b')][_0xab98('0x1c')]||null:null,'limit':_0x12d408[_0xab98('0x1b')]?_0x12d408[_0xab98('0x1b')][_0xab98('0x1d')]||null:null,'include':_0x12d408['options']?_0x12d408[_0xab98('0x1b')][_0xab98('0x1e')]?_[_0xab98('0x1f')](_0x12d408[_0xab98('0x1b')][_0xab98('0x1e')],function(_0x2442b6){return{'model':db[_0x2442b6[_0xab98('0x20')]],'as':_0x2442b6['as'],'attributes':_0x2442b6[_0xab98('0x1c')],'include':_0x2442b6[_0xab98('0x1e')]?_[_0xab98('0x1f')](_0x2442b6[_0xab98('0x1e')],function(_0x5472e8){return{'model':db[_0x5472e8[_0xab98('0x20')]],'as':_0x5472e8['as'],'attributes':_0x5472e8[_0xab98('0x1c')],'include':_0x5472e8[_0xab98('0x1e')]?_[_0xab98('0x1f')](_0x5472e8[_0xab98('0x1e')],function(_0x5350b3){return{'model':db[_0x5350b3['model']],'as':_0x5350b3['as'],'attributes':_0x5350b3[_0xab98('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x12ab89){logger[_0xab98('0xf')]('GetDeskAccount',_0x12d408);logger['debug'](_0xab98('0x19'),_0x12d408,JSON['stringify'](_0x12ab89));_0x455fc3(_0x12ab89);})['catch'](function(_0x1e2100){logger[_0xab98('0x14')](_0xab98('0x19'),_0x1e2100['message'],_0x12d408);_0x38a5b7(_0x5ed720['error'](0x1f4,_0x1e2100[_0xab98('0x16')]));});});};exports[_0xab98('0x21')]=function(_0x7047d4){var _0x2d1508=this;return new Promise(function(_0x299053,_0x3b7a0f){return db[_0xab98('0x22')][_0xab98('0x23')]({'raw':_0x7047d4[_0xab98('0x1b')]?_0x7047d4[_0xab98('0x1b')][_0xab98('0x24')]===undefined?!![]:![]:!![],'where':_0x7047d4[_0xab98('0x1b')]?_0x7047d4[_0xab98('0x1b')]['where']||null:null,'attributes':_0x7047d4['options']?_0x7047d4['options'][_0xab98('0x1c')]||null:null,'include':_0x7047d4[_0xab98('0x1b')]?_0x7047d4[_0xab98('0x1b')][_0xab98('0x1e')]?_['map'](_0x7047d4[_0xab98('0x1b')]['include'],function(_0x110092){return{'model':db[_0x110092[_0xab98('0x20')]],'as':_0x110092['as'],'attributes':_0x110092['attributes'],'include':_0x110092['include']?_[_0xab98('0x1f')](_0x110092['include'],function(_0x2d6882){return{'model':db[_0x2d6882['model']],'as':_0x2d6882['as'],'attributes':_0x2d6882[_0xab98('0x1c')],'include':_0x2d6882[_0xab98('0x1e')]?_[_0xab98('0x1f')](_0x2d6882[_0xab98('0x1e')],function(_0x3724a4){return{'model':db[_0x3724a4[_0xab98('0x20')]],'as':_0x3724a4['as'],'attributes':_0x3724a4[_0xab98('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xab98('0xe')](function(_0x5ec9cd){logger[_0xab98('0xf')](_0xab98('0x21'),_0x7047d4);logger[_0xab98('0x12')]('ShowDeskAccount',_0x7047d4,JSON[_0xab98('0x25')](_0x5ec9cd));_0x299053(_0x5ec9cd);})[_0xab98('0x18')](function(_0x1c803c){logger[_0xab98('0x14')](_0xab98('0x21'),_0x1c803c['message'],_0x7047d4);_0x3b7a0f(_0x2d1508[_0xab98('0x14')](0x1f4,_0x1c803c[_0xab98('0x16')]));});});};