c5a207a55288b71c1f98e6f774d6cd97f0faaafe
[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 _0xf6c6=['stringify','error','code','FreshdeskAccount,\x20%s,\x20%s','message','result','GetFreshdeskAccount','findAll','options','raw','attributes','limit','include','model','map','then','catch','ShowFreshdeskAccount','FreshdeskAccount','find','where','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','request','info','debug','request\x20sent'];(function(_0x49020c,_0x55f5e8){var _0xc7dc3a=function(_0x51cb69){while(--_0x51cb69){_0x49020c['push'](_0x49020c['shift']());}};_0xc7dc3a(++_0x55f5e8);}(_0xf6c6,0xed));var _0x6f6c=function(_0x2e4e19,_0x493b50){_0x2e4e19=_0x2e4e19-0x0;var _0x9ba20b=_0xf6c6[_0x2e4e19];return _0x9ba20b;};'use strict';var _=require(_0x6f6c('0x0'));var util=require(_0x6f6c('0x1'));var moment=require(_0x6f6c('0x2'));var BPromise=require(_0x6f6c('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x6f6c('0x4'));var db=require(_0x6f6c('0x5'))['db'];var utils=require(_0x6f6c('0x6'));var logger=require(_0x6f6c('0x7'))('rpc');var config=require(_0x6f6c('0x8'));var jayson=require(_0x6f6c('0x9'));var client=jayson[_0x6f6c('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x158508,_0x10d84e,_0x4bb100){return new BPromise(function(_0x53f5c4,_0x4e57d1){return client[_0x6f6c('0xb')](_0x158508,_0x4bb100)['then'](function(_0x16c39d){logger[_0x6f6c('0xc')]('FreshdeskAccount,\x20%s,\x20%s',_0x10d84e,'request\x20sent');logger[_0x6f6c('0xd')]('FreshdeskAccount,\x20%s,\x20%s,\x20%s',_0x10d84e,_0x6f6c('0xe'),JSON[_0x6f6c('0xf')](_0x16c39d));if(_0x16c39d[_0x6f6c('0x10')]){if(_0x16c39d[_0x6f6c('0x10')][_0x6f6c('0x11')]===0x1f4){logger[_0x6f6c('0x10')](_0x6f6c('0x12'),_0x10d84e,_0x16c39d[_0x6f6c('0x10')]['message']);return _0x4e57d1(_0x16c39d['error'][_0x6f6c('0x13')]);}logger['error']('FreshdeskAccount,\x20%s,\x20%s',_0x10d84e,_0x16c39d[_0x6f6c('0x10')][_0x6f6c('0x13')]);return _0x53f5c4(_0x16c39d[_0x6f6c('0x10')][_0x6f6c('0x13')]);}else{logger[_0x6f6c('0xc')](_0x6f6c('0x12'),_0x10d84e,_0x6f6c('0xe'));_0x53f5c4(_0x16c39d[_0x6f6c('0x14')][_0x6f6c('0x13')]);}})['catch'](function(_0xe76fe9){logger[_0x6f6c('0x10')](_0x6f6c('0x12'),_0x10d84e,_0xe76fe9);_0x4e57d1(_0xe76fe9);});});}exports[_0x6f6c('0x15')]=function(_0x106b98){var _0xb5b0f0=this;return new Promise(function(_0x12e900,_0x12e163){return db['FreshdeskAccount'][_0x6f6c('0x16')]({'raw':_0x106b98[_0x6f6c('0x17')]?_0x106b98[_0x6f6c('0x17')][_0x6f6c('0x18')]===undefined?!![]:![]:!![],'where':_0x106b98[_0x6f6c('0x17')]?_0x106b98[_0x6f6c('0x17')]['where']||null:null,'attributes':_0x106b98['options']?_0x106b98[_0x6f6c('0x17')][_0x6f6c('0x19')]||null:null,'limit':_0x106b98[_0x6f6c('0x17')]?_0x106b98['options'][_0x6f6c('0x1a')]||null:null,'include':_0x106b98[_0x6f6c('0x17')]?_0x106b98['options'][_0x6f6c('0x1b')]?_['map'](_0x106b98[_0x6f6c('0x17')]['include'],function(_0x25c98e){return{'model':db[_0x25c98e[_0x6f6c('0x1c')]],'as':_0x25c98e['as'],'attributes':_0x25c98e[_0x6f6c('0x19')],'include':_0x25c98e[_0x6f6c('0x1b')]?_[_0x6f6c('0x1d')](_0x25c98e[_0x6f6c('0x1b')],function(_0x2da358){return{'model':db[_0x2da358[_0x6f6c('0x1c')]],'as':_0x2da358['as'],'attributes':_0x2da358['attributes'],'include':_0x2da358[_0x6f6c('0x1b')]?_['map'](_0x2da358['include'],function(_0x2253e5){return{'model':db[_0x2253e5[_0x6f6c('0x1c')]],'as':_0x2253e5['as'],'attributes':_0x2253e5[_0x6f6c('0x19')]};}):[]};}):[]};}):[]:[]})[_0x6f6c('0x1e')](function(_0x51c05a){logger[_0x6f6c('0xc')](_0x6f6c('0x15'),_0x106b98);logger['debug'](_0x6f6c('0x15'),_0x106b98,JSON[_0x6f6c('0xf')](_0x51c05a));_0x12e900(_0x51c05a);})[_0x6f6c('0x1f')](function(_0x5c845e){logger[_0x6f6c('0x10')](_0x6f6c('0x15'),_0x5c845e['message'],_0x106b98);_0x12e163(_0xb5b0f0['error'](0x1f4,_0x5c845e['message']));});});};exports[_0x6f6c('0x20')]=function(_0x3214d7){var _0xb3e5cb=this;return new Promise(function(_0x1ea880,_0x776f36){return db[_0x6f6c('0x21')][_0x6f6c('0x22')]({'raw':_0x3214d7[_0x6f6c('0x17')]?_0x3214d7[_0x6f6c('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x3214d7['options']?_0x3214d7[_0x6f6c('0x17')][_0x6f6c('0x23')]||null:null,'attributes':_0x3214d7[_0x6f6c('0x17')]?_0x3214d7[_0x6f6c('0x17')]['attributes']||null:null,'include':_0x3214d7['options']?_0x3214d7[_0x6f6c('0x17')][_0x6f6c('0x1b')]?_[_0x6f6c('0x1d')](_0x3214d7['options']['include'],function(_0x4cbcec){return{'model':db[_0x4cbcec[_0x6f6c('0x1c')]],'as':_0x4cbcec['as'],'attributes':_0x4cbcec['attributes'],'include':_0x4cbcec[_0x6f6c('0x1b')]?_[_0x6f6c('0x1d')](_0x4cbcec['include'],function(_0x240a08){return{'model':db[_0x240a08[_0x6f6c('0x1c')]],'as':_0x240a08['as'],'attributes':_0x240a08['attributes'],'include':_0x240a08[_0x6f6c('0x1b')]?_[_0x6f6c('0x1d')](_0x240a08[_0x6f6c('0x1b')],function(_0x56e544){return{'model':db[_0x56e544[_0x6f6c('0x1c')]],'as':_0x56e544['as'],'attributes':_0x56e544[_0x6f6c('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1ee5cb){logger[_0x6f6c('0xc')](_0x6f6c('0x20'),_0x3214d7);logger['debug'](_0x6f6c('0x20'),_0x3214d7,JSON[_0x6f6c('0xf')](_0x1ee5cb));_0x1ea880(_0x1ee5cb);})['catch'](function(_0xb10ab7){logger[_0x6f6c('0x10')](_0x6f6c('0x20'),_0xb10ab7[_0x6f6c('0x13')],_0x3214d7);_0x776f36(_0xb3e5cb[_0x6f6c('0x10')](0x1f4,_0xb10ab7['message']));});});};