1827396009df165f8dbf62a699a9e10b9b787108
[motion2.git] / server / api / intFreshdeskAccount / intFreshdeskAccount.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 _0x75a4=['debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetFreshdeskAccount','FreshdeskAccount','options','raw','attributes','limit','include','model','map','then','ShowFreshdeskAccount','find','where','lodash','util','moment','randomstring','../../config/logger','../../config/environment','jayson/promise','client','http','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent'];(function(_0x5b7364,_0x306bd3){var _0x129523=function(_0x24a175){while(--_0x24a175){_0x5b7364['push'](_0x5b7364['shift']());}};_0x129523(++_0x306bd3);}(_0x75a4,0x180));var _0x475a=function(_0x5a2254,_0x5560b3){_0x5a2254=_0x5a2254-0x0;var _0x29e850=_0x75a4[_0x5a2254];return _0x29e850;};'use strict';var _=require(_0x475a('0x0'));var util=require(_0x475a('0x1'));var moment=require(_0x475a('0x2'));var BPromise=require('bluebird');var rs=require(_0x475a('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x475a('0x4'))('rpc');var config=require(_0x475a('0x5'));var jayson=require(_0x475a('0x6'));var client=jayson[_0x475a('0x7')][_0x475a('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x352edf,_0x94bcc4,_0x33945b){return new BPromise(function(_0xdbac7f,_0x45c55f){return client['request'](_0x352edf,_0x33945b)['then'](function(_0xecea11){logger[_0x475a('0x9')](_0x475a('0xa'),_0x94bcc4,_0x475a('0xb'));logger[_0x475a('0xc')](_0x475a('0xd'),_0x94bcc4,_0x475a('0xb'),JSON[_0x475a('0xe')](_0xecea11));if(_0xecea11['error']){if(_0xecea11[_0x475a('0xf')][_0x475a('0x10')]===0x1f4){logger[_0x475a('0xf')](_0x475a('0xa'),_0x94bcc4,_0xecea11[_0x475a('0xf')][_0x475a('0x11')]);return _0x45c55f(_0xecea11[_0x475a('0xf')][_0x475a('0x11')]);}logger[_0x475a('0xf')]('FreshdeskAccount,\x20%s,\x20%s',_0x94bcc4,_0xecea11[_0x475a('0xf')][_0x475a('0x11')]);return _0xdbac7f(_0xecea11[_0x475a('0xf')][_0x475a('0x11')]);}else{logger[_0x475a('0x9')](_0x475a('0xa'),_0x94bcc4,_0x475a('0xb'));_0xdbac7f(_0xecea11[_0x475a('0x12')][_0x475a('0x11')]);}})[_0x475a('0x13')](function(_0x4c54ee){logger[_0x475a('0xf')](_0x475a('0xa'),_0x94bcc4,_0x4c54ee);_0x45c55f(_0x4c54ee);});});}exports[_0x475a('0x14')]=function(_0x3d7a07){var _0xce05c0=this;return new Promise(function(_0x11183b,_0x33dfd5){return db[_0x475a('0x15')]['findAll']({'raw':_0x3d7a07[_0x475a('0x16')]?_0x3d7a07[_0x475a('0x16')][_0x475a('0x17')]===undefined?!![]:![]:!![],'where':_0x3d7a07[_0x475a('0x16')]?_0x3d7a07[_0x475a('0x16')]['where']||null:null,'attributes':_0x3d7a07[_0x475a('0x16')]?_0x3d7a07['options'][_0x475a('0x18')]||null:null,'limit':_0x3d7a07[_0x475a('0x16')]?_0x3d7a07[_0x475a('0x16')][_0x475a('0x19')]||null:null,'include':_0x3d7a07[_0x475a('0x16')]?_0x3d7a07[_0x475a('0x16')][_0x475a('0x1a')]?_['map'](_0x3d7a07['options'][_0x475a('0x1a')],function(_0x352c9a){return{'model':db[_0x352c9a[_0x475a('0x1b')]],'as':_0x352c9a['as'],'attributes':_0x352c9a[_0x475a('0x18')],'include':_0x352c9a['include']?_['map'](_0x352c9a[_0x475a('0x1a')],function(_0x5804f2){return{'model':db[_0x5804f2[_0x475a('0x1b')]],'as':_0x5804f2['as'],'attributes':_0x5804f2[_0x475a('0x18')],'include':_0x5804f2[_0x475a('0x1a')]?_[_0x475a('0x1c')](_0x5804f2[_0x475a('0x1a')],function(_0x22906f){return{'model':db[_0x22906f['model']],'as':_0x22906f['as'],'attributes':_0x22906f[_0x475a('0x18')]};}):[]};}):[]};}):[]:[]})[_0x475a('0x1d')](function(_0x2bfe05){logger[_0x475a('0x9')]('GetFreshdeskAccount',_0x3d7a07);logger[_0x475a('0xc')](_0x475a('0x14'),_0x3d7a07,JSON[_0x475a('0xe')](_0x2bfe05));_0x11183b(_0x2bfe05);})[_0x475a('0x13')](function(_0x4aaed0){logger[_0x475a('0xf')]('GetFreshdeskAccount',_0x4aaed0['message'],_0x3d7a07);_0x33dfd5(_0xce05c0[_0x475a('0xf')](0x1f4,_0x4aaed0[_0x475a('0x11')]));});});};exports[_0x475a('0x1e')]=function(_0x734d7c){var _0x5662d9=this;return new Promise(function(_0x325697,_0x4be27e){return db[_0x475a('0x15')][_0x475a('0x1f')]({'raw':_0x734d7c[_0x475a('0x16')]?_0x734d7c[_0x475a('0x16')]['raw']===undefined?!![]:![]:!![],'where':_0x734d7c[_0x475a('0x16')]?_0x734d7c[_0x475a('0x16')][_0x475a('0x20')]||null:null,'attributes':_0x734d7c[_0x475a('0x16')]?_0x734d7c['options'][_0x475a('0x18')]||null:null,'include':_0x734d7c['options']?_0x734d7c[_0x475a('0x16')][_0x475a('0x1a')]?_[_0x475a('0x1c')](_0x734d7c[_0x475a('0x16')][_0x475a('0x1a')],function(_0x2707fd){return{'model':db[_0x2707fd[_0x475a('0x1b')]],'as':_0x2707fd['as'],'attributes':_0x2707fd['attributes'],'include':_0x2707fd['include']?_[_0x475a('0x1c')](_0x2707fd[_0x475a('0x1a')],function(_0xbcb95){return{'model':db[_0xbcb95[_0x475a('0x1b')]],'as':_0xbcb95['as'],'attributes':_0xbcb95[_0x475a('0x18')],'include':_0xbcb95['include']?_[_0x475a('0x1c')](_0xbcb95[_0x475a('0x1a')],function(_0x3939b4){return{'model':db[_0x3939b4[_0x475a('0x1b')]],'as':_0x3939b4['as'],'attributes':_0x3939b4['attributes']};}):[]};}):[]};}):[]:[]})[_0x475a('0x1d')](function(_0x52d97a){logger[_0x475a('0x9')](_0x475a('0x1e'),_0x734d7c);logger[_0x475a('0xc')]('ShowFreshdeskAccount',_0x734d7c,JSON[_0x475a('0xe')](_0x52d97a));_0x325697(_0x52d97a);})['catch'](function(_0x5c1146){logger[_0x475a('0xf')]('ShowFreshdeskAccount',_0x5c1146[_0x475a('0x11')],_0x734d7c);_0x4be27e(_0x5662d9[_0x475a('0xf')](0x1f4,_0x5c1146['message']));});});};