37eee4f1b20955f4734ae9aad545b344ffe986a0
[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 _0xca4b=['find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','findAll','options','raw','where','attributes','limit','include','map','model','then','GetFreshdeskAccount','ShowFreshdeskAccount','FreshdeskAccount'];(function(_0x4cce8,_0x22d1fe){var _0x458440=function(_0x3d15e4){while(--_0x3d15e4){_0x4cce8['push'](_0x4cce8['shift']());}};_0x458440(++_0x22d1fe);}(_0xca4b,0x1eb));var _0xbca4=function(_0x529a51,_0x408d27){_0x529a51=_0x529a51-0x0;var _0x29b763=_0xca4b[_0x529a51];return _0x29b763;};'use strict';var _=require(_0xbca4('0x0'));var util=require(_0xbca4('0x1'));var moment=require(_0xbca4('0x2'));var BPromise=require(_0xbca4('0x3'));var rs=require(_0xbca4('0x4'));var fs=require('fs');var Redis=require(_0xbca4('0x5'));var db=require(_0xbca4('0x6'))['db'];var utils=require(_0xbca4('0x7'));var logger=require(_0xbca4('0x8'))(_0xbca4('0x9'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xbca4('0xa')][_0xbca4('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x2e4bbe,_0x62292d,_0x56dd4f){return new BPromise(function(_0x3a2cd0,_0x3ba840){return client['request'](_0x2e4bbe,_0x56dd4f)['then'](function(_0x3922d7){logger[_0xbca4('0xc')](_0xbca4('0xd'),_0x62292d,_0xbca4('0xe'));logger[_0xbca4('0xf')]('FreshdeskAccount,\x20%s,\x20%s,\x20%s',_0x62292d,_0xbca4('0xe'),JSON[_0xbca4('0x10')](_0x3922d7));if(_0x3922d7[_0xbca4('0x11')]){if(_0x3922d7[_0xbca4('0x11')][_0xbca4('0x12')]===0x1f4){logger[_0xbca4('0x11')](_0xbca4('0xd'),_0x62292d,_0x3922d7[_0xbca4('0x11')][_0xbca4('0x13')]);return _0x3ba840(_0x3922d7['error'][_0xbca4('0x13')]);}logger[_0xbca4('0x11')]('FreshdeskAccount,\x20%s,\x20%s',_0x62292d,_0x3922d7[_0xbca4('0x11')][_0xbca4('0x13')]);return _0x3a2cd0(_0x3922d7[_0xbca4('0x11')][_0xbca4('0x13')]);}else{logger[_0xbca4('0xc')](_0xbca4('0xd'),_0x62292d,_0xbca4('0xe'));_0x3a2cd0(_0x3922d7['result'][_0xbca4('0x13')]);}})[_0xbca4('0x14')](function(_0x40704c){logger[_0xbca4('0x11')]('FreshdeskAccount,\x20%s,\x20%s',_0x62292d,_0x40704c);_0x3ba840(_0x40704c);});});}exports['GetFreshdeskAccount']=function(_0x4dc9aa){var _0x1b1e27=this;return new Promise(function(_0x3033da,_0x40f02a){return db['FreshdeskAccount'][_0xbca4('0x15')]({'raw':_0x4dc9aa['options']?_0x4dc9aa[_0xbca4('0x16')][_0xbca4('0x17')]===undefined?!![]:![]:!![],'where':_0x4dc9aa[_0xbca4('0x16')]?_0x4dc9aa['options'][_0xbca4('0x18')]||null:null,'attributes':_0x4dc9aa['options']?_0x4dc9aa[_0xbca4('0x16')][_0xbca4('0x19')]||null:null,'limit':_0x4dc9aa[_0xbca4('0x16')]?_0x4dc9aa[_0xbca4('0x16')][_0xbca4('0x1a')]||null:null,'include':_0x4dc9aa['options']?_0x4dc9aa['options'][_0xbca4('0x1b')]?_[_0xbca4('0x1c')](_0x4dc9aa['options'][_0xbca4('0x1b')],function(_0xa9be84){return{'model':db[_0xa9be84[_0xbca4('0x1d')]],'as':_0xa9be84['as'],'attributes':_0xa9be84[_0xbca4('0x19')],'include':_0xa9be84['include']?_[_0xbca4('0x1c')](_0xa9be84['include'],function(_0x3a1b8a){return{'model':db[_0x3a1b8a[_0xbca4('0x1d')]],'as':_0x3a1b8a['as'],'attributes':_0x3a1b8a[_0xbca4('0x19')],'include':_0x3a1b8a[_0xbca4('0x1b')]?_[_0xbca4('0x1c')](_0x3a1b8a[_0xbca4('0x1b')],function(_0x405a96){return{'model':db[_0x405a96[_0xbca4('0x1d')]],'as':_0x405a96['as'],'attributes':_0x405a96[_0xbca4('0x19')]};}):[]};}):[]};}):[]:[]})[_0xbca4('0x1e')](function(_0x5bd4d7){logger['info'](_0xbca4('0x1f'),_0x4dc9aa);logger[_0xbca4('0xf')]('GetFreshdeskAccount',_0x4dc9aa,JSON[_0xbca4('0x10')](_0x5bd4d7));_0x3033da(_0x5bd4d7);})[_0xbca4('0x14')](function(_0x5611f7){logger[_0xbca4('0x11')](_0xbca4('0x1f'),_0x5611f7[_0xbca4('0x13')],_0x4dc9aa);_0x40f02a(_0x1b1e27[_0xbca4('0x11')](0x1f4,_0x5611f7[_0xbca4('0x13')]));});});};exports[_0xbca4('0x20')]=function(_0x24a874){var _0x2f6c0d=this;return new Promise(function(_0x179589,_0xbcc412){return db[_0xbca4('0x21')][_0xbca4('0x22')]({'raw':_0x24a874[_0xbca4('0x16')]?_0x24a874[_0xbca4('0x16')][_0xbca4('0x17')]===undefined?!![]:![]:!![],'where':_0x24a874[_0xbca4('0x16')]?_0x24a874[_0xbca4('0x16')][_0xbca4('0x18')]||null:null,'attributes':_0x24a874[_0xbca4('0x16')]?_0x24a874['options'][_0xbca4('0x19')]||null:null,'include':_0x24a874['options']?_0x24a874[_0xbca4('0x16')][_0xbca4('0x1b')]?_[_0xbca4('0x1c')](_0x24a874['options'][_0xbca4('0x1b')],function(_0x5e79ab){return{'model':db[_0x5e79ab[_0xbca4('0x1d')]],'as':_0x5e79ab['as'],'attributes':_0x5e79ab[_0xbca4('0x19')],'include':_0x5e79ab[_0xbca4('0x1b')]?_['map'](_0x5e79ab[_0xbca4('0x1b')],function(_0x377c53){return{'model':db[_0x377c53['model']],'as':_0x377c53['as'],'attributes':_0x377c53[_0xbca4('0x19')],'include':_0x377c53['include']?_['map'](_0x377c53[_0xbca4('0x1b')],function(_0x85e6d8){return{'model':db[_0x85e6d8[_0xbca4('0x1d')]],'as':_0x85e6d8['as'],'attributes':_0x85e6d8[_0xbca4('0x19')]};}):[]};}):[]};}):[]:[]})[_0xbca4('0x1e')](function(_0x47cda8){logger[_0xbca4('0xc')](_0xbca4('0x20'),_0x24a874);logger[_0xbca4('0xf')](_0xbca4('0x20'),_0x24a874,JSON['stringify'](_0x47cda8));_0x179589(_0x47cda8);})[_0xbca4('0x14')](function(_0x3661ce){logger[_0xbca4('0x11')](_0xbca4('0x20'),_0x3661ce[_0xbca4('0x13')],_0x24a874);_0xbcc412(_0x2f6c0d[_0xbca4('0x11')](0x1f4,_0x3661ce['message']));});});};