24c3510a8ff5ad420d864bad9ad29946a8cf4083
[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 _0xd2be=['DeskAccount,\x20%s,\x20%s','DeskAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','GetDeskAccount','DeskAccount','findAll','options','raw','attributes','map','include','model','ShowDeskAccount','find','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','info'];(function(_0x4668fc,_0x44d716){var _0x4514f8=function(_0x3c9800){while(--_0x3c9800){_0x4668fc['push'](_0x4668fc['shift']());}};_0x4514f8(++_0x44d716);}(_0xd2be,0x1d3));var _0xed2b=function(_0x4007c1,_0x47f5c2){_0x4007c1=_0x4007c1-0x0;var _0x15bc7d=_0xd2be[_0x4007c1];return _0x15bc7d;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xed2b('0x0'));var BPromise=require(_0xed2b('0x1'));var rs=require(_0xed2b('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xed2b('0x3'))['db'];var utils=require(_0xed2b('0x4'));var logger=require(_0xed2b('0x5'))(_0xed2b('0x6'));var config=require(_0xed2b('0x7'));var jayson=require(_0xed2b('0x8'));var client=jayson[_0xed2b('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3da054,_0x2b82c3,_0x1540ad){return new BPromise(function(_0x227005,_0x3d3910){return client[_0xed2b('0xa')](_0x3da054,_0x1540ad)[_0xed2b('0xb')](function(_0x2c5a93){logger[_0xed2b('0xc')](_0xed2b('0xd'),_0x2b82c3,'request\x20sent');logger['debug'](_0xed2b('0xe'),_0x2b82c3,_0xed2b('0xf'),JSON[_0xed2b('0x10')](_0x2c5a93));if(_0x2c5a93['error']){if(_0x2c5a93[_0xed2b('0x11')][_0xed2b('0x12')]===0x1f4){logger[_0xed2b('0x11')](_0xed2b('0xd'),_0x2b82c3,_0x2c5a93[_0xed2b('0x11')][_0xed2b('0x13')]);return _0x3d3910(_0x2c5a93['error']['message']);}logger[_0xed2b('0x11')](_0xed2b('0xd'),_0x2b82c3,_0x2c5a93['error']['message']);return _0x227005(_0x2c5a93[_0xed2b('0x11')]['message']);}else{logger['info'](_0xed2b('0xd'),_0x2b82c3,_0xed2b('0xf'));_0x227005(_0x2c5a93['result'][_0xed2b('0x13')]);}})[_0xed2b('0x14')](function(_0x50ae82){logger[_0xed2b('0x11')]('DeskAccount,\x20%s,\x20%s',_0x2b82c3,_0x50ae82);_0x3d3910(_0x50ae82);});});}exports[_0xed2b('0x15')]=function(_0x38904a){var _0x4bcd91=this;return new Promise(function(_0x2723c7,_0x45e1cf){return db[_0xed2b('0x16')][_0xed2b('0x17')]({'raw':_0x38904a[_0xed2b('0x18')]?_0x38904a['options'][_0xed2b('0x19')]===undefined?!![]:![]:!![],'where':_0x38904a[_0xed2b('0x18')]?_0x38904a[_0xed2b('0x18')]['where']||null:null,'attributes':_0x38904a[_0xed2b('0x18')]?_0x38904a[_0xed2b('0x18')][_0xed2b('0x1a')]||null:null,'limit':_0x38904a[_0xed2b('0x18')]?_0x38904a['options']['limit']||null:null,'include':_0x38904a[_0xed2b('0x18')]?_0x38904a[_0xed2b('0x18')]['include']?_[_0xed2b('0x1b')](_0x38904a['options'][_0xed2b('0x1c')],function(_0x26a619){return{'model':db[_0x26a619[_0xed2b('0x1d')]],'as':_0x26a619['as'],'attributes':_0x26a619[_0xed2b('0x1a')],'include':_0x26a619[_0xed2b('0x1c')]?_[_0xed2b('0x1b')](_0x26a619['include'],function(_0x3a80aa){return{'model':db[_0x3a80aa[_0xed2b('0x1d')]],'as':_0x3a80aa['as'],'attributes':_0x3a80aa['attributes'],'include':_0x3a80aa[_0xed2b('0x1c')]?_[_0xed2b('0x1b')](_0x3a80aa[_0xed2b('0x1c')],function(_0x12d61b){return{'model':db[_0x12d61b[_0xed2b('0x1d')]],'as':_0x12d61b['as'],'attributes':_0x12d61b[_0xed2b('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xed2b('0xb')](function(_0x8691ca){logger[_0xed2b('0xc')](_0xed2b('0x15'),_0x38904a);logger['debug']('GetDeskAccount',_0x38904a,JSON[_0xed2b('0x10')](_0x8691ca));_0x2723c7(_0x8691ca);})['catch'](function(_0xa2e079){logger[_0xed2b('0x11')](_0xed2b('0x15'),_0xa2e079[_0xed2b('0x13')],_0x38904a);_0x45e1cf(_0x4bcd91['error'](0x1f4,_0xa2e079[_0xed2b('0x13')]));});});};exports[_0xed2b('0x1e')]=function(_0x2d6bb2){var _0x321903=this;return new Promise(function(_0x253e6a,_0x43b723){return db['DeskAccount'][_0xed2b('0x1f')]({'raw':_0x2d6bb2[_0xed2b('0x18')]?_0x2d6bb2['options'][_0xed2b('0x19')]===undefined?!![]:![]:!![],'where':_0x2d6bb2[_0xed2b('0x18')]?_0x2d6bb2[_0xed2b('0x18')]['where']||null:null,'attributes':_0x2d6bb2['options']?_0x2d6bb2[_0xed2b('0x18')]['attributes']||null:null,'include':_0x2d6bb2[_0xed2b('0x18')]?_0x2d6bb2['options'][_0xed2b('0x1c')]?_[_0xed2b('0x1b')](_0x2d6bb2[_0xed2b('0x18')]['include'],function(_0x363982){return{'model':db[_0x363982[_0xed2b('0x1d')]],'as':_0x363982['as'],'attributes':_0x363982[_0xed2b('0x1a')],'include':_0x363982['include']?_['map'](_0x363982[_0xed2b('0x1c')],function(_0xdec23e){return{'model':db[_0xdec23e[_0xed2b('0x1d')]],'as':_0xdec23e['as'],'attributes':_0xdec23e[_0xed2b('0x1a')],'include':_0xdec23e[_0xed2b('0x1c')]?_[_0xed2b('0x1b')](_0xdec23e['include'],function(_0xb9b041){return{'model':db[_0xb9b041['model']],'as':_0xb9b041['as'],'attributes':_0xb9b041[_0xed2b('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xed2b('0xb')](function(_0x5f0602){logger['info'](_0xed2b('0x1e'),_0x2d6bb2);logger['debug'](_0xed2b('0x1e'),_0x2d6bb2,JSON[_0xed2b('0x10')](_0x5f0602));_0x253e6a(_0x5f0602);})[_0xed2b('0x14')](function(_0x47c59c){logger[_0xed2b('0x11')]('ShowDeskAccount',_0x47c59c[_0xed2b('0x13')],_0x2d6bb2);_0x43b723(_0x321903[_0xed2b('0x11')](0x1f4,_0x47c59c[_0xed2b('0x13')]));});});};