7a88018f8bba171f07449595d0266a033d00bc72
[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 _0xc3e0=['../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','then','info','DeskAccount,\x20%s,\x20%s','debug','DeskAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','GetDeskAccount','DeskAccount','findAll','options','raw','where','attributes','include','map','model','catch','find','ShowDeskAccount','stringify','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb'];(function(_0x3ab51d,_0x2fa01d){var _0x29a04e=function(_0x7807b0){while(--_0x7807b0){_0x3ab51d['push'](_0x3ab51d['shift']());}};_0x29a04e(++_0x2fa01d);}(_0xc3e0,0x1db));var _0x0c3e=function(_0x4e55fb,_0x1f2322){_0x4e55fb=_0x4e55fb-0x0;var _0x57deda=_0xc3e0[_0x4e55fb];return _0x57deda;};'use strict';var _=require(_0x0c3e('0x0'));var util=require('util');var moment=require(_0x0c3e('0x1'));var BPromise=require(_0x0c3e('0x2'));var rs=require(_0x0c3e('0x3'));var fs=require('fs');var Redis=require(_0x0c3e('0x4'));var db=require(_0x0c3e('0x5'))['db'];var utils=require(_0x0c3e('0x6'));var logger=require('../../config/logger')(_0x0c3e('0x7'));var config=require(_0x0c3e('0x8'));var jayson=require(_0x0c3e('0x9'));var client=jayson[_0x0c3e('0xa')][_0x0c3e('0xb')]({'port':0x232a});function respondWithRpcPromise(_0xdaaf5f,_0x2fde05,_0x148edd){return new BPromise(function(_0x4823fd,_0x341548){return client[_0x0c3e('0xc')](_0xdaaf5f,_0x148edd)[_0x0c3e('0xd')](function(_0x5ecdde){logger[_0x0c3e('0xe')](_0x0c3e('0xf'),_0x2fde05,'request\x20sent');logger[_0x0c3e('0x10')](_0x0c3e('0x11'),_0x2fde05,_0x0c3e('0x12'),JSON['stringify'](_0x5ecdde));if(_0x5ecdde[_0x0c3e('0x13')]){if(_0x5ecdde[_0x0c3e('0x13')][_0x0c3e('0x14')]===0x1f4){logger[_0x0c3e('0x13')](_0x0c3e('0xf'),_0x2fde05,_0x5ecdde[_0x0c3e('0x13')][_0x0c3e('0x15')]);return _0x341548(_0x5ecdde['error'][_0x0c3e('0x15')]);}logger[_0x0c3e('0x13')](_0x0c3e('0xf'),_0x2fde05,_0x5ecdde[_0x0c3e('0x13')]['message']);return _0x4823fd(_0x5ecdde[_0x0c3e('0x13')][_0x0c3e('0x15')]);}else{logger[_0x0c3e('0xe')]('DeskAccount,\x20%s,\x20%s',_0x2fde05,_0x0c3e('0x12'));_0x4823fd(_0x5ecdde[_0x0c3e('0x16')][_0x0c3e('0x15')]);}})['catch'](function(_0x122448){logger[_0x0c3e('0x13')](_0x0c3e('0xf'),_0x2fde05,_0x122448);_0x341548(_0x122448);});});}exports[_0x0c3e('0x17')]=function(_0x55b169){var _0x2ca438=this;return new Promise(function(_0x167e02,_0x64fede){return db[_0x0c3e('0x18')][_0x0c3e('0x19')]({'raw':_0x55b169['options']?_0x55b169[_0x0c3e('0x1a')][_0x0c3e('0x1b')]===undefined?!![]:![]:!![],'where':_0x55b169[_0x0c3e('0x1a')]?_0x55b169[_0x0c3e('0x1a')][_0x0c3e('0x1c')]||null:null,'attributes':_0x55b169['options']?_0x55b169[_0x0c3e('0x1a')][_0x0c3e('0x1d')]||null:null,'limit':_0x55b169['options']?_0x55b169[_0x0c3e('0x1a')]['limit']||null:null,'include':_0x55b169[_0x0c3e('0x1a')]?_0x55b169[_0x0c3e('0x1a')][_0x0c3e('0x1e')]?_[_0x0c3e('0x1f')](_0x55b169['options'][_0x0c3e('0x1e')],function(_0x5b02e8){return{'model':db[_0x5b02e8['model']],'as':_0x5b02e8['as'],'attributes':_0x5b02e8[_0x0c3e('0x1d')],'include':_0x5b02e8['include']?_['map'](_0x5b02e8[_0x0c3e('0x1e')],function(_0x7bcc29){return{'model':db[_0x7bcc29[_0x0c3e('0x20')]],'as':_0x7bcc29['as'],'attributes':_0x7bcc29[_0x0c3e('0x1d')],'include':_0x7bcc29[_0x0c3e('0x1e')]?_['map'](_0x7bcc29[_0x0c3e('0x1e')],function(_0x4cf589){return{'model':db[_0x4cf589[_0x0c3e('0x20')]],'as':_0x4cf589['as'],'attributes':_0x4cf589[_0x0c3e('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x0c3e('0xd')](function(_0x3bd9e4){logger[_0x0c3e('0xe')](_0x0c3e('0x17'),_0x55b169);logger[_0x0c3e('0x10')](_0x0c3e('0x17'),_0x55b169,JSON['stringify'](_0x3bd9e4));_0x167e02(_0x3bd9e4);})[_0x0c3e('0x21')](function(_0x22e97d){logger['error'](_0x0c3e('0x17'),_0x22e97d['message'],_0x55b169);_0x64fede(_0x2ca438[_0x0c3e('0x13')](0x1f4,_0x22e97d[_0x0c3e('0x15')]));});});};exports['ShowDeskAccount']=function(_0x43774f){var _0x714a4a=this;return new Promise(function(_0x56c0e3,_0x234183){return db[_0x0c3e('0x18')][_0x0c3e('0x22')]({'raw':_0x43774f[_0x0c3e('0x1a')]?_0x43774f[_0x0c3e('0x1a')][_0x0c3e('0x1b')]===undefined?!![]:![]:!![],'where':_0x43774f['options']?_0x43774f[_0x0c3e('0x1a')][_0x0c3e('0x1c')]||null:null,'attributes':_0x43774f[_0x0c3e('0x1a')]?_0x43774f[_0x0c3e('0x1a')][_0x0c3e('0x1d')]||null:null,'include':_0x43774f[_0x0c3e('0x1a')]?_0x43774f['options'][_0x0c3e('0x1e')]?_[_0x0c3e('0x1f')](_0x43774f['options']['include'],function(_0x2082ac){return{'model':db[_0x2082ac[_0x0c3e('0x20')]],'as':_0x2082ac['as'],'attributes':_0x2082ac['attributes'],'include':_0x2082ac[_0x0c3e('0x1e')]?_[_0x0c3e('0x1f')](_0x2082ac[_0x0c3e('0x1e')],function(_0x1ffd6a){return{'model':db[_0x1ffd6a[_0x0c3e('0x20')]],'as':_0x1ffd6a['as'],'attributes':_0x1ffd6a[_0x0c3e('0x1d')],'include':_0x1ffd6a['include']?_[_0x0c3e('0x1f')](_0x1ffd6a[_0x0c3e('0x1e')],function(_0x1dca23){return{'model':db[_0x1dca23[_0x0c3e('0x20')]],'as':_0x1dca23['as'],'attributes':_0x1dca23[_0x0c3e('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x91e66e){logger['info'](_0x0c3e('0x23'),_0x43774f);logger[_0x0c3e('0x10')]('ShowDeskAccount',_0x43774f,JSON[_0x0c3e('0x24')](_0x91e66e));_0x56c0e3(_0x91e66e);})['catch'](function(_0x5703f9){logger[_0x0c3e('0x13')](_0x0c3e('0x23'),_0x5703f9['message'],_0x43774f);_0x234183(_0x714a4a[_0x0c3e('0x13')](0x1f4,_0x5703f9[_0x0c3e('0x15')]));});});};