Built motion from commit efa66e19.|2.6.22
[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 _0xcb0f=['result','GetFreshdeskAccount','FreshdeskAccount','findAll','options','raw','attributes','limit','include','map','model','catch','ShowFreshdeskAccount','where','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','message'];(function(_0x1543b0,_0x22de65){var _0xaa76b1=function(_0x17741a){while(--_0x17741a){_0x1543b0['push'](_0x1543b0['shift']());}};_0xaa76b1(++_0x22de65);}(_0xcb0f,0x7d));var _0xfcb0=function(_0x14ed2f,_0x439945){_0x14ed2f=_0x14ed2f-0x0;var _0x5e29f9=_0xcb0f[_0x14ed2f];return _0x5e29f9;};'use strict';var _=require(_0xfcb0('0x0'));var util=require(_0xfcb0('0x1'));var moment=require(_0xfcb0('0x2'));var BPromise=require('bluebird');var rs=require(_0xfcb0('0x3'));var fs=require('fs');var Redis=require(_0xfcb0('0x4'));var db=require(_0xfcb0('0x5'))['db'];var utils=require(_0xfcb0('0x6'));var logger=require(_0xfcb0('0x7'))(_0xfcb0('0x8'));var config=require(_0xfcb0('0x9'));var jayson=require(_0xfcb0('0xa'));var client=jayson[_0xfcb0('0xb')][_0xfcb0('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x1c53d2,_0x50995c,_0x3c0b5c){return new BPromise(function(_0x3ac1e6,_0x5c291c){return client[_0xfcb0('0xd')](_0x1c53d2,_0x3c0b5c)[_0xfcb0('0xe')](function(_0xd25efb){logger[_0xfcb0('0xf')](_0xfcb0('0x10'),_0x50995c,_0xfcb0('0x11'));logger[_0xfcb0('0x12')](_0xfcb0('0x13'),_0x50995c,_0xfcb0('0x11'),JSON[_0xfcb0('0x14')](_0xd25efb));if(_0xd25efb['error']){if(_0xd25efb[_0xfcb0('0x15')]['code']===0x1f4){logger[_0xfcb0('0x15')]('FreshdeskAccount,\x20%s,\x20%s',_0x50995c,_0xd25efb[_0xfcb0('0x15')][_0xfcb0('0x16')]);return _0x5c291c(_0xd25efb[_0xfcb0('0x15')][_0xfcb0('0x16')]);}logger['error'](_0xfcb0('0x10'),_0x50995c,_0xd25efb[_0xfcb0('0x15')][_0xfcb0('0x16')]);return _0x3ac1e6(_0xd25efb[_0xfcb0('0x15')]['message']);}else{logger[_0xfcb0('0xf')](_0xfcb0('0x10'),_0x50995c,'request\x20sent');_0x3ac1e6(_0xd25efb[_0xfcb0('0x17')][_0xfcb0('0x16')]);}})['catch'](function(_0x45fa37){logger['error'](_0xfcb0('0x10'),_0x50995c,_0x45fa37);_0x5c291c(_0x45fa37);});});}exports[_0xfcb0('0x18')]=function(_0x387ca4){var _0x3a9a04=this;return new Promise(function(_0x594872,_0x28c96d){return db[_0xfcb0('0x19')][_0xfcb0('0x1a')]({'raw':_0x387ca4[_0xfcb0('0x1b')]?_0x387ca4[_0xfcb0('0x1b')][_0xfcb0('0x1c')]===undefined?!![]:![]:!![],'where':_0x387ca4['options']?_0x387ca4[_0xfcb0('0x1b')]['where']||null:null,'attributes':_0x387ca4[_0xfcb0('0x1b')]?_0x387ca4[_0xfcb0('0x1b')][_0xfcb0('0x1d')]||null:null,'limit':_0x387ca4[_0xfcb0('0x1b')]?_0x387ca4[_0xfcb0('0x1b')][_0xfcb0('0x1e')]||null:null,'include':_0x387ca4[_0xfcb0('0x1b')]?_0x387ca4['options'][_0xfcb0('0x1f')]?_[_0xfcb0('0x20')](_0x387ca4['options']['include'],function(_0x434460){return{'model':db[_0x434460[_0xfcb0('0x21')]],'as':_0x434460['as'],'attributes':_0x434460[_0xfcb0('0x1d')],'include':_0x434460['include']?_[_0xfcb0('0x20')](_0x434460[_0xfcb0('0x1f')],function(_0x163ccd){return{'model':db[_0x163ccd['model']],'as':_0x163ccd['as'],'attributes':_0x163ccd[_0xfcb0('0x1d')],'include':_0x163ccd['include']?_[_0xfcb0('0x20')](_0x163ccd[_0xfcb0('0x1f')],function(_0x1ab398){return{'model':db[_0x1ab398['model']],'as':_0x1ab398['as'],'attributes':_0x1ab398[_0xfcb0('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xfcb0('0xe')](function(_0x14f53a){logger['info'](_0xfcb0('0x18'),_0x387ca4);logger[_0xfcb0('0x12')](_0xfcb0('0x18'),_0x387ca4,JSON[_0xfcb0('0x14')](_0x14f53a));_0x594872(_0x14f53a);})[_0xfcb0('0x22')](function(_0x1b1287){logger[_0xfcb0('0x15')](_0xfcb0('0x18'),_0x1b1287[_0xfcb0('0x16')],_0x387ca4);_0x28c96d(_0x3a9a04['error'](0x1f4,_0x1b1287[_0xfcb0('0x16')]));});});};exports[_0xfcb0('0x23')]=function(_0x5285ea){var _0x158f9e=this;return new Promise(function(_0x36cdd7,_0x41debf){return db[_0xfcb0('0x19')]['find']({'raw':_0x5285ea[_0xfcb0('0x1b')]?_0x5285ea[_0xfcb0('0x1b')][_0xfcb0('0x1c')]===undefined?!![]:![]:!![],'where':_0x5285ea['options']?_0x5285ea['options'][_0xfcb0('0x24')]||null:null,'attributes':_0x5285ea[_0xfcb0('0x1b')]?_0x5285ea[_0xfcb0('0x1b')][_0xfcb0('0x1d')]||null:null,'include':_0x5285ea[_0xfcb0('0x1b')]?_0x5285ea[_0xfcb0('0x1b')][_0xfcb0('0x1f')]?_['map'](_0x5285ea[_0xfcb0('0x1b')]['include'],function(_0x3b3e21){return{'model':db[_0x3b3e21[_0xfcb0('0x21')]],'as':_0x3b3e21['as'],'attributes':_0x3b3e21[_0xfcb0('0x1d')],'include':_0x3b3e21['include']?_['map'](_0x3b3e21[_0xfcb0('0x1f')],function(_0x126ac7){return{'model':db[_0x126ac7[_0xfcb0('0x21')]],'as':_0x126ac7['as'],'attributes':_0x126ac7['attributes'],'include':_0x126ac7[_0xfcb0('0x1f')]?_[_0xfcb0('0x20')](_0x126ac7[_0xfcb0('0x1f')],function(_0x480fbc){return{'model':db[_0x480fbc['model']],'as':_0x480fbc['as'],'attributes':_0x480fbc[_0xfcb0('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xfcb0('0xe')](function(_0x4dffeb){logger['info']('ShowFreshdeskAccount',_0x5285ea);logger[_0xfcb0('0x12')](_0xfcb0('0x23'),_0x5285ea,JSON[_0xfcb0('0x14')](_0x4dffeb));_0x36cdd7(_0x4dffeb);})[_0xfcb0('0x22')](function(_0x47383c){logger[_0xfcb0('0x15')]('ShowFreshdeskAccount',_0x47383c['message'],_0x5285ea);_0x41debf(_0x158f9e['error'](0x1f4,_0x47383c[_0xfcb0('0x16')]));});});};