Built motion from commit 06eb8eb0.|2.6.31
[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 _0xaf70=['code','message','result','catch','GetDeskAccount','DeskAccount','findAll','options','where','attributes','include','map','then','debug','ShowDeskAccount','find','model','stringify','lodash','util','moment','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','info','DeskAccount,\x20%s,\x20%s','request\x20sent','DeskAccount,\x20%s,\x20%s,\x20%s','error'];(function(_0x45c0f7,_0x3b1c07){var _0x56cb13=function(_0x3434f6){while(--_0x3434f6){_0x45c0f7['push'](_0x45c0f7['shift']());}};_0x56cb13(++_0x3b1c07);}(_0xaf70,0xd8));var _0x0af7=function(_0x47d01f,_0xd1aa50){_0x47d01f=_0x47d01f-0x0;var _0x4701c7=_0xaf70[_0x47d01f];return _0x4701c7;};'use strict';var _=require(_0x0af7('0x0'));var util=require(_0x0af7('0x1'));var moment=require(_0x0af7('0x2'));var BPromise=require('bluebird');var rs=require(_0x0af7('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x0af7('0x4'));var logger=require(_0x0af7('0x5'))(_0x0af7('0x6'));var config=require(_0x0af7('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x0af7('0x8')][_0x0af7('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x178e78,_0x356fcd,_0x3eb193){return new BPromise(function(_0x216af0,_0x729bf8){return client['request'](_0x178e78,_0x3eb193)['then'](function(_0x501568){logger[_0x0af7('0xa')](_0x0af7('0xb'),_0x356fcd,_0x0af7('0xc'));logger['debug'](_0x0af7('0xd'),_0x356fcd,_0x0af7('0xc'),JSON['stringify'](_0x501568));if(_0x501568[_0x0af7('0xe')]){if(_0x501568[_0x0af7('0xe')][_0x0af7('0xf')]===0x1f4){logger[_0x0af7('0xe')]('DeskAccount,\x20%s,\x20%s',_0x356fcd,_0x501568[_0x0af7('0xe')][_0x0af7('0x10')]);return _0x729bf8(_0x501568[_0x0af7('0xe')][_0x0af7('0x10')]);}logger[_0x0af7('0xe')]('DeskAccount,\x20%s,\x20%s',_0x356fcd,_0x501568['error'][_0x0af7('0x10')]);return _0x216af0(_0x501568[_0x0af7('0xe')][_0x0af7('0x10')]);}else{logger['info'](_0x0af7('0xb'),_0x356fcd,_0x0af7('0xc'));_0x216af0(_0x501568[_0x0af7('0x11')][_0x0af7('0x10')]);}})[_0x0af7('0x12')](function(_0x33956b){logger[_0x0af7('0xe')](_0x0af7('0xb'),_0x356fcd,_0x33956b);_0x729bf8(_0x33956b);});});}exports[_0x0af7('0x13')]=function(_0x18ee6b){var _0x4a3aa1=this;return new Promise(function(_0x17a653,_0x3948e4){return db[_0x0af7('0x14')][_0x0af7('0x15')]({'raw':_0x18ee6b[_0x0af7('0x16')]?_0x18ee6b[_0x0af7('0x16')]['raw']===undefined?!![]:![]:!![],'where':_0x18ee6b[_0x0af7('0x16')]?_0x18ee6b[_0x0af7('0x16')][_0x0af7('0x17')]||null:null,'attributes':_0x18ee6b[_0x0af7('0x16')]?_0x18ee6b[_0x0af7('0x16')][_0x0af7('0x18')]||null:null,'limit':_0x18ee6b[_0x0af7('0x16')]?_0x18ee6b[_0x0af7('0x16')]['limit']||null:null,'include':_0x18ee6b[_0x0af7('0x16')]?_0x18ee6b[_0x0af7('0x16')][_0x0af7('0x19')]?_[_0x0af7('0x1a')](_0x18ee6b['options'][_0x0af7('0x19')],function(_0x9cc3d6){return{'model':db[_0x9cc3d6['model']],'as':_0x9cc3d6['as'],'attributes':_0x9cc3d6[_0x0af7('0x18')],'include':_0x9cc3d6[_0x0af7('0x19')]?_[_0x0af7('0x1a')](_0x9cc3d6[_0x0af7('0x19')],function(_0x1f5f6b){return{'model':db[_0x1f5f6b['model']],'as':_0x1f5f6b['as'],'attributes':_0x1f5f6b['attributes'],'include':_0x1f5f6b[_0x0af7('0x19')]?_[_0x0af7('0x1a')](_0x1f5f6b[_0x0af7('0x19')],function(_0x48e792){return{'model':db[_0x48e792['model']],'as':_0x48e792['as'],'attributes':_0x48e792[_0x0af7('0x18')]};}):[]};}):[]};}):[]:[]})[_0x0af7('0x1b')](function(_0x435591){logger[_0x0af7('0xa')](_0x0af7('0x13'),_0x18ee6b);logger[_0x0af7('0x1c')](_0x0af7('0x13'),_0x18ee6b,JSON['stringify'](_0x435591));_0x17a653(_0x435591);})[_0x0af7('0x12')](function(_0x570431){logger[_0x0af7('0xe')](_0x0af7('0x13'),_0x570431[_0x0af7('0x10')],_0x18ee6b);_0x3948e4(_0x4a3aa1['error'](0x1f4,_0x570431['message']));});});};exports[_0x0af7('0x1d')]=function(_0x4ba6c8){var _0x434912=this;return new Promise(function(_0x13ddc6,_0x9476ba){return db['DeskAccount'][_0x0af7('0x1e')]({'raw':_0x4ba6c8[_0x0af7('0x16')]?_0x4ba6c8['options']['raw']===undefined?!![]:![]:!![],'where':_0x4ba6c8[_0x0af7('0x16')]?_0x4ba6c8[_0x0af7('0x16')][_0x0af7('0x17')]||null:null,'attributes':_0x4ba6c8[_0x0af7('0x16')]?_0x4ba6c8['options'][_0x0af7('0x18')]||null:null,'include':_0x4ba6c8['options']?_0x4ba6c8[_0x0af7('0x16')]['include']?_[_0x0af7('0x1a')](_0x4ba6c8[_0x0af7('0x16')]['include'],function(_0x5e45e1){return{'model':db[_0x5e45e1[_0x0af7('0x1f')]],'as':_0x5e45e1['as'],'attributes':_0x5e45e1[_0x0af7('0x18')],'include':_0x5e45e1[_0x0af7('0x19')]?_['map'](_0x5e45e1[_0x0af7('0x19')],function(_0x5da7e8){return{'model':db[_0x5da7e8[_0x0af7('0x1f')]],'as':_0x5da7e8['as'],'attributes':_0x5da7e8['attributes'],'include':_0x5da7e8[_0x0af7('0x19')]?_['map'](_0x5da7e8[_0x0af7('0x19')],function(_0x123b8b){return{'model':db[_0x123b8b['model']],'as':_0x123b8b['as'],'attributes':_0x123b8b[_0x0af7('0x18')]};}):[]};}):[]};}):[]:[]})[_0x0af7('0x1b')](function(_0x51ff8d){logger[_0x0af7('0xa')](_0x0af7('0x1d'),_0x4ba6c8);logger['debug']('ShowDeskAccount',_0x4ba6c8,JSON[_0x0af7('0x20')](_0x51ff8d));_0x13ddc6(_0x51ff8d);})[_0x0af7('0x12')](function(_0x4fca63){logger['error'](_0x0af7('0x1d'),_0x4fca63[_0x0af7('0x10')],_0x4ba6c8);_0x9476ba(_0x434912[_0x0af7('0xe')](0x1f4,_0x4fca63[_0x0af7('0x10')]));});});};