09792706292adf46cfd558cea007f6a8b28fdd20
[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 _0x4492=['code','DeskAccount,\x20%s,\x20%s','message','GetDeskAccount','findAll','options','where','attributes','map','include','model','catch','ShowDeskAccount','DeskAccount','find','stringify','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','then','info','request\x20sent','debug','DeskAccount,\x20%s,\x20%s,\x20%s','error'];(function(_0x55b0de,_0xbfff48){var _0x3ee40b=function(_0x3cb588){while(--_0x3cb588){_0x55b0de['push'](_0x55b0de['shift']());}};_0x3ee40b(++_0xbfff48);}(_0x4492,0x110));var _0x2449=function(_0x5ade35,_0x35cec6){_0x5ade35=_0x5ade35-0x0;var _0x21d317=_0x4492[_0x5ade35];return _0x21d317;};'use strict';var _=require(_0x2449('0x0'));var util=require('util');var moment=require(_0x2449('0x1'));var BPromise=require(_0x2449('0x2'));var rs=require(_0x2449('0x3'));var fs=require('fs');var Redis=require(_0x2449('0x4'));var db=require(_0x2449('0x5'))['db'];var utils=require(_0x2449('0x6'));var logger=require('../../config/logger')(_0x2449('0x7'));var config=require(_0x2449('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x2449('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1b4742,_0x85a990,_0x2725fc){return new BPromise(function(_0xa20c5d,_0x1a4a69){return client['request'](_0x1b4742,_0x2725fc)[_0x2449('0xa')](function(_0x5afecf){logger[_0x2449('0xb')]('DeskAccount,\x20%s,\x20%s',_0x85a990,_0x2449('0xc'));logger[_0x2449('0xd')](_0x2449('0xe'),_0x85a990,_0x2449('0xc'),JSON['stringify'](_0x5afecf));if(_0x5afecf[_0x2449('0xf')]){if(_0x5afecf['error'][_0x2449('0x10')]===0x1f4){logger[_0x2449('0xf')](_0x2449('0x11'),_0x85a990,_0x5afecf[_0x2449('0xf')][_0x2449('0x12')]);return _0x1a4a69(_0x5afecf[_0x2449('0xf')][_0x2449('0x12')]);}logger['error']('DeskAccount,\x20%s,\x20%s',_0x85a990,_0x5afecf[_0x2449('0xf')][_0x2449('0x12')]);return _0xa20c5d(_0x5afecf[_0x2449('0xf')][_0x2449('0x12')]);}else{logger['info'](_0x2449('0x11'),_0x85a990,_0x2449('0xc'));_0xa20c5d(_0x5afecf['result'][_0x2449('0x12')]);}})['catch'](function(_0x542ce){logger[_0x2449('0xf')](_0x2449('0x11'),_0x85a990,_0x542ce);_0x1a4a69(_0x542ce);});});}exports[_0x2449('0x13')]=function(_0x12f256){var _0x216260=this;return new Promise(function(_0x1b02fe,_0x2f3b09){return db['DeskAccount'][_0x2449('0x14')]({'raw':_0x12f256['options']?_0x12f256[_0x2449('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x12f256[_0x2449('0x15')]?_0x12f256['options'][_0x2449('0x16')]||null:null,'attributes':_0x12f256[_0x2449('0x15')]?_0x12f256[_0x2449('0x15')][_0x2449('0x17')]||null:null,'limit':_0x12f256[_0x2449('0x15')]?_0x12f256[_0x2449('0x15')]['limit']||null:null,'include':_0x12f256[_0x2449('0x15')]?_0x12f256[_0x2449('0x15')]['include']?_[_0x2449('0x18')](_0x12f256['options'][_0x2449('0x19')],function(_0xa43ccb){return{'model':db[_0xa43ccb[_0x2449('0x1a')]],'as':_0xa43ccb['as'],'attributes':_0xa43ccb[_0x2449('0x17')],'include':_0xa43ccb[_0x2449('0x19')]?_[_0x2449('0x18')](_0xa43ccb[_0x2449('0x19')],function(_0x50a1b5){return{'model':db[_0x50a1b5[_0x2449('0x1a')]],'as':_0x50a1b5['as'],'attributes':_0x50a1b5[_0x2449('0x17')],'include':_0x50a1b5['include']?_[_0x2449('0x18')](_0x50a1b5[_0x2449('0x19')],function(_0x4b5633){return{'model':db[_0x4b5633[_0x2449('0x1a')]],'as':_0x4b5633['as'],'attributes':_0x4b5633[_0x2449('0x17')]};}):[]};}):[]};}):[]:[]})[_0x2449('0xa')](function(_0x3a2295){logger[_0x2449('0xb')](_0x2449('0x13'),_0x12f256);logger['debug'](_0x2449('0x13'),_0x12f256,JSON['stringify'](_0x3a2295));_0x1b02fe(_0x3a2295);})[_0x2449('0x1b')](function(_0x4c227b){logger['error'](_0x2449('0x13'),_0x4c227b[_0x2449('0x12')],_0x12f256);_0x2f3b09(_0x216260[_0x2449('0xf')](0x1f4,_0x4c227b['message']));});});};exports[_0x2449('0x1c')]=function(_0x50cb5b){var _0x3e4be0=this;return new Promise(function(_0x2d0095,_0x4772d7){return db[_0x2449('0x1d')][_0x2449('0x1e')]({'raw':_0x50cb5b[_0x2449('0x15')]?_0x50cb5b[_0x2449('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x50cb5b[_0x2449('0x15')]?_0x50cb5b[_0x2449('0x15')][_0x2449('0x16')]||null:null,'attributes':_0x50cb5b['options']?_0x50cb5b[_0x2449('0x15')][_0x2449('0x17')]||null:null,'include':_0x50cb5b[_0x2449('0x15')]?_0x50cb5b[_0x2449('0x15')][_0x2449('0x19')]?_['map'](_0x50cb5b[_0x2449('0x15')]['include'],function(_0x2ee23b){return{'model':db[_0x2ee23b[_0x2449('0x1a')]],'as':_0x2ee23b['as'],'attributes':_0x2ee23b['attributes'],'include':_0x2ee23b['include']?_['map'](_0x2ee23b[_0x2449('0x19')],function(_0x1d33ff){return{'model':db[_0x1d33ff['model']],'as':_0x1d33ff['as'],'attributes':_0x1d33ff[_0x2449('0x17')],'include':_0x1d33ff[_0x2449('0x19')]?_[_0x2449('0x18')](_0x1d33ff[_0x2449('0x19')],function(_0x516074){return{'model':db[_0x516074[_0x2449('0x1a')]],'as':_0x516074['as'],'attributes':_0x516074[_0x2449('0x17')]};}):[]};}):[]};}):[]:[]})[_0x2449('0xa')](function(_0x3fc85d){logger[_0x2449('0xb')](_0x2449('0x1c'),_0x50cb5b);logger[_0x2449('0xd')](_0x2449('0x1c'),_0x50cb5b,JSON[_0x2449('0x1f')](_0x3fc85d));_0x2d0095(_0x3fc85d);})[_0x2449('0x1b')](function(_0x3c485e){logger[_0x2449('0xf')](_0x2449('0x1c'),_0x3c485e[_0x2449('0x12')],_0x50cb5b);_0x4772d7(_0x3e4be0[_0x2449('0xf')](0x1f4,_0x3c485e['message']));});});};