a00817b33a5934db894cd3cbb0e28e2a0f714ef6
[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 _0x6467=['request\x20sent','stringify','error','code','DeskAccount,\x20%s,\x20%s','message','result','catch','GetDeskAccount','DeskAccount','findAll','options','raw','attributes','limit','include','model','map','ShowDeskAccount','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','request','then','info','debug'];(function(_0x209941,_0x5c9988){var _0x1e8729=function(_0x51a9b8){while(--_0x51a9b8){_0x209941['push'](_0x209941['shift']());}};_0x1e8729(++_0x5c9988);}(_0x6467,0x1c0));var _0x7646=function(_0x5ad04e,_0x233e4e){_0x5ad04e=_0x5ad04e-0x0;var _0x19d0e0=_0x6467[_0x5ad04e];return _0x19d0e0;};'use strict';var _=require(_0x7646('0x0'));var util=require('util');var moment=require(_0x7646('0x1'));var BPromise=require('bluebird');var rs=require(_0x7646('0x2'));var fs=require('fs');var Redis=require(_0x7646('0x3'));var db=require(_0x7646('0x4'))['db'];var utils=require(_0x7646('0x5'));var logger=require('../../config/logger')(_0x7646('0x6'));var config=require(_0x7646('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x7646('0x8')][_0x7646('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3ff1e5,_0x5b6297,_0x351029){return new BPromise(function(_0x5d3b56,_0x1a6d45){return client[_0x7646('0xa')](_0x3ff1e5,_0x351029)[_0x7646('0xb')](function(_0x576cb3){logger[_0x7646('0xc')]('DeskAccount,\x20%s,\x20%s',_0x5b6297,'request\x20sent');logger[_0x7646('0xd')]('DeskAccount,\x20%s,\x20%s,\x20%s',_0x5b6297,_0x7646('0xe'),JSON[_0x7646('0xf')](_0x576cb3));if(_0x576cb3[_0x7646('0x10')]){if(_0x576cb3['error'][_0x7646('0x11')]===0x1f4){logger[_0x7646('0x10')](_0x7646('0x12'),_0x5b6297,_0x576cb3[_0x7646('0x10')][_0x7646('0x13')]);return _0x1a6d45(_0x576cb3[_0x7646('0x10')][_0x7646('0x13')]);}logger[_0x7646('0x10')]('DeskAccount,\x20%s,\x20%s',_0x5b6297,_0x576cb3[_0x7646('0x10')][_0x7646('0x13')]);return _0x5d3b56(_0x576cb3['error']['message']);}else{logger['info'](_0x7646('0x12'),_0x5b6297,_0x7646('0xe'));_0x5d3b56(_0x576cb3[_0x7646('0x14')][_0x7646('0x13')]);}})[_0x7646('0x15')](function(_0x45cde9){logger['error']('DeskAccount,\x20%s,\x20%s',_0x5b6297,_0x45cde9);_0x1a6d45(_0x45cde9);});});}exports[_0x7646('0x16')]=function(_0x2ceaf6){var _0xeb2038=this;return new Promise(function(_0x177d40,_0xb6b519){return db[_0x7646('0x17')][_0x7646('0x18')]({'raw':_0x2ceaf6[_0x7646('0x19')]?_0x2ceaf6[_0x7646('0x19')][_0x7646('0x1a')]===undefined?!![]:![]:!![],'where':_0x2ceaf6[_0x7646('0x19')]?_0x2ceaf6['options']['where']||null:null,'attributes':_0x2ceaf6[_0x7646('0x19')]?_0x2ceaf6[_0x7646('0x19')][_0x7646('0x1b')]||null:null,'limit':_0x2ceaf6['options']?_0x2ceaf6[_0x7646('0x19')][_0x7646('0x1c')]||null:null,'include':_0x2ceaf6[_0x7646('0x19')]?_0x2ceaf6['options']['include']?_['map'](_0x2ceaf6[_0x7646('0x19')][_0x7646('0x1d')],function(_0x89d947){return{'model':db[_0x89d947[_0x7646('0x1e')]],'as':_0x89d947['as'],'attributes':_0x89d947[_0x7646('0x1b')],'include':_0x89d947[_0x7646('0x1d')]?_[_0x7646('0x1f')](_0x89d947[_0x7646('0x1d')],function(_0x12026a){return{'model':db[_0x12026a[_0x7646('0x1e')]],'as':_0x12026a['as'],'attributes':_0x12026a[_0x7646('0x1b')],'include':_0x12026a[_0x7646('0x1d')]?_[_0x7646('0x1f')](_0x12026a[_0x7646('0x1d')],function(_0x4d7ffe){return{'model':db[_0x4d7ffe[_0x7646('0x1e')]],'as':_0x4d7ffe['as'],'attributes':_0x4d7ffe[_0x7646('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x7646('0xb')](function(_0x67a3f4){logger[_0x7646('0xc')](_0x7646('0x16'),_0x2ceaf6);logger[_0x7646('0xd')](_0x7646('0x16'),_0x2ceaf6,JSON[_0x7646('0xf')](_0x67a3f4));_0x177d40(_0x67a3f4);})[_0x7646('0x15')](function(_0x40de2c){logger[_0x7646('0x10')]('GetDeskAccount',_0x40de2c[_0x7646('0x13')],_0x2ceaf6);_0xb6b519(_0xeb2038['error'](0x1f4,_0x40de2c['message']));});});};exports[_0x7646('0x20')]=function(_0x56814a){var _0x1aa625=this;return new Promise(function(_0x400114,_0x5d6c24){return db[_0x7646('0x17')]['find']({'raw':_0x56814a[_0x7646('0x19')]?_0x56814a[_0x7646('0x19')][_0x7646('0x1a')]===undefined?!![]:![]:!![],'where':_0x56814a[_0x7646('0x19')]?_0x56814a[_0x7646('0x19')]['where']||null:null,'attributes':_0x56814a[_0x7646('0x19')]?_0x56814a[_0x7646('0x19')][_0x7646('0x1b')]||null:null,'include':_0x56814a[_0x7646('0x19')]?_0x56814a[_0x7646('0x19')][_0x7646('0x1d')]?_[_0x7646('0x1f')](_0x56814a['options'][_0x7646('0x1d')],function(_0xa73eae){return{'model':db[_0xa73eae[_0x7646('0x1e')]],'as':_0xa73eae['as'],'attributes':_0xa73eae[_0x7646('0x1b')],'include':_0xa73eae[_0x7646('0x1d')]?_['map'](_0xa73eae[_0x7646('0x1d')],function(_0x2420a7){return{'model':db[_0x2420a7[_0x7646('0x1e')]],'as':_0x2420a7['as'],'attributes':_0x2420a7[_0x7646('0x1b')],'include':_0x2420a7[_0x7646('0x1d')]?_[_0x7646('0x1f')](_0x2420a7[_0x7646('0x1d')],function(_0x352c7d){return{'model':db[_0x352c7d[_0x7646('0x1e')]],'as':_0x352c7d['as'],'attributes':_0x352c7d[_0x7646('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x7646('0xb')](function(_0x5b80bf){logger[_0x7646('0xc')](_0x7646('0x20'),_0x56814a);logger[_0x7646('0xd')](_0x7646('0x20'),_0x56814a,JSON[_0x7646('0xf')](_0x5b80bf));_0x400114(_0x5b80bf);})[_0x7646('0x15')](function(_0x2b4d1b){logger[_0x7646('0x10')]('ShowDeskAccount',_0x2b4d1b['message'],_0x56814a);_0x5d6c24(_0x1aa625[_0x7646('0x10')](0x1f4,_0x2b4d1b[_0x7646('0x13')]));});});};