17ff55c71a92ab1116b21d2e6b0acdfe0ab6d782
[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 _0x62cf=['include','map','model','ShowDeskAccount','DeskAccount','lodash','moment','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info','DeskAccount,\x20%s,\x20%s','request\x20sent','debug','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetDeskAccount','findAll','options','where','attributes'];(function(_0x5d8727,_0xdfdd0b){var _0x17e166=function(_0xcbbf3f){while(--_0xcbbf3f){_0x5d8727['push'](_0x5d8727['shift']());}};_0x17e166(++_0xdfdd0b);}(_0x62cf,0x81));var _0xf62c=function(_0x4ae277,_0x436908){_0x4ae277=_0x4ae277-0x0;var _0x24b67f=_0x62cf[_0x4ae277];return _0x24b67f;};'use strict';var _=require(_0xf62c('0x0'));var util=require('util');var moment=require(_0xf62c('0x1'));var BPromise=require('bluebird');var rs=require(_0xf62c('0x2'));var fs=require('fs');var Redis=require(_0xf62c('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xf62c('0x4'))(_0xf62c('0x5'));var config=require(_0xf62c('0x6'));var jayson=require(_0xf62c('0x7'));var client=jayson[_0xf62c('0x8')][_0xf62c('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x45749c,_0x314609,_0x372f7b){return new BPromise(function(_0x54389e,_0x181f87){return client['request'](_0x45749c,_0x372f7b)[_0xf62c('0xa')](function(_0x8038ed){logger[_0xf62c('0xb')](_0xf62c('0xc'),_0x314609,_0xf62c('0xd'));logger[_0xf62c('0xe')](_0xf62c('0xf'),_0x314609,_0xf62c('0xd'),JSON[_0xf62c('0x10')](_0x8038ed));if(_0x8038ed[_0xf62c('0x11')]){if(_0x8038ed[_0xf62c('0x11')]['code']===0x1f4){logger[_0xf62c('0x11')]('DeskAccount,\x20%s,\x20%s',_0x314609,_0x8038ed['error'][_0xf62c('0x12')]);return _0x181f87(_0x8038ed[_0xf62c('0x11')]['message']);}logger[_0xf62c('0x11')](_0xf62c('0xc'),_0x314609,_0x8038ed['error'][_0xf62c('0x12')]);return _0x54389e(_0x8038ed['error'][_0xf62c('0x12')]);}else{logger[_0xf62c('0xb')]('DeskAccount,\x20%s,\x20%s',_0x314609,_0xf62c('0xd'));_0x54389e(_0x8038ed[_0xf62c('0x13')]['message']);}})[_0xf62c('0x14')](function(_0x14b26e){logger[_0xf62c('0x11')]('DeskAccount,\x20%s,\x20%s',_0x314609,_0x14b26e);_0x181f87(_0x14b26e);});});}exports[_0xf62c('0x15')]=function(_0xc7da63){var _0x8180f3=this;return new Promise(function(_0x329c3c,_0x32a7c3){return db['DeskAccount'][_0xf62c('0x16')]({'raw':_0xc7da63[_0xf62c('0x17')]?_0xc7da63[_0xf62c('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0xc7da63['options']?_0xc7da63[_0xf62c('0x17')][_0xf62c('0x18')]||null:null,'attributes':_0xc7da63[_0xf62c('0x17')]?_0xc7da63[_0xf62c('0x17')][_0xf62c('0x19')]||null:null,'limit':_0xc7da63['options']?_0xc7da63['options']['limit']||null:null,'include':_0xc7da63[_0xf62c('0x17')]?_0xc7da63[_0xf62c('0x17')][_0xf62c('0x1a')]?_[_0xf62c('0x1b')](_0xc7da63[_0xf62c('0x17')][_0xf62c('0x1a')],function(_0x5c048f){return{'model':db[_0x5c048f[_0xf62c('0x1c')]],'as':_0x5c048f['as'],'attributes':_0x5c048f[_0xf62c('0x19')],'include':_0x5c048f[_0xf62c('0x1a')]?_['map'](_0x5c048f['include'],function(_0x48541f){return{'model':db[_0x48541f['model']],'as':_0x48541f['as'],'attributes':_0x48541f[_0xf62c('0x19')],'include':_0x48541f['include']?_[_0xf62c('0x1b')](_0x48541f['include'],function(_0x2e2e54){return{'model':db[_0x2e2e54['model']],'as':_0x2e2e54['as'],'attributes':_0x2e2e54[_0xf62c('0x19')]};}):[]};}):[]};}):[]:[]})[_0xf62c('0xa')](function(_0x439f48){logger[_0xf62c('0xb')](_0xf62c('0x15'),_0xc7da63);logger['debug'](_0xf62c('0x15'),_0xc7da63,JSON[_0xf62c('0x10')](_0x439f48));_0x329c3c(_0x439f48);})[_0xf62c('0x14')](function(_0x358036){logger[_0xf62c('0x11')](_0xf62c('0x15'),_0x358036[_0xf62c('0x12')],_0xc7da63);_0x32a7c3(_0x8180f3[_0xf62c('0x11')](0x1f4,_0x358036[_0xf62c('0x12')]));});});};exports[_0xf62c('0x1d')]=function(_0x554fce){var _0x398d1c=this;return new Promise(function(_0x1aaeb9,_0x56ec5f){return db[_0xf62c('0x1e')]['find']({'raw':_0x554fce[_0xf62c('0x17')]?_0x554fce[_0xf62c('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x554fce['options']?_0x554fce[_0xf62c('0x17')][_0xf62c('0x18')]||null:null,'attributes':_0x554fce['options']?_0x554fce[_0xf62c('0x17')]['attributes']||null:null,'include':_0x554fce[_0xf62c('0x17')]?_0x554fce[_0xf62c('0x17')][_0xf62c('0x1a')]?_[_0xf62c('0x1b')](_0x554fce['options']['include'],function(_0x3f6726){return{'model':db[_0x3f6726['model']],'as':_0x3f6726['as'],'attributes':_0x3f6726[_0xf62c('0x19')],'include':_0x3f6726['include']?_[_0xf62c('0x1b')](_0x3f6726[_0xf62c('0x1a')],function(_0x337fec){return{'model':db[_0x337fec[_0xf62c('0x1c')]],'as':_0x337fec['as'],'attributes':_0x337fec['attributes'],'include':_0x337fec[_0xf62c('0x1a')]?_[_0xf62c('0x1b')](_0x337fec[_0xf62c('0x1a')],function(_0x459b09){return{'model':db[_0x459b09['model']],'as':_0x459b09['as'],'attributes':_0x459b09[_0xf62c('0x19')]};}):[]};}):[]};}):[]:[]})[_0xf62c('0xa')](function(_0x4f2cc2){logger[_0xf62c('0xb')](_0xf62c('0x1d'),_0x554fce);logger[_0xf62c('0xe')](_0xf62c('0x1d'),_0x554fce,JSON[_0xf62c('0x10')](_0x4f2cc2));_0x1aaeb9(_0x4f2cc2);})[_0xf62c('0x14')](function(_0x317253){logger[_0xf62c('0x11')](_0xf62c('0x1d'),_0x317253[_0xf62c('0x12')],_0x554fce);_0x56ec5f(_0x398d1c[_0xf62c('0x11')](0x1f4,_0x317253[_0xf62c('0x12')]));});});};