cee6a684870fa9fbfce18b30720e619effb5cac7
[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 _0x1402=['client','http','then','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','GetFreshdeskAccount','FreshdeskAccount','findAll','options','raw','where','attributes','limit','include','model','map','debug','catch','ShowFreshdeskAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','jayson/promise'];(function(_0x2395cc,_0x159ebe){var _0x380e6f=function(_0x2da383){while(--_0x2da383){_0x2395cc['push'](_0x2395cc['shift']());}};_0x380e6f(++_0x159ebe);}(_0x1402,0x121));var _0x2140=function(_0x1d2a11,_0x44e346){_0x1d2a11=_0x1d2a11-0x0;var _0xc2dee0=_0x1402[_0x1d2a11];return _0xc2dee0;};'use strict';var _=require(_0x2140('0x0'));var util=require(_0x2140('0x1'));var moment=require(_0x2140('0x2'));var BPromise=require(_0x2140('0x3'));var rs=require(_0x2140('0x4'));var fs=require('fs');var Redis=require(_0x2140('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x2140('0x6'))('rpc');var config=require('../../config/environment');var jayson=require(_0x2140('0x7'));var client=jayson[_0x2140('0x8')][_0x2140('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3ad262,_0x18e2f4,_0x1a97f4){return new BPromise(function(_0x5dffd7,_0x162c1c){return client['request'](_0x3ad262,_0x1a97f4)[_0x2140('0xa')](function(_0x1e6634){logger[_0x2140('0xb')](_0x2140('0xc'),_0x18e2f4,_0x2140('0xd'));logger['debug']('FreshdeskAccount,\x20%s,\x20%s,\x20%s',_0x18e2f4,_0x2140('0xd'),JSON[_0x2140('0xe')](_0x1e6634));if(_0x1e6634['error']){if(_0x1e6634[_0x2140('0xf')][_0x2140('0x10')]===0x1f4){logger['error'](_0x2140('0xc'),_0x18e2f4,_0x1e6634[_0x2140('0xf')][_0x2140('0x11')]);return _0x162c1c(_0x1e6634[_0x2140('0xf')][_0x2140('0x11')]);}logger['error'](_0x2140('0xc'),_0x18e2f4,_0x1e6634[_0x2140('0xf')]['message']);return _0x5dffd7(_0x1e6634[_0x2140('0xf')][_0x2140('0x11')]);}else{logger[_0x2140('0xb')](_0x2140('0xc'),_0x18e2f4,'request\x20sent');_0x5dffd7(_0x1e6634['result'][_0x2140('0x11')]);}})['catch'](function(_0x4b84cb){logger[_0x2140('0xf')](_0x2140('0xc'),_0x18e2f4,_0x4b84cb);_0x162c1c(_0x4b84cb);});});}exports[_0x2140('0x12')]=function(_0x51a6da){var _0x31a0fa=this;return new Promise(function(_0x4fb0ad,_0x1b25fb){return db[_0x2140('0x13')][_0x2140('0x14')]({'raw':_0x51a6da[_0x2140('0x15')]?_0x51a6da[_0x2140('0x15')][_0x2140('0x16')]===undefined?!![]:![]:!![],'where':_0x51a6da[_0x2140('0x15')]?_0x51a6da['options'][_0x2140('0x17')]||null:null,'attributes':_0x51a6da['options']?_0x51a6da[_0x2140('0x15')][_0x2140('0x18')]||null:null,'limit':_0x51a6da[_0x2140('0x15')]?_0x51a6da[_0x2140('0x15')][_0x2140('0x19')]||null:null,'include':_0x51a6da[_0x2140('0x15')]?_0x51a6da['options'][_0x2140('0x1a')]?_['map'](_0x51a6da[_0x2140('0x15')][_0x2140('0x1a')],function(_0x592422){return{'model':db[_0x592422[_0x2140('0x1b')]],'as':_0x592422['as'],'attributes':_0x592422[_0x2140('0x18')],'include':_0x592422['include']?_['map'](_0x592422[_0x2140('0x1a')],function(_0x54169c){return{'model':db[_0x54169c[_0x2140('0x1b')]],'as':_0x54169c['as'],'attributes':_0x54169c[_0x2140('0x18')],'include':_0x54169c[_0x2140('0x1a')]?_[_0x2140('0x1c')](_0x54169c[_0x2140('0x1a')],function(_0x3e0da0){return{'model':db[_0x3e0da0[_0x2140('0x1b')]],'as':_0x3e0da0['as'],'attributes':_0x3e0da0[_0x2140('0x18')]};}):[]};}):[]};}):[]:[]})[_0x2140('0xa')](function(_0x3293d3){logger[_0x2140('0xb')](_0x2140('0x12'),_0x51a6da);logger[_0x2140('0x1d')](_0x2140('0x12'),_0x51a6da,JSON['stringify'](_0x3293d3));_0x4fb0ad(_0x3293d3);})[_0x2140('0x1e')](function(_0x24fe6a){logger['error'](_0x2140('0x12'),_0x24fe6a['message'],_0x51a6da);_0x1b25fb(_0x31a0fa[_0x2140('0xf')](0x1f4,_0x24fe6a[_0x2140('0x11')]));});});};exports[_0x2140('0x1f')]=function(_0x15e40c){var _0x1e6c9e=this;return new Promise(function(_0x452258,_0x2a08ac){return db[_0x2140('0x13')][_0x2140('0x20')]({'raw':_0x15e40c[_0x2140('0x15')]?_0x15e40c[_0x2140('0x15')][_0x2140('0x16')]===undefined?!![]:![]:!![],'where':_0x15e40c['options']?_0x15e40c['options'][_0x2140('0x17')]||null:null,'attributes':_0x15e40c['options']?_0x15e40c[_0x2140('0x15')]['attributes']||null:null,'include':_0x15e40c[_0x2140('0x15')]?_0x15e40c[_0x2140('0x15')][_0x2140('0x1a')]?_['map'](_0x15e40c['options']['include'],function(_0x4c6aa6){return{'model':db[_0x4c6aa6[_0x2140('0x1b')]],'as':_0x4c6aa6['as'],'attributes':_0x4c6aa6['attributes'],'include':_0x4c6aa6['include']?_[_0x2140('0x1c')](_0x4c6aa6[_0x2140('0x1a')],function(_0x46e4da){return{'model':db[_0x46e4da[_0x2140('0x1b')]],'as':_0x46e4da['as'],'attributes':_0x46e4da[_0x2140('0x18')],'include':_0x46e4da[_0x2140('0x1a')]?_[_0x2140('0x1c')](_0x46e4da[_0x2140('0x1a')],function(_0xeaaa90){return{'model':db[_0xeaaa90[_0x2140('0x1b')]],'as':_0xeaaa90['as'],'attributes':_0xeaaa90['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x397d91){logger['info'](_0x2140('0x1f'),_0x15e40c);logger[_0x2140('0x1d')](_0x2140('0x1f'),_0x15e40c,JSON[_0x2140('0xe')](_0x397d91));_0x452258(_0x397d91);})[_0x2140('0x1e')](function(_0x1f2de1){logger[_0x2140('0xf')](_0x2140('0x1f'),_0x1f2de1['message'],_0x15e40c);_0x2a08ac(_0x1e6c9e[_0x2140('0xf')](0x1f4,_0x1f2de1['message']));});});};