Built motion from commit 4fa9d4a7.|2.6.31
[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 _0xf543=['moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','DeskAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','DeskAccount','findAll','options','raw','where','attributes','include','model','map','then','GetDeskAccount','catch','ShowDeskAccount','find','util'];(function(_0x4dc7b9,_0x319d5a){var _0x3ab114=function(_0x51a9df){while(--_0x51a9df){_0x4dc7b9['push'](_0x4dc7b9['shift']());}};_0x3ab114(++_0x319d5a);}(_0xf543,0x1e9));var _0x3f54=function(_0x1b6b51,_0x157bf2){_0x1b6b51=_0x1b6b51-0x0;var _0xc73faf=_0xf543[_0x1b6b51];return _0xc73faf;};'use strict';var _=require('lodash');var util=require(_0x3f54('0x0'));var moment=require(_0x3f54('0x1'));var BPromise=require(_0x3f54('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x3f54('0x3'));var db=require(_0x3f54('0x4'))['db'];var utils=require(_0x3f54('0x5'));var logger=require(_0x3f54('0x6'))('rpc');var config=require(_0x3f54('0x7'));var jayson=require(_0x3f54('0x8'));var client=jayson[_0x3f54('0x9')][_0x3f54('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x31c717,_0x3adfc5,_0x28519b){return new BPromise(function(_0x5e35cc,_0xb12fdd){return client[_0x3f54('0xb')](_0x31c717,_0x28519b)['then'](function(_0x1a86f5){logger['info'](_0x3f54('0xc'),_0x3adfc5,_0x3f54('0xd'));logger[_0x3f54('0xe')]('DeskAccount,\x20%s,\x20%s,\x20%s',_0x3adfc5,_0x3f54('0xd'),JSON[_0x3f54('0xf')](_0x1a86f5));if(_0x1a86f5[_0x3f54('0x10')]){if(_0x1a86f5[_0x3f54('0x10')][_0x3f54('0x11')]===0x1f4){logger['error'](_0x3f54('0xc'),_0x3adfc5,_0x1a86f5['error'][_0x3f54('0x12')]);return _0xb12fdd(_0x1a86f5[_0x3f54('0x10')][_0x3f54('0x12')]);}logger[_0x3f54('0x10')]('DeskAccount,\x20%s,\x20%s',_0x3adfc5,_0x1a86f5[_0x3f54('0x10')][_0x3f54('0x12')]);return _0x5e35cc(_0x1a86f5[_0x3f54('0x10')]['message']);}else{logger[_0x3f54('0x13')]('DeskAccount,\x20%s,\x20%s',_0x3adfc5,_0x3f54('0xd'));_0x5e35cc(_0x1a86f5[_0x3f54('0x14')][_0x3f54('0x12')]);}})['catch'](function(_0xad05e9){logger[_0x3f54('0x10')](_0x3f54('0xc'),_0x3adfc5,_0xad05e9);_0xb12fdd(_0xad05e9);});});}exports['GetDeskAccount']=function(_0x557732){var _0xb8686=this;return new Promise(function(_0x137b87,_0x5c1a0c){return db[_0x3f54('0x15')][_0x3f54('0x16')]({'raw':_0x557732[_0x3f54('0x17')]?_0x557732['options'][_0x3f54('0x18')]===undefined?!![]:![]:!![],'where':_0x557732[_0x3f54('0x17')]?_0x557732[_0x3f54('0x17')][_0x3f54('0x19')]||null:null,'attributes':_0x557732['options']?_0x557732[_0x3f54('0x17')][_0x3f54('0x1a')]||null:null,'limit':_0x557732[_0x3f54('0x17')]?_0x557732[_0x3f54('0x17')]['limit']||null:null,'include':_0x557732[_0x3f54('0x17')]?_0x557732[_0x3f54('0x17')][_0x3f54('0x1b')]?_['map'](_0x557732[_0x3f54('0x17')][_0x3f54('0x1b')],function(_0x50beb2){return{'model':db[_0x50beb2[_0x3f54('0x1c')]],'as':_0x50beb2['as'],'attributes':_0x50beb2[_0x3f54('0x1a')],'include':_0x50beb2['include']?_[_0x3f54('0x1d')](_0x50beb2[_0x3f54('0x1b')],function(_0x4413e6){return{'model':db[_0x4413e6[_0x3f54('0x1c')]],'as':_0x4413e6['as'],'attributes':_0x4413e6[_0x3f54('0x1a')],'include':_0x4413e6[_0x3f54('0x1b')]?_[_0x3f54('0x1d')](_0x4413e6['include'],function(_0x256faa){return{'model':db[_0x256faa[_0x3f54('0x1c')]],'as':_0x256faa['as'],'attributes':_0x256faa[_0x3f54('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x3f54('0x1e')](function(_0x2e0b08){logger[_0x3f54('0x13')](_0x3f54('0x1f'),_0x557732);logger[_0x3f54('0xe')](_0x3f54('0x1f'),_0x557732,JSON[_0x3f54('0xf')](_0x2e0b08));_0x137b87(_0x2e0b08);})[_0x3f54('0x20')](function(_0x5d82d7){logger[_0x3f54('0x10')](_0x3f54('0x1f'),_0x5d82d7[_0x3f54('0x12')],_0x557732);_0x5c1a0c(_0xb8686[_0x3f54('0x10')](0x1f4,_0x5d82d7[_0x3f54('0x12')]));});});};exports[_0x3f54('0x21')]=function(_0x1d6729){var _0x2329c6=this;return new Promise(function(_0x1173c8,_0x1457db){return db[_0x3f54('0x15')][_0x3f54('0x22')]({'raw':_0x1d6729[_0x3f54('0x17')]?_0x1d6729[_0x3f54('0x17')][_0x3f54('0x18')]===undefined?!![]:![]:!![],'where':_0x1d6729['options']?_0x1d6729['options'][_0x3f54('0x19')]||null:null,'attributes':_0x1d6729[_0x3f54('0x17')]?_0x1d6729[_0x3f54('0x17')][_0x3f54('0x1a')]||null:null,'include':_0x1d6729[_0x3f54('0x17')]?_0x1d6729[_0x3f54('0x17')]['include']?_[_0x3f54('0x1d')](_0x1d6729[_0x3f54('0x17')]['include'],function(_0x5c62e3){return{'model':db[_0x5c62e3[_0x3f54('0x1c')]],'as':_0x5c62e3['as'],'attributes':_0x5c62e3['attributes'],'include':_0x5c62e3['include']?_[_0x3f54('0x1d')](_0x5c62e3['include'],function(_0x2ce39d){return{'model':db[_0x2ce39d[_0x3f54('0x1c')]],'as':_0x2ce39d['as'],'attributes':_0x2ce39d[_0x3f54('0x1a')],'include':_0x2ce39d[_0x3f54('0x1b')]?_[_0x3f54('0x1d')](_0x2ce39d[_0x3f54('0x1b')],function(_0x4ff65a){return{'model':db[_0x4ff65a[_0x3f54('0x1c')]],'as':_0x4ff65a['as'],'attributes':_0x4ff65a[_0x3f54('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x3f54('0x1e')](function(_0x5c4de4){logger[_0x3f54('0x13')](_0x3f54('0x21'),_0x1d6729);logger[_0x3f54('0xe')](_0x3f54('0x21'),_0x1d6729,JSON[_0x3f54('0xf')](_0x5c4de4));_0x1173c8(_0x5c4de4);})[_0x3f54('0x20')](function(_0x3b5ce7){logger['error'](_0x3f54('0x21'),_0x3b5ce7['message'],_0x1d6729);_0x1457db(_0x2329c6[_0x3f54('0x10')](0x1f4,_0x3b5ce7['message']));});});};