Built motion from commit (unavailable).|2.5.11
[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 _0xb3d0=['info','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','FreshdeskAccount,\x20%s,\x20%s','message','GetFreshdeskAccount','FreshdeskAccount','findAll','options','raw','where','attributes','limit','include','map','then','stringify','catch','find','model','ShowFreshdeskAccount','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','request'];(function(_0x1b2763,_0x49e0b5){var _0x5a02a5=function(_0x4d13a9){while(--_0x4d13a9){_0x1b2763['push'](_0x1b2763['shift']());}};_0x5a02a5(++_0x49e0b5);}(_0xb3d0,0x18e));var _0x0b3d=function(_0x9272bd,_0xe1c15){_0x9272bd=_0x9272bd-0x0;var _0x3e8351=_0xb3d0[_0x9272bd];return _0x3e8351;};'use strict';var _=require(_0x0b3d('0x0'));var util=require('util');var moment=require(_0x0b3d('0x1'));var BPromise=require(_0x0b3d('0x2'));var rs=require(_0x0b3d('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x0b3d('0x4'))['db'];var utils=require(_0x0b3d('0x5'));var logger=require(_0x0b3d('0x6'))(_0x0b3d('0x7'));var config=require('../../config/environment');var jayson=require(_0x0b3d('0x8'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x5d1b09,_0x44e875,_0xa6c1a0){return new BPromise(function(_0x3c04b0,_0x15b1c3){return client[_0x0b3d('0x9')](_0x5d1b09,_0xa6c1a0)['then'](function(_0x41bf38){logger[_0x0b3d('0xa')]('FreshdeskAccount,\x20%s,\x20%s',_0x44e875,'request\x20sent');logger[_0x0b3d('0xb')](_0x0b3d('0xc'),_0x44e875,_0x0b3d('0xd'),JSON['stringify'](_0x41bf38));if(_0x41bf38[_0x0b3d('0xe')]){if(_0x41bf38[_0x0b3d('0xe')][_0x0b3d('0xf')]===0x1f4){logger[_0x0b3d('0xe')](_0x0b3d('0x10'),_0x44e875,_0x41bf38[_0x0b3d('0xe')]['message']);return _0x15b1c3(_0x41bf38[_0x0b3d('0xe')][_0x0b3d('0x11')]);}logger[_0x0b3d('0xe')]('FreshdeskAccount,\x20%s,\x20%s',_0x44e875,_0x41bf38['error'][_0x0b3d('0x11')]);return _0x3c04b0(_0x41bf38['error'][_0x0b3d('0x11')]);}else{logger[_0x0b3d('0xa')]('FreshdeskAccount,\x20%s,\x20%s',_0x44e875,'request\x20sent');_0x3c04b0(_0x41bf38['result'][_0x0b3d('0x11')]);}})['catch'](function(_0x563d7b){logger[_0x0b3d('0xe')](_0x0b3d('0x10'),_0x44e875,_0x563d7b);_0x15b1c3(_0x563d7b);});});}exports[_0x0b3d('0x12')]=function(_0x394e23){var _0x163d14=this;return new Promise(function(_0x4f3544,_0xb09cc5){return db[_0x0b3d('0x13')][_0x0b3d('0x14')]({'raw':_0x394e23[_0x0b3d('0x15')]?_0x394e23[_0x0b3d('0x15')][_0x0b3d('0x16')]===undefined?!![]:![]:!![],'where':_0x394e23[_0x0b3d('0x15')]?_0x394e23['options'][_0x0b3d('0x17')]||null:null,'attributes':_0x394e23[_0x0b3d('0x15')]?_0x394e23[_0x0b3d('0x15')][_0x0b3d('0x18')]||null:null,'limit':_0x394e23[_0x0b3d('0x15')]?_0x394e23['options'][_0x0b3d('0x19')]||null:null,'include':_0x394e23[_0x0b3d('0x15')]?_0x394e23[_0x0b3d('0x15')][_0x0b3d('0x1a')]?_['map'](_0x394e23[_0x0b3d('0x15')][_0x0b3d('0x1a')],function(_0x18a5a8){return{'model':db[_0x18a5a8['model']],'as':_0x18a5a8['as'],'attributes':_0x18a5a8[_0x0b3d('0x18')],'include':_0x18a5a8['include']?_['map'](_0x18a5a8[_0x0b3d('0x1a')],function(_0x1e53f8){return{'model':db[_0x1e53f8['model']],'as':_0x1e53f8['as'],'attributes':_0x1e53f8[_0x0b3d('0x18')],'include':_0x1e53f8[_0x0b3d('0x1a')]?_[_0x0b3d('0x1b')](_0x1e53f8[_0x0b3d('0x1a')],function(_0x37ceea){return{'model':db[_0x37ceea['model']],'as':_0x37ceea['as'],'attributes':_0x37ceea[_0x0b3d('0x18')]};}):[]};}):[]};}):[]:[]})[_0x0b3d('0x1c')](function(_0x95b7a5){logger[_0x0b3d('0xa')](_0x0b3d('0x12'),_0x394e23);logger['debug'](_0x0b3d('0x12'),_0x394e23,JSON[_0x0b3d('0x1d')](_0x95b7a5));_0x4f3544(_0x95b7a5);})[_0x0b3d('0x1e')](function(_0x294088){logger['error']('GetFreshdeskAccount',_0x294088[_0x0b3d('0x11')],_0x394e23);_0xb09cc5(_0x163d14[_0x0b3d('0xe')](0x1f4,_0x294088[_0x0b3d('0x11')]));});});};exports['ShowFreshdeskAccount']=function(_0x612933){var _0x9de2f5=this;return new Promise(function(_0x2bb28e,_0x4ec20f){return db[_0x0b3d('0x13')][_0x0b3d('0x1f')]({'raw':_0x612933[_0x0b3d('0x15')]?_0x612933[_0x0b3d('0x15')][_0x0b3d('0x16')]===undefined?!![]:![]:!![],'where':_0x612933[_0x0b3d('0x15')]?_0x612933['options'][_0x0b3d('0x17')]||null:null,'attributes':_0x612933['options']?_0x612933['options'][_0x0b3d('0x18')]||null:null,'include':_0x612933[_0x0b3d('0x15')]?_0x612933['options'][_0x0b3d('0x1a')]?_[_0x0b3d('0x1b')](_0x612933[_0x0b3d('0x15')]['include'],function(_0x874045){return{'model':db[_0x874045[_0x0b3d('0x20')]],'as':_0x874045['as'],'attributes':_0x874045['attributes'],'include':_0x874045[_0x0b3d('0x1a')]?_[_0x0b3d('0x1b')](_0x874045[_0x0b3d('0x1a')],function(_0x58ae95){return{'model':db[_0x58ae95[_0x0b3d('0x20')]],'as':_0x58ae95['as'],'attributes':_0x58ae95['attributes'],'include':_0x58ae95['include']?_[_0x0b3d('0x1b')](_0x58ae95[_0x0b3d('0x1a')],function(_0x18eb04){return{'model':db[_0x18eb04[_0x0b3d('0x20')]],'as':_0x18eb04['as'],'attributes':_0x18eb04[_0x0b3d('0x18')]};}):[]};}):[]};}):[]:[]})[_0x0b3d('0x1c')](function(_0x1f306c){logger[_0x0b3d('0xa')](_0x0b3d('0x21'),_0x612933);logger[_0x0b3d('0xb')](_0x0b3d('0x21'),_0x612933,JSON[_0x0b3d('0x1d')](_0x1f306c));_0x2bb28e(_0x1f306c);})[_0x0b3d('0x1e')](function(_0x4eb691){logger[_0x0b3d('0xe')](_0x0b3d('0x21'),_0x4eb691[_0x0b3d('0x11')],_0x612933);_0x4ec20f(_0x9de2f5[_0x0b3d('0xe')](0x1f4,_0x4eb691[_0x0b3d('0x11')]));});});};