Built motion from commit (unavailable).|2.5.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 _0x12dc=['../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','request','then','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','info','catch','FreshdeskAccount','findAll','options','raw','where','limit','include','map','model','attributes','GetFreshdeskAccount','ShowFreshdeskAccount','find','lodash','util','moment','randomstring','ioredis','../../mysqldb'];(function(_0x14d250,_0x4b2e12){var _0xb991d8=function(_0x4ea76d){while(--_0x4ea76d){_0x14d250['push'](_0x14d250['shift']());}};_0xb991d8(++_0x4b2e12);}(_0x12dc,0x82));var _0xc12d=function(_0x2cd69d,_0x23c69e){_0x2cd69d=_0x2cd69d-0x0;var _0x16e4a5=_0x12dc[_0x2cd69d];return _0x16e4a5;};'use strict';var _=require(_0xc12d('0x0'));var util=require(_0xc12d('0x1'));var moment=require(_0xc12d('0x2'));var BPromise=require('bluebird');var rs=require(_0xc12d('0x3'));var fs=require('fs');var Redis=require(_0xc12d('0x4'));var db=require(_0xc12d('0x5'))['db'];var utils=require(_0xc12d('0x6'));var logger=require(_0xc12d('0x7'))('rpc');var config=require(_0xc12d('0x8'));var jayson=require(_0xc12d('0x9'));var client=jayson[_0xc12d('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5b2125,_0x4345fc,_0x3b0c8e){return new BPromise(function(_0x350d3d,_0xdba7be){return client[_0xc12d('0xb')](_0x5b2125,_0x3b0c8e)[_0xc12d('0xc')](function(_0x9ef27){logger['info'](_0xc12d('0xd'),_0x4345fc,_0xc12d('0xe'));logger[_0xc12d('0xf')]('FreshdeskAccount,\x20%s,\x20%s,\x20%s',_0x4345fc,'request\x20sent',JSON[_0xc12d('0x10')](_0x9ef27));if(_0x9ef27[_0xc12d('0x11')]){if(_0x9ef27[_0xc12d('0x11')]['code']===0x1f4){logger[_0xc12d('0x11')](_0xc12d('0xd'),_0x4345fc,_0x9ef27['error'][_0xc12d('0x12')]);return _0xdba7be(_0x9ef27['error']['message']);}logger['error']('FreshdeskAccount,\x20%s,\x20%s',_0x4345fc,_0x9ef27[_0xc12d('0x11')]['message']);return _0x350d3d(_0x9ef27[_0xc12d('0x11')]['message']);}else{logger[_0xc12d('0x13')]('FreshdeskAccount,\x20%s,\x20%s',_0x4345fc,_0xc12d('0xe'));_0x350d3d(_0x9ef27['result'][_0xc12d('0x12')]);}})[_0xc12d('0x14')](function(_0xc6a446){logger[_0xc12d('0x11')](_0xc12d('0xd'),_0x4345fc,_0xc6a446);_0xdba7be(_0xc6a446);});});}exports['GetFreshdeskAccount']=function(_0x16d1ec){var _0x357ec0=this;return new Promise(function(_0x52517e,_0x2131a2){return db[_0xc12d('0x15')][_0xc12d('0x16')]({'raw':_0x16d1ec['options']?_0x16d1ec[_0xc12d('0x17')][_0xc12d('0x18')]===undefined?!![]:![]:!![],'where':_0x16d1ec[_0xc12d('0x17')]?_0x16d1ec[_0xc12d('0x17')][_0xc12d('0x19')]||null:null,'attributes':_0x16d1ec['options']?_0x16d1ec['options']['attributes']||null:null,'limit':_0x16d1ec[_0xc12d('0x17')]?_0x16d1ec[_0xc12d('0x17')][_0xc12d('0x1a')]||null:null,'include':_0x16d1ec['options']?_0x16d1ec[_0xc12d('0x17')][_0xc12d('0x1b')]?_[_0xc12d('0x1c')](_0x16d1ec['options'][_0xc12d('0x1b')],function(_0x5d5e1b){return{'model':db[_0x5d5e1b[_0xc12d('0x1d')]],'as':_0x5d5e1b['as'],'attributes':_0x5d5e1b['attributes'],'include':_0x5d5e1b[_0xc12d('0x1b')]?_['map'](_0x5d5e1b[_0xc12d('0x1b')],function(_0x320b03){return{'model':db[_0x320b03[_0xc12d('0x1d')]],'as':_0x320b03['as'],'attributes':_0x320b03[_0xc12d('0x1e')],'include':_0x320b03[_0xc12d('0x1b')]?_[_0xc12d('0x1c')](_0x320b03[_0xc12d('0x1b')],function(_0x364746){return{'model':db[_0x364746[_0xc12d('0x1d')]],'as':_0x364746['as'],'attributes':_0x364746[_0xc12d('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x29f9f4){logger['info'](_0xc12d('0x1f'),_0x16d1ec);logger['debug'](_0xc12d('0x1f'),_0x16d1ec,JSON['stringify'](_0x29f9f4));_0x52517e(_0x29f9f4);})[_0xc12d('0x14')](function(_0x5203a0){logger[_0xc12d('0x11')](_0xc12d('0x1f'),_0x5203a0['message'],_0x16d1ec);_0x2131a2(_0x357ec0[_0xc12d('0x11')](0x1f4,_0x5203a0[_0xc12d('0x12')]));});});};exports[_0xc12d('0x20')]=function(_0x5e9981){var _0xd543be=this;return new Promise(function(_0x457819,_0x49e8d0){return db[_0xc12d('0x15')][_0xc12d('0x21')]({'raw':_0x5e9981[_0xc12d('0x17')]?_0x5e9981[_0xc12d('0x17')][_0xc12d('0x18')]===undefined?!![]:![]:!![],'where':_0x5e9981[_0xc12d('0x17')]?_0x5e9981[_0xc12d('0x17')][_0xc12d('0x19')]||null:null,'attributes':_0x5e9981['options']?_0x5e9981[_0xc12d('0x17')][_0xc12d('0x1e')]||null:null,'include':_0x5e9981[_0xc12d('0x17')]?_0x5e9981[_0xc12d('0x17')]['include']?_['map'](_0x5e9981['options'][_0xc12d('0x1b')],function(_0x284c63){return{'model':db[_0x284c63[_0xc12d('0x1d')]],'as':_0x284c63['as'],'attributes':_0x284c63[_0xc12d('0x1e')],'include':_0x284c63[_0xc12d('0x1b')]?_['map'](_0x284c63[_0xc12d('0x1b')],function(_0x57ab16){return{'model':db[_0x57ab16[_0xc12d('0x1d')]],'as':_0x57ab16['as'],'attributes':_0x57ab16['attributes'],'include':_0x57ab16[_0xc12d('0x1b')]?_['map'](_0x57ab16['include'],function(_0x289311){return{'model':db[_0x289311[_0xc12d('0x1d')]],'as':_0x289311['as'],'attributes':_0x289311[_0xc12d('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xc12d('0xc')](function(_0x4ff97b){logger[_0xc12d('0x13')]('ShowFreshdeskAccount',_0x5e9981);logger[_0xc12d('0xf')](_0xc12d('0x20'),_0x5e9981,JSON[_0xc12d('0x10')](_0x4ff97b));_0x457819(_0x4ff97b);})['catch'](function(_0x29202a){logger[_0xc12d('0x11')](_0xc12d('0x20'),_0x29202a[_0xc12d('0x12')],_0x5e9981);_0x49e8d0(_0xd543be[_0xc12d('0x11')](0x1f4,_0x29202a[_0xc12d('0x12')]));});});};