c28b68b5b138f282b2b99112454831dceba88136
[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 _0x854d=['limit','include','map','model','attributes','find','info','ShowDeskAccount','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','then','DeskAccount,\x20%s,\x20%s','debug','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetDeskAccount','findAll','options','raw','where'];(function(_0x55237b,_0x493ab6){var _0x111011=function(_0x3f0fec){while(--_0x3f0fec){_0x55237b['push'](_0x55237b['shift']());}};_0x111011(++_0x493ab6);}(_0x854d,0x104));var _0xd854=function(_0x50cc38,_0x5c0cad){_0x50cc38=_0x50cc38-0x0;var _0x4cea2d=_0x854d[_0x50cc38];return _0x4cea2d;};'use strict';var _=require(_0xd854('0x0'));var util=require(_0xd854('0x1'));var moment=require(_0xd854('0x2'));var BPromise=require('bluebird');var rs=require(_0xd854('0x3'));var fs=require('fs');var Redis=require(_0xd854('0x4'));var db=require(_0xd854('0x5'))['db'];var utils=require(_0xd854('0x6'));var logger=require('../../config/logger')(_0xd854('0x7'));var config=require(_0xd854('0x8'));var jayson=require(_0xd854('0x9'));var client=jayson[_0xd854('0xa')][_0xd854('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x59818e,_0x5ca286,_0x2408f2){return new BPromise(function(_0x2a380c,_0x4d7efe){return client[_0xd854('0xc')](_0x59818e,_0x2408f2)[_0xd854('0xd')](function(_0xc7b624){logger['info'](_0xd854('0xe'),_0x5ca286,'request\x20sent');logger[_0xd854('0xf')](_0xd854('0x10'),_0x5ca286,'request\x20sent',JSON[_0xd854('0x11')](_0xc7b624));if(_0xc7b624[_0xd854('0x12')]){if(_0xc7b624[_0xd854('0x12')][_0xd854('0x13')]===0x1f4){logger['error'](_0xd854('0xe'),_0x5ca286,_0xc7b624[_0xd854('0x12')]['message']);return _0x4d7efe(_0xc7b624[_0xd854('0x12')][_0xd854('0x14')]);}logger[_0xd854('0x12')](_0xd854('0xe'),_0x5ca286,_0xc7b624[_0xd854('0x12')][_0xd854('0x14')]);return _0x2a380c(_0xc7b624[_0xd854('0x12')][_0xd854('0x14')]);}else{logger['info'](_0xd854('0xe'),_0x5ca286,'request\x20sent');_0x2a380c(_0xc7b624[_0xd854('0x15')][_0xd854('0x14')]);}})[_0xd854('0x16')](function(_0x27ffc8){logger['error'](_0xd854('0xe'),_0x5ca286,_0x27ffc8);_0x4d7efe(_0x27ffc8);});});}exports[_0xd854('0x17')]=function(_0x2103de){var _0x44d3d1=this;return new Promise(function(_0x22be4d,_0x35b67a){return db['DeskAccount'][_0xd854('0x18')]({'raw':_0x2103de[_0xd854('0x19')]?_0x2103de['options'][_0xd854('0x1a')]===undefined?!![]:![]:!![],'where':_0x2103de['options']?_0x2103de[_0xd854('0x19')][_0xd854('0x1b')]||null:null,'attributes':_0x2103de[_0xd854('0x19')]?_0x2103de['options']['attributes']||null:null,'limit':_0x2103de['options']?_0x2103de['options'][_0xd854('0x1c')]||null:null,'include':_0x2103de[_0xd854('0x19')]?_0x2103de[_0xd854('0x19')][_0xd854('0x1d')]?_[_0xd854('0x1e')](_0x2103de[_0xd854('0x19')][_0xd854('0x1d')],function(_0x2f55e3){return{'model':db[_0x2f55e3[_0xd854('0x1f')]],'as':_0x2f55e3['as'],'attributes':_0x2f55e3[_0xd854('0x20')],'include':_0x2f55e3['include']?_[_0xd854('0x1e')](_0x2f55e3[_0xd854('0x1d')],function(_0x5f10db){return{'model':db[_0x5f10db['model']],'as':_0x5f10db['as'],'attributes':_0x5f10db[_0xd854('0x20')],'include':_0x5f10db[_0xd854('0x1d')]?_[_0xd854('0x1e')](_0x5f10db['include'],function(_0x2f4c16){return{'model':db[_0x2f4c16[_0xd854('0x1f')]],'as':_0x2f4c16['as'],'attributes':_0x2f4c16[_0xd854('0x20')]};}):[]};}):[]};}):[]:[]})[_0xd854('0xd')](function(_0xdb4ee3){logger['info'](_0xd854('0x17'),_0x2103de);logger[_0xd854('0xf')]('GetDeskAccount',_0x2103de,JSON[_0xd854('0x11')](_0xdb4ee3));_0x22be4d(_0xdb4ee3);})[_0xd854('0x16')](function(_0x3e3b26){logger[_0xd854('0x12')](_0xd854('0x17'),_0x3e3b26[_0xd854('0x14')],_0x2103de);_0x35b67a(_0x44d3d1['error'](0x1f4,_0x3e3b26[_0xd854('0x14')]));});});};exports['ShowDeskAccount']=function(_0x15f30f){var _0x36a05d=this;return new Promise(function(_0x57de6f,_0x164580){return db['DeskAccount'][_0xd854('0x21')]({'raw':_0x15f30f[_0xd854('0x19')]?_0x15f30f[_0xd854('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x15f30f[_0xd854('0x19')]?_0x15f30f['options'][_0xd854('0x1b')]||null:null,'attributes':_0x15f30f[_0xd854('0x19')]?_0x15f30f[_0xd854('0x19')][_0xd854('0x20')]||null:null,'include':_0x15f30f['options']?_0x15f30f[_0xd854('0x19')][_0xd854('0x1d')]?_[_0xd854('0x1e')](_0x15f30f[_0xd854('0x19')][_0xd854('0x1d')],function(_0x510c5e){return{'model':db[_0x510c5e['model']],'as':_0x510c5e['as'],'attributes':_0x510c5e[_0xd854('0x20')],'include':_0x510c5e[_0xd854('0x1d')]?_['map'](_0x510c5e[_0xd854('0x1d')],function(_0x47db68){return{'model':db[_0x47db68['model']],'as':_0x47db68['as'],'attributes':_0x47db68['attributes'],'include':_0x47db68[_0xd854('0x1d')]?_[_0xd854('0x1e')](_0x47db68['include'],function(_0x50a2ed){return{'model':db[_0x50a2ed['model']],'as':_0x50a2ed['as'],'attributes':_0x50a2ed[_0xd854('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x315cbb){logger[_0xd854('0x22')](_0xd854('0x23'),_0x15f30f);logger['debug']('ShowDeskAccount',_0x15f30f,JSON['stringify'](_0x315cbb));_0x57de6f(_0x315cbb);})[_0xd854('0x16')](function(_0x3202f1){logger[_0xd854('0x12')](_0xd854('0x23'),_0x3202f1[_0xd854('0x14')],_0x15f30f);_0x164580(_0x36a05d[_0xd854('0x12')](0x1f4,_0x3202f1['message']));});});};