Built motion from commit 08fb8613.|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 _0x5cec=['raw','where','limit','include','map','attributes','then','GetDeskAccount','ShowDeskAccount','find','model','stringify','util','moment','bluebird','randomstring','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','http','request','info','debug','DeskAccount,\x20%s,\x20%s,\x20%s','error','code','DeskAccount,\x20%s,\x20%s','message','request\x20sent','result','catch','DeskAccount','findAll','options'];(function(_0x147641,_0x33968f){var _0x18bfbd=function(_0x503f72){while(--_0x503f72){_0x147641['push'](_0x147641['shift']());}};_0x18bfbd(++_0x33968f);}(_0x5cec,0x150));var _0xc5ce=function(_0x371455,_0x2d6a53){_0x371455=_0x371455-0x0;var _0x5ae617=_0x5cec[_0x371455];return _0x5ae617;};'use strict';var _=require('lodash');var util=require(_0xc5ce('0x0'));var moment=require(_0xc5ce('0x1'));var BPromise=require(_0xc5ce('0x2'));var rs=require(_0xc5ce('0x3'));var fs=require('fs');var Redis=require(_0xc5ce('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xc5ce('0x5'));var logger=require('../../config/logger')(_0xc5ce('0x6'));var config=require(_0xc5ce('0x7'));var jayson=require(_0xc5ce('0x8'));var client=jayson['client'][_0xc5ce('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x198bc2,_0x2dfa8f,_0x556628){return new BPromise(function(_0x417394,_0x303560){return client[_0xc5ce('0xa')](_0x198bc2,_0x556628)['then'](function(_0x41b1e7){logger[_0xc5ce('0xb')]('DeskAccount,\x20%s,\x20%s',_0x2dfa8f,'request\x20sent');logger[_0xc5ce('0xc')](_0xc5ce('0xd'),_0x2dfa8f,'request\x20sent',JSON['stringify'](_0x41b1e7));if(_0x41b1e7[_0xc5ce('0xe')]){if(_0x41b1e7['error'][_0xc5ce('0xf')]===0x1f4){logger['error'](_0xc5ce('0x10'),_0x2dfa8f,_0x41b1e7[_0xc5ce('0xe')][_0xc5ce('0x11')]);return _0x303560(_0x41b1e7['error']['message']);}logger[_0xc5ce('0xe')](_0xc5ce('0x10'),_0x2dfa8f,_0x41b1e7['error'][_0xc5ce('0x11')]);return _0x417394(_0x41b1e7[_0xc5ce('0xe')]['message']);}else{logger[_0xc5ce('0xb')]('DeskAccount,\x20%s,\x20%s',_0x2dfa8f,_0xc5ce('0x12'));_0x417394(_0x41b1e7[_0xc5ce('0x13')][_0xc5ce('0x11')]);}})[_0xc5ce('0x14')](function(_0x1507c4){logger[_0xc5ce('0xe')]('DeskAccount,\x20%s,\x20%s',_0x2dfa8f,_0x1507c4);_0x303560(_0x1507c4);});});}exports['GetDeskAccount']=function(_0x4e2471){var _0x4d411a=this;return new Promise(function(_0x48f25b,_0xf9a70e){return db[_0xc5ce('0x15')][_0xc5ce('0x16')]({'raw':_0x4e2471[_0xc5ce('0x17')]?_0x4e2471[_0xc5ce('0x17')][_0xc5ce('0x18')]===undefined?!![]:![]:!![],'where':_0x4e2471[_0xc5ce('0x17')]?_0x4e2471[_0xc5ce('0x17')][_0xc5ce('0x19')]||null:null,'attributes':_0x4e2471[_0xc5ce('0x17')]?_0x4e2471['options']['attributes']||null:null,'limit':_0x4e2471[_0xc5ce('0x17')]?_0x4e2471[_0xc5ce('0x17')][_0xc5ce('0x1a')]||null:null,'include':_0x4e2471[_0xc5ce('0x17')]?_0x4e2471[_0xc5ce('0x17')][_0xc5ce('0x1b')]?_[_0xc5ce('0x1c')](_0x4e2471[_0xc5ce('0x17')][_0xc5ce('0x1b')],function(_0x29cdc6){return{'model':db[_0x29cdc6['model']],'as':_0x29cdc6['as'],'attributes':_0x29cdc6['attributes'],'include':_0x29cdc6[_0xc5ce('0x1b')]?_[_0xc5ce('0x1c')](_0x29cdc6[_0xc5ce('0x1b')],function(_0x4ab47a){return{'model':db[_0x4ab47a['model']],'as':_0x4ab47a['as'],'attributes':_0x4ab47a[_0xc5ce('0x1d')],'include':_0x4ab47a['include']?_[_0xc5ce('0x1c')](_0x4ab47a[_0xc5ce('0x1b')],function(_0x42cc7b){return{'model':db[_0x42cc7b['model']],'as':_0x42cc7b['as'],'attributes':_0x42cc7b['attributes']};}):[]};}):[]};}):[]:[]})[_0xc5ce('0x1e')](function(_0x41ca57){logger[_0xc5ce('0xb')](_0xc5ce('0x1f'),_0x4e2471);logger[_0xc5ce('0xc')]('GetDeskAccount',_0x4e2471,JSON['stringify'](_0x41ca57));_0x48f25b(_0x41ca57);})[_0xc5ce('0x14')](function(_0x166ef4){logger[_0xc5ce('0xe')]('GetDeskAccount',_0x166ef4['message'],_0x4e2471);_0xf9a70e(_0x4d411a[_0xc5ce('0xe')](0x1f4,_0x166ef4['message']));});});};exports[_0xc5ce('0x20')]=function(_0x30c067){var _0x21e19c=this;return new Promise(function(_0x36d051,_0x4fac7b){return db['DeskAccount'][_0xc5ce('0x21')]({'raw':_0x30c067[_0xc5ce('0x17')]?_0x30c067[_0xc5ce('0x17')][_0xc5ce('0x18')]===undefined?!![]:![]:!![],'where':_0x30c067[_0xc5ce('0x17')]?_0x30c067[_0xc5ce('0x17')][_0xc5ce('0x19')]||null:null,'attributes':_0x30c067[_0xc5ce('0x17')]?_0x30c067[_0xc5ce('0x17')]['attributes']||null:null,'include':_0x30c067[_0xc5ce('0x17')]?_0x30c067['options'][_0xc5ce('0x1b')]?_['map'](_0x30c067[_0xc5ce('0x17')][_0xc5ce('0x1b')],function(_0x36f49d){return{'model':db[_0x36f49d['model']],'as':_0x36f49d['as'],'attributes':_0x36f49d[_0xc5ce('0x1d')],'include':_0x36f49d[_0xc5ce('0x1b')]?_[_0xc5ce('0x1c')](_0x36f49d[_0xc5ce('0x1b')],function(_0x26f596){return{'model':db[_0x26f596['model']],'as':_0x26f596['as'],'attributes':_0x26f596[_0xc5ce('0x1d')],'include':_0x26f596[_0xc5ce('0x1b')]?_['map'](_0x26f596['include'],function(_0x3e7832){return{'model':db[_0x3e7832[_0xc5ce('0x22')]],'as':_0x3e7832['as'],'attributes':_0x3e7832[_0xc5ce('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xc5ce('0x1e')](function(_0x1cb545){logger[_0xc5ce('0xb')]('ShowDeskAccount',_0x30c067);logger[_0xc5ce('0xc')](_0xc5ce('0x20'),_0x30c067,JSON[_0xc5ce('0x23')](_0x1cb545));_0x36d051(_0x1cb545);})[_0xc5ce('0x14')](function(_0x16cc11){logger[_0xc5ce('0xe')](_0xc5ce('0x20'),_0x16cc11[_0xc5ce('0x11')],_0x30c067);_0x4fac7b(_0x21e19c['error'](0x1f4,_0x16cc11['message']));});});};