Built motion from commit 91ed41ac.|2.5.44
[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 _0x6a21=['client','request','info','DeskAccount,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','GetDeskAccount','DeskAccount','findAll','options','raw','where','attributes','limit','include','map','model','then','debug','find','ShowDeskAccount','lodash','moment','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x187ee1,_0x3fd1e6){var _0x388160=function(_0x542dd2){while(--_0x542dd2){_0x187ee1['push'](_0x187ee1['shift']());}};_0x388160(++_0x3fd1e6);}(_0x6a21,0x129));var _0x16a2=function(_0x4e84bd,_0x19f5b8){_0x4e84bd=_0x4e84bd-0x0;var _0x19c922=_0x6a21[_0x4e84bd];return _0x19c922;};'use strict';var _=require(_0x16a2('0x0'));var util=require('util');var moment=require(_0x16a2('0x1'));var BPromise=require(_0x16a2('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x16a2('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x16a2('0x4'));var logger=require(_0x16a2('0x5'))(_0x16a2('0x6'));var config=require(_0x16a2('0x7'));var jayson=require(_0x16a2('0x8'));var client=jayson[_0x16a2('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0xfa7aba,_0xa143ac,_0x39053e){return new BPromise(function(_0xb39b7c,_0x2db0b5){return client[_0x16a2('0xa')](_0xfa7aba,_0x39053e)['then'](function(_0x272e6d){logger[_0x16a2('0xb')](_0x16a2('0xc'),_0xa143ac,'request\x20sent');logger['debug']('DeskAccount,\x20%s,\x20%s,\x20%s',_0xa143ac,_0x16a2('0xd'),JSON[_0x16a2('0xe')](_0x272e6d));if(_0x272e6d[_0x16a2('0xf')]){if(_0x272e6d[_0x16a2('0xf')][_0x16a2('0x10')]===0x1f4){logger[_0x16a2('0xf')](_0x16a2('0xc'),_0xa143ac,_0x272e6d[_0x16a2('0xf')][_0x16a2('0x11')]);return _0x2db0b5(_0x272e6d[_0x16a2('0xf')][_0x16a2('0x11')]);}logger[_0x16a2('0xf')](_0x16a2('0xc'),_0xa143ac,_0x272e6d['error'][_0x16a2('0x11')]);return _0xb39b7c(_0x272e6d[_0x16a2('0xf')][_0x16a2('0x11')]);}else{logger[_0x16a2('0xb')](_0x16a2('0xc'),_0xa143ac,_0x16a2('0xd'));_0xb39b7c(_0x272e6d['result'][_0x16a2('0x11')]);}})[_0x16a2('0x12')](function(_0x3e7342){logger[_0x16a2('0xf')](_0x16a2('0xc'),_0xa143ac,_0x3e7342);_0x2db0b5(_0x3e7342);});});}exports[_0x16a2('0x13')]=function(_0x2c4624){var _0x3c7bb7=this;return new Promise(function(_0x328b9f,_0xc93157){return db[_0x16a2('0x14')][_0x16a2('0x15')]({'raw':_0x2c4624[_0x16a2('0x16')]?_0x2c4624['options'][_0x16a2('0x17')]===undefined?!![]:![]:!![],'where':_0x2c4624['options']?_0x2c4624[_0x16a2('0x16')][_0x16a2('0x18')]||null:null,'attributes':_0x2c4624[_0x16a2('0x16')]?_0x2c4624[_0x16a2('0x16')][_0x16a2('0x19')]||null:null,'limit':_0x2c4624[_0x16a2('0x16')]?_0x2c4624[_0x16a2('0x16')][_0x16a2('0x1a')]||null:null,'include':_0x2c4624[_0x16a2('0x16')]?_0x2c4624[_0x16a2('0x16')][_0x16a2('0x1b')]?_[_0x16a2('0x1c')](_0x2c4624[_0x16a2('0x16')]['include'],function(_0x26d970){return{'model':db[_0x26d970[_0x16a2('0x1d')]],'as':_0x26d970['as'],'attributes':_0x26d970[_0x16a2('0x19')],'include':_0x26d970[_0x16a2('0x1b')]?_[_0x16a2('0x1c')](_0x26d970[_0x16a2('0x1b')],function(_0x268b9d){return{'model':db[_0x268b9d[_0x16a2('0x1d')]],'as':_0x268b9d['as'],'attributes':_0x268b9d[_0x16a2('0x19')],'include':_0x268b9d[_0x16a2('0x1b')]?_[_0x16a2('0x1c')](_0x268b9d[_0x16a2('0x1b')],function(_0x1d5a9b){return{'model':db[_0x1d5a9b['model']],'as':_0x1d5a9b['as'],'attributes':_0x1d5a9b[_0x16a2('0x19')]};}):[]};}):[]};}):[]:[]})[_0x16a2('0x1e')](function(_0x5afa68){logger[_0x16a2('0xb')](_0x16a2('0x13'),_0x2c4624);logger[_0x16a2('0x1f')](_0x16a2('0x13'),_0x2c4624,JSON[_0x16a2('0xe')](_0x5afa68));_0x328b9f(_0x5afa68);})[_0x16a2('0x12')](function(_0x54f141){logger[_0x16a2('0xf')]('GetDeskAccount',_0x54f141['message'],_0x2c4624);_0xc93157(_0x3c7bb7[_0x16a2('0xf')](0x1f4,_0x54f141[_0x16a2('0x11')]));});});};exports['ShowDeskAccount']=function(_0x5e5a19){var _0xd665d4=this;return new Promise(function(_0x6ae0cd,_0x390cd0){return db[_0x16a2('0x14')][_0x16a2('0x20')]({'raw':_0x5e5a19[_0x16a2('0x16')]?_0x5e5a19[_0x16a2('0x16')][_0x16a2('0x17')]===undefined?!![]:![]:!![],'where':_0x5e5a19[_0x16a2('0x16')]?_0x5e5a19[_0x16a2('0x16')][_0x16a2('0x18')]||null:null,'attributes':_0x5e5a19['options']?_0x5e5a19[_0x16a2('0x16')][_0x16a2('0x19')]||null:null,'include':_0x5e5a19['options']?_0x5e5a19[_0x16a2('0x16')][_0x16a2('0x1b')]?_[_0x16a2('0x1c')](_0x5e5a19[_0x16a2('0x16')][_0x16a2('0x1b')],function(_0x4c4512){return{'model':db[_0x4c4512['model']],'as':_0x4c4512['as'],'attributes':_0x4c4512[_0x16a2('0x19')],'include':_0x4c4512[_0x16a2('0x1b')]?_[_0x16a2('0x1c')](_0x4c4512['include'],function(_0x552236){return{'model':db[_0x552236[_0x16a2('0x1d')]],'as':_0x552236['as'],'attributes':_0x552236[_0x16a2('0x19')],'include':_0x552236[_0x16a2('0x1b')]?_[_0x16a2('0x1c')](_0x552236['include'],function(_0x2a9458){return{'model':db[_0x2a9458[_0x16a2('0x1d')]],'as':_0x2a9458['as'],'attributes':_0x2a9458[_0x16a2('0x19')]};}):[]};}):[]};}):[]:[]})[_0x16a2('0x1e')](function(_0x50593b){logger[_0x16a2('0xb')]('ShowDeskAccount',_0x5e5a19);logger['debug'](_0x16a2('0x21'),_0x5e5a19,JSON[_0x16a2('0xe')](_0x50593b));_0x6ae0cd(_0x50593b);})[_0x16a2('0x12')](function(_0x175b2d){logger[_0x16a2('0xf')](_0x16a2('0x21'),_0x175b2d['message'],_0x5e5a19);_0x390cd0(_0xd665d4[_0x16a2('0xf')](0x1f4,_0x175b2d[_0x16a2('0x11')]));});});};