8a75ed3a0a5a0f4be79d698476dc67ebba893e9b
[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 _0x94f7=['rpc','../../config/environment','jayson/promise','client','http','request','then','request\x20sent','stringify','error','DeskAccount,\x20%s,\x20%s','message','info','result','catch','GetDeskAccount','DeskAccount','findAll','options','attributes','limit','include','map','model','debug','ShowDeskAccount','raw','where','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x1d930e,_0x20d8b8){var _0x5bbd66=function(_0x3c7488){while(--_0x3c7488){_0x1d930e['push'](_0x1d930e['shift']());}};_0x5bbd66(++_0x20d8b8);}(_0x94f7,0x1e3));var _0x794f=function(_0x287a6b,_0x3ae716){_0x287a6b=_0x287a6b-0x0;var _0x198063=_0x94f7[_0x287a6b];return _0x198063;};'use strict';var _=require(_0x794f('0x0'));var util=require('util');var moment=require(_0x794f('0x1'));var BPromise=require(_0x794f('0x2'));var rs=require(_0x794f('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x794f('0x4'))['db'];var utils=require(_0x794f('0x5'));var logger=require(_0x794f('0x6'))(_0x794f('0x7'));var config=require(_0x794f('0x8'));var jayson=require(_0x794f('0x9'));var client=jayson[_0x794f('0xa')][_0x794f('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1f7fdf,_0x290990,_0x54bf0c){return new BPromise(function(_0x274aeb,_0x34ce01){return client[_0x794f('0xc')](_0x1f7fdf,_0x54bf0c)[_0x794f('0xd')](function(_0x475f45){logger['info']('DeskAccount,\x20%s,\x20%s',_0x290990,_0x794f('0xe'));logger['debug']('DeskAccount,\x20%s,\x20%s,\x20%s',_0x290990,_0x794f('0xe'),JSON[_0x794f('0xf')](_0x475f45));if(_0x475f45['error']){if(_0x475f45[_0x794f('0x10')]['code']===0x1f4){logger['error'](_0x794f('0x11'),_0x290990,_0x475f45[_0x794f('0x10')]['message']);return _0x34ce01(_0x475f45['error'][_0x794f('0x12')]);}logger[_0x794f('0x10')]('DeskAccount,\x20%s,\x20%s',_0x290990,_0x475f45['error'][_0x794f('0x12')]);return _0x274aeb(_0x475f45[_0x794f('0x10')][_0x794f('0x12')]);}else{logger[_0x794f('0x13')](_0x794f('0x11'),_0x290990,'request\x20sent');_0x274aeb(_0x475f45[_0x794f('0x14')][_0x794f('0x12')]);}})[_0x794f('0x15')](function(_0x4162f4){logger[_0x794f('0x10')](_0x794f('0x11'),_0x290990,_0x4162f4);_0x34ce01(_0x4162f4);});});}exports[_0x794f('0x16')]=function(_0x39aba3){var _0x18a652=this;return new Promise(function(_0xc8d3a6,_0x38461f){return db[_0x794f('0x17')][_0x794f('0x18')]({'raw':_0x39aba3[_0x794f('0x19')]?_0x39aba3[_0x794f('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x39aba3[_0x794f('0x19')]?_0x39aba3['options']['where']||null:null,'attributes':_0x39aba3[_0x794f('0x19')]?_0x39aba3[_0x794f('0x19')][_0x794f('0x1a')]||null:null,'limit':_0x39aba3['options']?_0x39aba3[_0x794f('0x19')][_0x794f('0x1b')]||null:null,'include':_0x39aba3[_0x794f('0x19')]?_0x39aba3[_0x794f('0x19')][_0x794f('0x1c')]?_[_0x794f('0x1d')](_0x39aba3['options'][_0x794f('0x1c')],function(_0x2b5336){return{'model':db[_0x2b5336[_0x794f('0x1e')]],'as':_0x2b5336['as'],'attributes':_0x2b5336[_0x794f('0x1a')],'include':_0x2b5336[_0x794f('0x1c')]?_[_0x794f('0x1d')](_0x2b5336['include'],function(_0x2f2a6e){return{'model':db[_0x2f2a6e[_0x794f('0x1e')]],'as':_0x2f2a6e['as'],'attributes':_0x2f2a6e[_0x794f('0x1a')],'include':_0x2f2a6e['include']?_[_0x794f('0x1d')](_0x2f2a6e[_0x794f('0x1c')],function(_0x260527){return{'model':db[_0x260527[_0x794f('0x1e')]],'as':_0x260527['as'],'attributes':_0x260527['attributes']};}):[]};}):[]};}):[]:[]})[_0x794f('0xd')](function(_0x407c02){logger[_0x794f('0x13')](_0x794f('0x16'),_0x39aba3);logger[_0x794f('0x1f')](_0x794f('0x16'),_0x39aba3,JSON['stringify'](_0x407c02));_0xc8d3a6(_0x407c02);})[_0x794f('0x15')](function(_0x543204){logger['error'](_0x794f('0x16'),_0x543204['message'],_0x39aba3);_0x38461f(_0x18a652[_0x794f('0x10')](0x1f4,_0x543204[_0x794f('0x12')]));});});};exports[_0x794f('0x20')]=function(_0x5783e6){var _0x313c9d=this;return new Promise(function(_0x24e56f,_0x1487e4){return db['DeskAccount']['find']({'raw':_0x5783e6[_0x794f('0x19')]?_0x5783e6[_0x794f('0x19')][_0x794f('0x21')]===undefined?!![]:![]:!![],'where':_0x5783e6[_0x794f('0x19')]?_0x5783e6[_0x794f('0x19')][_0x794f('0x22')]||null:null,'attributes':_0x5783e6[_0x794f('0x19')]?_0x5783e6['options'][_0x794f('0x1a')]||null:null,'include':_0x5783e6[_0x794f('0x19')]?_0x5783e6[_0x794f('0x19')][_0x794f('0x1c')]?_['map'](_0x5783e6[_0x794f('0x19')][_0x794f('0x1c')],function(_0x506f1b){return{'model':db[_0x506f1b[_0x794f('0x1e')]],'as':_0x506f1b['as'],'attributes':_0x506f1b[_0x794f('0x1a')],'include':_0x506f1b[_0x794f('0x1c')]?_['map'](_0x506f1b['include'],function(_0x42f229){return{'model':db[_0x42f229[_0x794f('0x1e')]],'as':_0x42f229['as'],'attributes':_0x42f229[_0x794f('0x1a')],'include':_0x42f229[_0x794f('0x1c')]?_[_0x794f('0x1d')](_0x42f229[_0x794f('0x1c')],function(_0x19f784){return{'model':db[_0x19f784[_0x794f('0x1e')]],'as':_0x19f784['as'],'attributes':_0x19f784[_0x794f('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x794f('0xd')](function(_0x53f63c){logger[_0x794f('0x13')](_0x794f('0x20'),_0x5783e6);logger['debug']('ShowDeskAccount',_0x5783e6,JSON['stringify'](_0x53f63c));_0x24e56f(_0x53f63c);})[_0x794f('0x15')](function(_0xc32fb2){logger[_0x794f('0x10')]('ShowDeskAccount',_0xc32fb2[_0x794f('0x12')],_0x5783e6);_0x1487e4(_0x313c9d[_0x794f('0x10')](0x1f4,_0xc32fb2['message']));});});};