e685a7eed0c0d0867c3beb599470a139b33907bb
[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 _0xb7de=['where','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','request','then','debug','error','code','message','info','DeskAccount,\x20%s,\x20%s','result','catch','GetDeskAccount','DeskAccount','findAll','options','raw','attributes','limit','include','map','model','stringify','ShowDeskAccount','find'];(function(_0x4c139d,_0xf5e7bf){var _0x5d7bb1=function(_0x2ddf30){while(--_0x2ddf30){_0x4c139d['push'](_0x4c139d['shift']());}};_0x5d7bb1(++_0xf5e7bf);}(_0xb7de,0x67));var _0xeb7d=function(_0x3ff085,_0x27c92e){_0x3ff085=_0x3ff085-0x0;var _0x2b68c3=_0xb7de[_0x3ff085];return _0x2b68c3;};'use strict';var _=require(_0xeb7d('0x0'));var util=require(_0xeb7d('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xeb7d('0x2'));var fs=require('fs');var Redis=require(_0xeb7d('0x3'));var db=require(_0xeb7d('0x4'))['db'];var utils=require(_0xeb7d('0x5'));var logger=require(_0xeb7d('0x6'))(_0xeb7d('0x7'));var config=require('../../config/environment');var jayson=require(_0xeb7d('0x8'));var client=jayson[_0xeb7d('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x484af5,_0x2885e8,_0x1c371c){return new BPromise(function(_0x25f3bf,_0x4ec0df){return client[_0xeb7d('0xa')](_0x484af5,_0x1c371c)[_0xeb7d('0xb')](function(_0x2df23c){logger['info']('DeskAccount,\x20%s,\x20%s',_0x2885e8,'request\x20sent');logger[_0xeb7d('0xc')]('DeskAccount,\x20%s,\x20%s,\x20%s',_0x2885e8,'request\x20sent',JSON['stringify'](_0x2df23c));if(_0x2df23c[_0xeb7d('0xd')]){if(_0x2df23c[_0xeb7d('0xd')][_0xeb7d('0xe')]===0x1f4){logger[_0xeb7d('0xd')]('DeskAccount,\x20%s,\x20%s',_0x2885e8,_0x2df23c[_0xeb7d('0xd')][_0xeb7d('0xf')]);return _0x4ec0df(_0x2df23c['error'][_0xeb7d('0xf')]);}logger[_0xeb7d('0xd')]('DeskAccount,\x20%s,\x20%s',_0x2885e8,_0x2df23c[_0xeb7d('0xd')][_0xeb7d('0xf')]);return _0x25f3bf(_0x2df23c[_0xeb7d('0xd')]['message']);}else{logger[_0xeb7d('0x10')](_0xeb7d('0x11'),_0x2885e8,'request\x20sent');_0x25f3bf(_0x2df23c[_0xeb7d('0x12')][_0xeb7d('0xf')]);}})[_0xeb7d('0x13')](function(_0x20d497){logger[_0xeb7d('0xd')](_0xeb7d('0x11'),_0x2885e8,_0x20d497);_0x4ec0df(_0x20d497);});});}exports[_0xeb7d('0x14')]=function(_0x2f32d7){var _0x2c22b4=this;return new Promise(function(_0xd004ce,_0x52c811){return db[_0xeb7d('0x15')][_0xeb7d('0x16')]({'raw':_0x2f32d7[_0xeb7d('0x17')]?_0x2f32d7['options'][_0xeb7d('0x18')]===undefined?!![]:![]:!![],'where':_0x2f32d7[_0xeb7d('0x17')]?_0x2f32d7['options']['where']||null:null,'attributes':_0x2f32d7[_0xeb7d('0x17')]?_0x2f32d7[_0xeb7d('0x17')][_0xeb7d('0x19')]||null:null,'limit':_0x2f32d7['options']?_0x2f32d7[_0xeb7d('0x17')][_0xeb7d('0x1a')]||null:null,'include':_0x2f32d7[_0xeb7d('0x17')]?_0x2f32d7[_0xeb7d('0x17')][_0xeb7d('0x1b')]?_[_0xeb7d('0x1c')](_0x2f32d7[_0xeb7d('0x17')]['include'],function(_0x34234b){return{'model':db[_0x34234b[_0xeb7d('0x1d')]],'as':_0x34234b['as'],'attributes':_0x34234b[_0xeb7d('0x19')],'include':_0x34234b[_0xeb7d('0x1b')]?_[_0xeb7d('0x1c')](_0x34234b[_0xeb7d('0x1b')],function(_0x17812c){return{'model':db[_0x17812c[_0xeb7d('0x1d')]],'as':_0x17812c['as'],'attributes':_0x17812c[_0xeb7d('0x19')],'include':_0x17812c[_0xeb7d('0x1b')]?_[_0xeb7d('0x1c')](_0x17812c[_0xeb7d('0x1b')],function(_0x5a0027){return{'model':db[_0x5a0027[_0xeb7d('0x1d')]],'as':_0x5a0027['as'],'attributes':_0x5a0027[_0xeb7d('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x142fb3){logger[_0xeb7d('0x10')]('GetDeskAccount',_0x2f32d7);logger[_0xeb7d('0xc')](_0xeb7d('0x14'),_0x2f32d7,JSON[_0xeb7d('0x1e')](_0x142fb3));_0xd004ce(_0x142fb3);})[_0xeb7d('0x13')](function(_0x4a4fdb){logger[_0xeb7d('0xd')](_0xeb7d('0x14'),_0x4a4fdb['message'],_0x2f32d7);_0x52c811(_0x2c22b4[_0xeb7d('0xd')](0x1f4,_0x4a4fdb[_0xeb7d('0xf')]));});});};exports[_0xeb7d('0x1f')]=function(_0x2d335b){var _0x534f1d=this;return new Promise(function(_0x3007d2,_0x4dc251){return db['DeskAccount'][_0xeb7d('0x20')]({'raw':_0x2d335b['options']?_0x2d335b['options'][_0xeb7d('0x18')]===undefined?!![]:![]:!![],'where':_0x2d335b['options']?_0x2d335b['options'][_0xeb7d('0x21')]||null:null,'attributes':_0x2d335b['options']?_0x2d335b[_0xeb7d('0x17')][_0xeb7d('0x19')]||null:null,'include':_0x2d335b[_0xeb7d('0x17')]?_0x2d335b[_0xeb7d('0x17')][_0xeb7d('0x1b')]?_[_0xeb7d('0x1c')](_0x2d335b[_0xeb7d('0x17')][_0xeb7d('0x1b')],function(_0xd844de){return{'model':db[_0xd844de['model']],'as':_0xd844de['as'],'attributes':_0xd844de['attributes'],'include':_0xd844de['include']?_['map'](_0xd844de['include'],function(_0x51cabf){return{'model':db[_0x51cabf[_0xeb7d('0x1d')]],'as':_0x51cabf['as'],'attributes':_0x51cabf[_0xeb7d('0x19')],'include':_0x51cabf[_0xeb7d('0x1b')]?_[_0xeb7d('0x1c')](_0x51cabf['include'],function(_0x433578){return{'model':db[_0x433578[_0xeb7d('0x1d')]],'as':_0x433578['as'],'attributes':_0x433578[_0xeb7d('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x38cb12){logger[_0xeb7d('0x10')](_0xeb7d('0x1f'),_0x2d335b);logger[_0xeb7d('0xc')](_0xeb7d('0x1f'),_0x2d335b,JSON[_0xeb7d('0x1e')](_0x38cb12));_0x3007d2(_0x38cb12);})[_0xeb7d('0x13')](function(_0x2a27dc){logger[_0xeb7d('0xd')](_0xeb7d('0x1f'),_0x2a27dc['message'],_0x2d335b);_0x4dc251(_0x534f1d[_0xeb7d('0xd')](0x1f4,_0x2a27dc[_0xeb7d('0xf')]));});});};