c41a28e08be1ff219cb1cc75b4cd8620a00d1f08
[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 _0xbf00=['../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','FreshdeskAccount,\x20%s,\x20%s','message','info','catch','GetFreshdeskAccount','FreshdeskAccount','options','where','attributes','limit','include','map','model','ShowFreshdeskAccount','find','raw','then','lodash','moment','bluebird','randomstring','ioredis','../../config/utils'];(function(_0x1a6469,_0x1c392c){var _0x2bb042=function(_0x4d4557){while(--_0x4d4557){_0x1a6469['push'](_0x1a6469['shift']());}};_0x2bb042(++_0x1c392c);}(_0xbf00,0x170));var _0x0bf0=function(_0x3e478c,_0x3afee8){_0x3e478c=_0x3e478c-0x0;var _0x3a0906=_0xbf00[_0x3e478c];return _0x3a0906;};'use strict';var _=require(_0x0bf0('0x0'));var util=require('util');var moment=require(_0x0bf0('0x1'));var BPromise=require(_0x0bf0('0x2'));var rs=require(_0x0bf0('0x3'));var fs=require('fs');var Redis=require(_0x0bf0('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x0bf0('0x5'));var logger=require(_0x0bf0('0x6'))(_0x0bf0('0x7'));var config=require(_0x0bf0('0x8'));var jayson=require(_0x0bf0('0x9'));var client=jayson[_0x0bf0('0xa')][_0x0bf0('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x288e19,_0x29f053,_0x195a5b){return new BPromise(function(_0x22d935,_0xfdca80){return client['request'](_0x288e19,_0x195a5b)['then'](function(_0x3ac5c9){logger['info']('FreshdeskAccount,\x20%s,\x20%s',_0x29f053,_0x0bf0('0xc'));logger[_0x0bf0('0xd')](_0x0bf0('0xe'),_0x29f053,'request\x20sent',JSON[_0x0bf0('0xf')](_0x3ac5c9));if(_0x3ac5c9[_0x0bf0('0x10')]){if(_0x3ac5c9[_0x0bf0('0x10')]['code']===0x1f4){logger[_0x0bf0('0x10')](_0x0bf0('0x11'),_0x29f053,_0x3ac5c9[_0x0bf0('0x10')][_0x0bf0('0x12')]);return _0xfdca80(_0x3ac5c9[_0x0bf0('0x10')][_0x0bf0('0x12')]);}logger[_0x0bf0('0x10')]('FreshdeskAccount,\x20%s,\x20%s',_0x29f053,_0x3ac5c9[_0x0bf0('0x10')][_0x0bf0('0x12')]);return _0x22d935(_0x3ac5c9[_0x0bf0('0x10')][_0x0bf0('0x12')]);}else{logger[_0x0bf0('0x13')](_0x0bf0('0x11'),_0x29f053,_0x0bf0('0xc'));_0x22d935(_0x3ac5c9['result'][_0x0bf0('0x12')]);}})[_0x0bf0('0x14')](function(_0x38f54a){logger['error'](_0x0bf0('0x11'),_0x29f053,_0x38f54a);_0xfdca80(_0x38f54a);});});}exports[_0x0bf0('0x15')]=function(_0x501b3e){var _0x1e4d5f=this;return new Promise(function(_0x607504,_0x568fe4){return db[_0x0bf0('0x16')]['findAll']({'raw':_0x501b3e[_0x0bf0('0x17')]?_0x501b3e[_0x0bf0('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x501b3e[_0x0bf0('0x17')]?_0x501b3e['options'][_0x0bf0('0x18')]||null:null,'attributes':_0x501b3e[_0x0bf0('0x17')]?_0x501b3e[_0x0bf0('0x17')][_0x0bf0('0x19')]||null:null,'limit':_0x501b3e[_0x0bf0('0x17')]?_0x501b3e['options'][_0x0bf0('0x1a')]||null:null,'include':_0x501b3e[_0x0bf0('0x17')]?_0x501b3e[_0x0bf0('0x17')][_0x0bf0('0x1b')]?_[_0x0bf0('0x1c')](_0x501b3e[_0x0bf0('0x17')][_0x0bf0('0x1b')],function(_0x3276fa){return{'model':db[_0x3276fa[_0x0bf0('0x1d')]],'as':_0x3276fa['as'],'attributes':_0x3276fa[_0x0bf0('0x19')],'include':_0x3276fa[_0x0bf0('0x1b')]?_['map'](_0x3276fa['include'],function(_0x38ebb1){return{'model':db[_0x38ebb1['model']],'as':_0x38ebb1['as'],'attributes':_0x38ebb1[_0x0bf0('0x19')],'include':_0x38ebb1[_0x0bf0('0x1b')]?_[_0x0bf0('0x1c')](_0x38ebb1[_0x0bf0('0x1b')],function(_0x15b4a2){return{'model':db[_0x15b4a2[_0x0bf0('0x1d')]],'as':_0x15b4a2['as'],'attributes':_0x15b4a2['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x57bef2){logger['info']('GetFreshdeskAccount',_0x501b3e);logger[_0x0bf0('0xd')]('GetFreshdeskAccount',_0x501b3e,JSON[_0x0bf0('0xf')](_0x57bef2));_0x607504(_0x57bef2);})[_0x0bf0('0x14')](function(_0x1845c2){logger[_0x0bf0('0x10')](_0x0bf0('0x15'),_0x1845c2[_0x0bf0('0x12')],_0x501b3e);_0x568fe4(_0x1e4d5f[_0x0bf0('0x10')](0x1f4,_0x1845c2[_0x0bf0('0x12')]));});});};exports[_0x0bf0('0x1e')]=function(_0x3f9f49){var _0x1e8fb6=this;return new Promise(function(_0x1e7328,_0x2605e0){return db['FreshdeskAccount'][_0x0bf0('0x1f')]({'raw':_0x3f9f49[_0x0bf0('0x17')]?_0x3f9f49[_0x0bf0('0x17')][_0x0bf0('0x20')]===undefined?!![]:![]:!![],'where':_0x3f9f49[_0x0bf0('0x17')]?_0x3f9f49['options']['where']||null:null,'attributes':_0x3f9f49[_0x0bf0('0x17')]?_0x3f9f49['options'][_0x0bf0('0x19')]||null:null,'include':_0x3f9f49[_0x0bf0('0x17')]?_0x3f9f49[_0x0bf0('0x17')][_0x0bf0('0x1b')]?_[_0x0bf0('0x1c')](_0x3f9f49[_0x0bf0('0x17')]['include'],function(_0x13ff77){return{'model':db[_0x13ff77[_0x0bf0('0x1d')]],'as':_0x13ff77['as'],'attributes':_0x13ff77[_0x0bf0('0x19')],'include':_0x13ff77['include']?_[_0x0bf0('0x1c')](_0x13ff77[_0x0bf0('0x1b')],function(_0x5d59b9){return{'model':db[_0x5d59b9[_0x0bf0('0x1d')]],'as':_0x5d59b9['as'],'attributes':_0x5d59b9[_0x0bf0('0x19')],'include':_0x5d59b9[_0x0bf0('0x1b')]?_['map'](_0x5d59b9[_0x0bf0('0x1b')],function(_0x36c5df){return{'model':db[_0x36c5df[_0x0bf0('0x1d')]],'as':_0x36c5df['as'],'attributes':_0x36c5df[_0x0bf0('0x19')]};}):[]};}):[]};}):[]:[]})[_0x0bf0('0x21')](function(_0x42e7c5){logger['info'](_0x0bf0('0x1e'),_0x3f9f49);logger[_0x0bf0('0xd')](_0x0bf0('0x1e'),_0x3f9f49,JSON[_0x0bf0('0xf')](_0x42e7c5));_0x1e7328(_0x42e7c5);})['catch'](function(_0x3ad605){logger[_0x0bf0('0x10')](_0x0bf0('0x1e'),_0x3ad605[_0x0bf0('0x12')],_0x3f9f49);_0x2605e0(_0x1e8fb6[_0x0bf0('0x10')](0x1f4,_0x3ad605[_0x0bf0('0x12')]));});});};