303c8e63f278642f2d82d4c5c9beac231fd7065d
[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 _0xb070=['randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','DeskAccount,\x20%s,\x20%s','request\x20sent','debug','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','GetDeskAccount','findAll','options','attributes','include','map','model','catch','ShowDeskAccount','DeskAccount','find','raw','util','moment','bluebird'];(function(_0x547a04,_0x4f4d69){var _0x2f48a4=function(_0x5e4120){while(--_0x5e4120){_0x547a04['push'](_0x547a04['shift']());}};_0x2f48a4(++_0x4f4d69);}(_0xb070,0x17e));var _0x0b07=function(_0x385f88,_0x2402a6){_0x385f88=_0x385f88-0x0;var _0x56792f=_0xb070[_0x385f88];return _0x56792f;};'use strict';var _=require('lodash');var util=require(_0x0b07('0x0'));var moment=require(_0x0b07('0x1'));var BPromise=require(_0x0b07('0x2'));var rs=require(_0x0b07('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x0b07('0x4'));var logger=require(_0x0b07('0x5'))(_0x0b07('0x6'));var config=require(_0x0b07('0x7'));var jayson=require(_0x0b07('0x8'));var client=jayson[_0x0b07('0x9')][_0x0b07('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2416df,_0x9f33d5,_0x572fd5){return new BPromise(function(_0x361fa4,_0x7bd04a){return client[_0x0b07('0xb')](_0x2416df,_0x572fd5)[_0x0b07('0xc')](function(_0x252153){logger['info'](_0x0b07('0xd'),_0x9f33d5,_0x0b07('0xe'));logger[_0x0b07('0xf')](_0x0b07('0x10'),_0x9f33d5,_0x0b07('0xe'),JSON[_0x0b07('0x11')](_0x252153));if(_0x252153[_0x0b07('0x12')]){if(_0x252153[_0x0b07('0x12')][_0x0b07('0x13')]===0x1f4){logger[_0x0b07('0x12')](_0x0b07('0xd'),_0x9f33d5,_0x252153[_0x0b07('0x12')][_0x0b07('0x14')]);return _0x7bd04a(_0x252153[_0x0b07('0x12')][_0x0b07('0x14')]);}logger['error'](_0x0b07('0xd'),_0x9f33d5,_0x252153[_0x0b07('0x12')][_0x0b07('0x14')]);return _0x361fa4(_0x252153[_0x0b07('0x12')]['message']);}else{logger[_0x0b07('0x15')](_0x0b07('0xd'),_0x9f33d5,'request\x20sent');_0x361fa4(_0x252153[_0x0b07('0x16')][_0x0b07('0x14')]);}})['catch'](function(_0x762296){logger[_0x0b07('0x12')](_0x0b07('0xd'),_0x9f33d5,_0x762296);_0x7bd04a(_0x762296);});});}exports[_0x0b07('0x17')]=function(_0x590818){var _0x1d620a=this;return new Promise(function(_0x378b32,_0x18ca34){return db['DeskAccount'][_0x0b07('0x18')]({'raw':_0x590818[_0x0b07('0x19')]?_0x590818[_0x0b07('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x590818[_0x0b07('0x19')]?_0x590818[_0x0b07('0x19')]['where']||null:null,'attributes':_0x590818['options']?_0x590818[_0x0b07('0x19')][_0x0b07('0x1a')]||null:null,'limit':_0x590818[_0x0b07('0x19')]?_0x590818[_0x0b07('0x19')]['limit']||null:null,'include':_0x590818['options']?_0x590818[_0x0b07('0x19')][_0x0b07('0x1b')]?_[_0x0b07('0x1c')](_0x590818[_0x0b07('0x19')][_0x0b07('0x1b')],function(_0x5135cb){return{'model':db[_0x5135cb[_0x0b07('0x1d')]],'as':_0x5135cb['as'],'attributes':_0x5135cb[_0x0b07('0x1a')],'include':_0x5135cb[_0x0b07('0x1b')]?_[_0x0b07('0x1c')](_0x5135cb[_0x0b07('0x1b')],function(_0x1facf0){return{'model':db[_0x1facf0[_0x0b07('0x1d')]],'as':_0x1facf0['as'],'attributes':_0x1facf0[_0x0b07('0x1a')],'include':_0x1facf0[_0x0b07('0x1b')]?_[_0x0b07('0x1c')](_0x1facf0[_0x0b07('0x1b')],function(_0x265496){return{'model':db[_0x265496['model']],'as':_0x265496['as'],'attributes':_0x265496[_0x0b07('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x0b07('0xc')](function(_0x38cfaa){logger[_0x0b07('0x15')](_0x0b07('0x17'),_0x590818);logger[_0x0b07('0xf')](_0x0b07('0x17'),_0x590818,JSON['stringify'](_0x38cfaa));_0x378b32(_0x38cfaa);})[_0x0b07('0x1e')](function(_0x4fee65){logger['error'](_0x0b07('0x17'),_0x4fee65[_0x0b07('0x14')],_0x590818);_0x18ca34(_0x1d620a['error'](0x1f4,_0x4fee65[_0x0b07('0x14')]));});});};exports[_0x0b07('0x1f')]=function(_0x2e3cf7){var _0x9dca8b=this;return new Promise(function(_0x3acb5e,_0x38fc8c){return db[_0x0b07('0x20')][_0x0b07('0x21')]({'raw':_0x2e3cf7['options']?_0x2e3cf7[_0x0b07('0x19')][_0x0b07('0x22')]===undefined?!![]:![]:!![],'where':_0x2e3cf7[_0x0b07('0x19')]?_0x2e3cf7[_0x0b07('0x19')]['where']||null:null,'attributes':_0x2e3cf7[_0x0b07('0x19')]?_0x2e3cf7[_0x0b07('0x19')][_0x0b07('0x1a')]||null:null,'include':_0x2e3cf7['options']?_0x2e3cf7[_0x0b07('0x19')]['include']?_[_0x0b07('0x1c')](_0x2e3cf7['options'][_0x0b07('0x1b')],function(_0x3f25b7){return{'model':db[_0x3f25b7[_0x0b07('0x1d')]],'as':_0x3f25b7['as'],'attributes':_0x3f25b7['attributes'],'include':_0x3f25b7[_0x0b07('0x1b')]?_[_0x0b07('0x1c')](_0x3f25b7[_0x0b07('0x1b')],function(_0x577c50){return{'model':db[_0x577c50['model']],'as':_0x577c50['as'],'attributes':_0x577c50['attributes'],'include':_0x577c50[_0x0b07('0x1b')]?_[_0x0b07('0x1c')](_0x577c50[_0x0b07('0x1b')],function(_0x67669d){return{'model':db[_0x67669d[_0x0b07('0x1d')]],'as':_0x67669d['as'],'attributes':_0x67669d[_0x0b07('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x0b07('0xc')](function(_0x4d9635){logger['info']('ShowDeskAccount',_0x2e3cf7);logger[_0x0b07('0xf')](_0x0b07('0x1f'),_0x2e3cf7,JSON[_0x0b07('0x11')](_0x4d9635));_0x3acb5e(_0x4d9635);})['catch'](function(_0x1a8e15){logger[_0x0b07('0x12')](_0x0b07('0x1f'),_0x1a8e15[_0x0b07('0x14')],_0x2e3cf7);_0x38fc8c(_0x9dca8b[_0x0b07('0x12')](0x1f4,_0x1a8e15[_0x0b07('0x14')]));});});};