Built motion from commit (unavailable).|2.6.0
[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 _0x4813=['util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','request','then','info','DeskAccount,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','catch','GetDeskAccount','findAll','options','raw','where','attributes','include','model','map','DeskAccount','find','ShowDeskAccount','lodash'];(function(_0x2cdfe2,_0x2458ab){var _0x3d0bd5=function(_0x3b7989){while(--_0x3b7989){_0x2cdfe2['push'](_0x2cdfe2['shift']());}};_0x3d0bd5(++_0x2458ab);}(_0x4813,0x175));var _0x3481=function(_0x343916,_0x331db9){_0x343916=_0x343916-0x0;var _0x173319=_0x4813[_0x343916];return _0x173319;};'use strict';var _=require(_0x3481('0x0'));var util=require(_0x3481('0x1'));var moment=require('moment');var BPromise=require(_0x3481('0x2'));var rs=require(_0x3481('0x3'));var fs=require('fs');var Redis=require(_0x3481('0x4'));var db=require(_0x3481('0x5'))['db'];var utils=require(_0x3481('0x6'));var logger=require(_0x3481('0x7'))('rpc');var config=require(_0x3481('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x3481('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5bf4af,_0x370398,_0x486ec2){return new BPromise(function(_0x19f5b6,_0x42fff0){return client[_0x3481('0xa')](_0x5bf4af,_0x486ec2)[_0x3481('0xb')](function(_0x3b810e){logger[_0x3481('0xc')](_0x3481('0xd'),_0x370398,'request\x20sent');logger[_0x3481('0xe')]('DeskAccount,\x20%s,\x20%s,\x20%s',_0x370398,_0x3481('0xf'),JSON[_0x3481('0x10')](_0x3b810e));if(_0x3b810e['error']){if(_0x3b810e[_0x3481('0x11')][_0x3481('0x12')]===0x1f4){logger[_0x3481('0x11')](_0x3481('0xd'),_0x370398,_0x3b810e['error']['message']);return _0x42fff0(_0x3b810e[_0x3481('0x11')][_0x3481('0x13')]);}logger['error']('DeskAccount,\x20%s,\x20%s',_0x370398,_0x3b810e[_0x3481('0x11')][_0x3481('0x13')]);return _0x19f5b6(_0x3b810e['error'][_0x3481('0x13')]);}else{logger['info']('DeskAccount,\x20%s,\x20%s',_0x370398,_0x3481('0xf'));_0x19f5b6(_0x3b810e[_0x3481('0x14')][_0x3481('0x13')]);}})[_0x3481('0x15')](function(_0x230e6a){logger[_0x3481('0x11')](_0x3481('0xd'),_0x370398,_0x230e6a);_0x42fff0(_0x230e6a);});});}exports[_0x3481('0x16')]=function(_0x28e160){var _0x39ec6a=this;return new Promise(function(_0x52ef79,_0x4237fb){return db['DeskAccount'][_0x3481('0x17')]({'raw':_0x28e160['options']?_0x28e160[_0x3481('0x18')][_0x3481('0x19')]===undefined?!![]:![]:!![],'where':_0x28e160[_0x3481('0x18')]?_0x28e160[_0x3481('0x18')][_0x3481('0x1a')]||null:null,'attributes':_0x28e160[_0x3481('0x18')]?_0x28e160[_0x3481('0x18')][_0x3481('0x1b')]||null:null,'limit':_0x28e160[_0x3481('0x18')]?_0x28e160['options']['limit']||null:null,'include':_0x28e160[_0x3481('0x18')]?_0x28e160[_0x3481('0x18')][_0x3481('0x1c')]?_['map'](_0x28e160['options'][_0x3481('0x1c')],function(_0x162b87){return{'model':db[_0x162b87['model']],'as':_0x162b87['as'],'attributes':_0x162b87['attributes'],'include':_0x162b87['include']?_['map'](_0x162b87[_0x3481('0x1c')],function(_0x58e2c8){return{'model':db[_0x58e2c8[_0x3481('0x1d')]],'as':_0x58e2c8['as'],'attributes':_0x58e2c8[_0x3481('0x1b')],'include':_0x58e2c8['include']?_[_0x3481('0x1e')](_0x58e2c8[_0x3481('0x1c')],function(_0x3c490d){return{'model':db[_0x3c490d[_0x3481('0x1d')]],'as':_0x3c490d['as'],'attributes':_0x3c490d['attributes']};}):[]};}):[]};}):[]:[]})[_0x3481('0xb')](function(_0x5c6f2b){logger[_0x3481('0xc')]('GetDeskAccount',_0x28e160);logger[_0x3481('0xe')](_0x3481('0x16'),_0x28e160,JSON[_0x3481('0x10')](_0x5c6f2b));_0x52ef79(_0x5c6f2b);})['catch'](function(_0x20704e){logger[_0x3481('0x11')](_0x3481('0x16'),_0x20704e[_0x3481('0x13')],_0x28e160);_0x4237fb(_0x39ec6a[_0x3481('0x11')](0x1f4,_0x20704e[_0x3481('0x13')]));});});};exports['ShowDeskAccount']=function(_0x7838c4){var _0x18a32e=this;return new Promise(function(_0x25890c,_0x34b213){return db[_0x3481('0x1f')][_0x3481('0x20')]({'raw':_0x7838c4['options']?_0x7838c4[_0x3481('0x18')][_0x3481('0x19')]===undefined?!![]:![]:!![],'where':_0x7838c4[_0x3481('0x18')]?_0x7838c4[_0x3481('0x18')][_0x3481('0x1a')]||null:null,'attributes':_0x7838c4[_0x3481('0x18')]?_0x7838c4['options']['attributes']||null:null,'include':_0x7838c4[_0x3481('0x18')]?_0x7838c4[_0x3481('0x18')][_0x3481('0x1c')]?_[_0x3481('0x1e')](_0x7838c4[_0x3481('0x18')][_0x3481('0x1c')],function(_0x250a07){return{'model':db[_0x250a07[_0x3481('0x1d')]],'as':_0x250a07['as'],'attributes':_0x250a07[_0x3481('0x1b')],'include':_0x250a07['include']?_['map'](_0x250a07['include'],function(_0x4e787a){return{'model':db[_0x4e787a['model']],'as':_0x4e787a['as'],'attributes':_0x4e787a[_0x3481('0x1b')],'include':_0x4e787a[_0x3481('0x1c')]?_['map'](_0x4e787a[_0x3481('0x1c')],function(_0x44f970){return{'model':db[_0x44f970[_0x3481('0x1d')]],'as':_0x44f970['as'],'attributes':_0x44f970[_0x3481('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x3481('0xb')](function(_0x5bfafa){logger[_0x3481('0xc')](_0x3481('0x21'),_0x7838c4);logger[_0x3481('0xe')](_0x3481('0x21'),_0x7838c4,JSON[_0x3481('0x10')](_0x5bfafa));_0x25890c(_0x5bfafa);})[_0x3481('0x15')](function(_0x2ae50c){logger[_0x3481('0x11')](_0x3481('0x21'),_0x2ae50c[_0x3481('0x13')],_0x7838c4);_0x34b213(_0x18a32e[_0x3481('0x11')](0x1f4,_0x2ae50c[_0x3481('0x13')]));});});};