Built motion from commit (unavailable).|2.5.4
[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 _0x8740=['client','request','then','info','DeskAccount,\x20%s,\x20%s','request\x20sent','debug','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','GetDeskAccount','findAll','options','where','limit','model','map','include','attributes','catch','raw','ShowDeskAccount','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise'];(function(_0x99f990,_0x2cefea){var _0xa74f46=function(_0x4c0b82){while(--_0x4c0b82){_0x99f990['push'](_0x99f990['shift']());}};_0xa74f46(++_0x2cefea);}(_0x8740,0x16c));var _0x0874=function(_0xbd08b4,_0x4790ed){_0xbd08b4=_0xbd08b4-0x0;var _0x314f1e=_0x8740[_0xbd08b4];return _0x314f1e;};'use strict';var _=require(_0x0874('0x0'));var util=require(_0x0874('0x1'));var moment=require(_0x0874('0x2'));var BPromise=require('bluebird');var rs=require(_0x0874('0x3'));var fs=require('fs');var Redis=require(_0x0874('0x4'));var db=require(_0x0874('0x5'))['db'];var utils=require(_0x0874('0x6'));var logger=require('../../config/logger')(_0x0874('0x7'));var config=require(_0x0874('0x8'));var jayson=require(_0x0874('0x9'));var client=jayson[_0x0874('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4970af,_0x371f47,_0x99d408){return new BPromise(function(_0x47d3a1,_0x1861c9){return client[_0x0874('0xb')](_0x4970af,_0x99d408)[_0x0874('0xc')](function(_0x1bb44a){logger[_0x0874('0xd')](_0x0874('0xe'),_0x371f47,_0x0874('0xf'));logger[_0x0874('0x10')](_0x0874('0x11'),_0x371f47,_0x0874('0xf'),JSON[_0x0874('0x12')](_0x1bb44a));if(_0x1bb44a['error']){if(_0x1bb44a[_0x0874('0x13')][_0x0874('0x14')]===0x1f4){logger[_0x0874('0x13')](_0x0874('0xe'),_0x371f47,_0x1bb44a[_0x0874('0x13')][_0x0874('0x15')]);return _0x1861c9(_0x1bb44a['error']['message']);}logger[_0x0874('0x13')](_0x0874('0xe'),_0x371f47,_0x1bb44a[_0x0874('0x13')]['message']);return _0x47d3a1(_0x1bb44a[_0x0874('0x13')][_0x0874('0x15')]);}else{logger[_0x0874('0xd')](_0x0874('0xe'),_0x371f47,'request\x20sent');_0x47d3a1(_0x1bb44a['result'][_0x0874('0x15')]);}})['catch'](function(_0x43df27){logger[_0x0874('0x13')](_0x0874('0xe'),_0x371f47,_0x43df27);_0x1861c9(_0x43df27);});});}exports[_0x0874('0x16')]=function(_0x194897){var _0x46545d=this;return new Promise(function(_0x2f08c4,_0x4dc7cd){return db['DeskAccount'][_0x0874('0x17')]({'raw':_0x194897[_0x0874('0x18')]?_0x194897[_0x0874('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x194897[_0x0874('0x18')]?_0x194897[_0x0874('0x18')][_0x0874('0x19')]||null:null,'attributes':_0x194897[_0x0874('0x18')]?_0x194897[_0x0874('0x18')]['attributes']||null:null,'limit':_0x194897[_0x0874('0x18')]?_0x194897[_0x0874('0x18')][_0x0874('0x1a')]||null:null,'include':_0x194897[_0x0874('0x18')]?_0x194897[_0x0874('0x18')]['include']?_['map'](_0x194897['options']['include'],function(_0x32edd8){return{'model':db[_0x32edd8[_0x0874('0x1b')]],'as':_0x32edd8['as'],'attributes':_0x32edd8['attributes'],'include':_0x32edd8['include']?_[_0x0874('0x1c')](_0x32edd8[_0x0874('0x1d')],function(_0x57fc88){return{'model':db[_0x57fc88[_0x0874('0x1b')]],'as':_0x57fc88['as'],'attributes':_0x57fc88['attributes'],'include':_0x57fc88[_0x0874('0x1d')]?_[_0x0874('0x1c')](_0x57fc88['include'],function(_0x162537){return{'model':db[_0x162537['model']],'as':_0x162537['as'],'attributes':_0x162537[_0x0874('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x0874('0xc')](function(_0x10d454){logger[_0x0874('0xd')]('GetDeskAccount',_0x194897);logger[_0x0874('0x10')](_0x0874('0x16'),_0x194897,JSON[_0x0874('0x12')](_0x10d454));_0x2f08c4(_0x10d454);})[_0x0874('0x1f')](function(_0x34fc6a){logger[_0x0874('0x13')](_0x0874('0x16'),_0x34fc6a[_0x0874('0x15')],_0x194897);_0x4dc7cd(_0x46545d[_0x0874('0x13')](0x1f4,_0x34fc6a['message']));});});};exports['ShowDeskAccount']=function(_0x168642){var _0x836521=this;return new Promise(function(_0x1fd638,_0x2144a3){return db['DeskAccount']['find']({'raw':_0x168642[_0x0874('0x18')]?_0x168642[_0x0874('0x18')][_0x0874('0x20')]===undefined?!![]:![]:!![],'where':_0x168642[_0x0874('0x18')]?_0x168642['options'][_0x0874('0x19')]||null:null,'attributes':_0x168642[_0x0874('0x18')]?_0x168642[_0x0874('0x18')][_0x0874('0x1e')]||null:null,'include':_0x168642[_0x0874('0x18')]?_0x168642[_0x0874('0x18')]['include']?_[_0x0874('0x1c')](_0x168642[_0x0874('0x18')]['include'],function(_0x45f845){return{'model':db[_0x45f845[_0x0874('0x1b')]],'as':_0x45f845['as'],'attributes':_0x45f845[_0x0874('0x1e')],'include':_0x45f845[_0x0874('0x1d')]?_['map'](_0x45f845[_0x0874('0x1d')],function(_0x3979f6){return{'model':db[_0x3979f6[_0x0874('0x1b')]],'as':_0x3979f6['as'],'attributes':_0x3979f6[_0x0874('0x1e')],'include':_0x3979f6[_0x0874('0x1d')]?_[_0x0874('0x1c')](_0x3979f6[_0x0874('0x1d')],function(_0x5a5bf6){return{'model':db[_0x5a5bf6[_0x0874('0x1b')]],'as':_0x5a5bf6['as'],'attributes':_0x5a5bf6[_0x0874('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x0874('0xc')](function(_0x3bb02f){logger['info'](_0x0874('0x21'),_0x168642);logger[_0x0874('0x10')](_0x0874('0x21'),_0x168642,JSON[_0x0874('0x12')](_0x3bb02f));_0x1fd638(_0x3bb02f);})[_0x0874('0x1f')](function(_0x54a855){logger[_0x0874('0x13')](_0x0874('0x21'),_0x54a855[_0x0874('0x15')],_0x168642);_0x2144a3(_0x836521[_0x0874('0x13')](0x1f4,_0x54a855[_0x0874('0x15')]));});});};