Built motion from commit 1fa89557.|2.6.10
[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 _0x28e4=['then','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','FreshdeskAccount','findAll','options','raw','where','attributes','limit','include','map','model','debug','GetFreshdeskAccount','ShowFreshdeskAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','http','request'];(function(_0x2e822f,_0x1acc38){var _0x5c6ee4=function(_0x474058){while(--_0x474058){_0x2e822f['push'](_0x2e822f['shift']());}};_0x5c6ee4(++_0x1acc38);}(_0x28e4,0x11c));var _0x428e=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x28e4[_0x321bb2];return _0x9c12ed;};'use strict';var _=require(_0x428e('0x0'));var util=require(_0x428e('0x1'));var moment=require(_0x428e('0x2'));var BPromise=require(_0x428e('0x3'));var rs=require(_0x428e('0x4'));var fs=require('fs');var Redis=require(_0x428e('0x5'));var db=require(_0x428e('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x428e('0x7'));var config=require(_0x428e('0x8'));var jayson=require(_0x428e('0x9'));var client=jayson['client'][_0x428e('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4cdc6f,_0x154508,_0x5b0d72){return new BPromise(function(_0x516f8c,_0x501e67){return client[_0x428e('0xb')](_0x4cdc6f,_0x5b0d72)[_0x428e('0xc')](function(_0x1e87cf){logger['info'](_0x428e('0xd'),_0x154508,_0x428e('0xe'));logger['debug'](_0x428e('0xf'),_0x154508,_0x428e('0xe'),JSON[_0x428e('0x10')](_0x1e87cf));if(_0x1e87cf[_0x428e('0x11')]){if(_0x1e87cf[_0x428e('0x11')][_0x428e('0x12')]===0x1f4){logger[_0x428e('0x11')](_0x428e('0xd'),_0x154508,_0x1e87cf['error'][_0x428e('0x13')]);return _0x501e67(_0x1e87cf['error'][_0x428e('0x13')]);}logger[_0x428e('0x11')]('FreshdeskAccount,\x20%s,\x20%s',_0x154508,_0x1e87cf[_0x428e('0x11')][_0x428e('0x13')]);return _0x516f8c(_0x1e87cf[_0x428e('0x11')][_0x428e('0x13')]);}else{logger[_0x428e('0x14')](_0x428e('0xd'),_0x154508,_0x428e('0xe'));_0x516f8c(_0x1e87cf[_0x428e('0x15')][_0x428e('0x13')]);}})[_0x428e('0x16')](function(_0x570300){logger[_0x428e('0x11')]('FreshdeskAccount,\x20%s,\x20%s',_0x154508,_0x570300);_0x501e67(_0x570300);});});}exports['GetFreshdeskAccount']=function(_0x1064e2){var _0x3b7bc2=this;return new Promise(function(_0x27ede9,_0x22a0b7){return db[_0x428e('0x17')][_0x428e('0x18')]({'raw':_0x1064e2[_0x428e('0x19')]?_0x1064e2['options'][_0x428e('0x1a')]===undefined?!![]:![]:!![],'where':_0x1064e2[_0x428e('0x19')]?_0x1064e2['options'][_0x428e('0x1b')]||null:null,'attributes':_0x1064e2[_0x428e('0x19')]?_0x1064e2[_0x428e('0x19')][_0x428e('0x1c')]||null:null,'limit':_0x1064e2['options']?_0x1064e2['options'][_0x428e('0x1d')]||null:null,'include':_0x1064e2[_0x428e('0x19')]?_0x1064e2['options'][_0x428e('0x1e')]?_[_0x428e('0x1f')](_0x1064e2[_0x428e('0x19')][_0x428e('0x1e')],function(_0x10a32c){return{'model':db[_0x10a32c[_0x428e('0x20')]],'as':_0x10a32c['as'],'attributes':_0x10a32c[_0x428e('0x1c')],'include':_0x10a32c['include']?_[_0x428e('0x1f')](_0x10a32c[_0x428e('0x1e')],function(_0x482ef4){return{'model':db[_0x482ef4['model']],'as':_0x482ef4['as'],'attributes':_0x482ef4['attributes'],'include':_0x482ef4[_0x428e('0x1e')]?_['map'](_0x482ef4[_0x428e('0x1e')],function(_0x1a4312){return{'model':db[_0x1a4312['model']],'as':_0x1a4312['as'],'attributes':_0x1a4312['attributes']};}):[]};}):[]};}):[]:[]})[_0x428e('0xc')](function(_0x315fc2){logger[_0x428e('0x14')]('GetFreshdeskAccount',_0x1064e2);logger[_0x428e('0x21')](_0x428e('0x22'),_0x1064e2,JSON[_0x428e('0x10')](_0x315fc2));_0x27ede9(_0x315fc2);})['catch'](function(_0x9c9291){logger['error'](_0x428e('0x22'),_0x9c9291[_0x428e('0x13')],_0x1064e2);_0x22a0b7(_0x3b7bc2[_0x428e('0x11')](0x1f4,_0x9c9291[_0x428e('0x13')]));});});};exports[_0x428e('0x23')]=function(_0x11f778){var _0x3aec42=this;return new Promise(function(_0x2fa30b,_0x24f167){return db[_0x428e('0x17')][_0x428e('0x24')]({'raw':_0x11f778[_0x428e('0x19')]?_0x11f778[_0x428e('0x19')][_0x428e('0x1a')]===undefined?!![]:![]:!![],'where':_0x11f778[_0x428e('0x19')]?_0x11f778[_0x428e('0x19')]['where']||null:null,'attributes':_0x11f778[_0x428e('0x19')]?_0x11f778[_0x428e('0x19')][_0x428e('0x1c')]||null:null,'include':_0x11f778[_0x428e('0x19')]?_0x11f778[_0x428e('0x19')][_0x428e('0x1e')]?_[_0x428e('0x1f')](_0x11f778[_0x428e('0x19')][_0x428e('0x1e')],function(_0x5baa42){return{'model':db[_0x5baa42[_0x428e('0x20')]],'as':_0x5baa42['as'],'attributes':_0x5baa42[_0x428e('0x1c')],'include':_0x5baa42[_0x428e('0x1e')]?_['map'](_0x5baa42[_0x428e('0x1e')],function(_0x1f05cb){return{'model':db[_0x1f05cb['model']],'as':_0x1f05cb['as'],'attributes':_0x1f05cb['attributes'],'include':_0x1f05cb[_0x428e('0x1e')]?_[_0x428e('0x1f')](_0x1f05cb[_0x428e('0x1e')],function(_0x588781){return{'model':db[_0x588781['model']],'as':_0x588781['as'],'attributes':_0x588781[_0x428e('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x27e120){logger[_0x428e('0x14')](_0x428e('0x23'),_0x11f778);logger[_0x428e('0x21')](_0x428e('0x23'),_0x11f778,JSON[_0x428e('0x10')](_0x27e120));_0x2fa30b(_0x27e120);})[_0x428e('0x16')](function(_0x1e19ce){logger[_0x428e('0x11')](_0x428e('0x23'),_0x1e19ce[_0x428e('0x13')],_0x11f778);_0x24f167(_0x3aec42[_0x428e('0x11')](0x1f4,_0x1e19ce['message']));});});};