Built motion from commit (unavailable).|2.5.6
[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 _0x7a17=['request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','findAll','options','raw','where','attributes','limit','include','map','model','then','GetFreshdeskAccount','stringify','catch','ShowFreshdeskAccount','FreshdeskAccount','find','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','request','info','FreshdeskAccount,\x20%s,\x20%s'];(function(_0x488b42,_0x2eebf4){var _0x37e1c6=function(_0x5b37dc){while(--_0x5b37dc){_0x488b42['push'](_0x488b42['shift']());}};_0x37e1c6(++_0x2eebf4);}(_0x7a17,0x1a3));var _0x77a1=function(_0x330a87,_0xa0fe0d){_0x330a87=_0x330a87-0x0;var _0x3f51f8=_0x7a17[_0x330a87];return _0x3f51f8;};'use strict';var _=require(_0x77a1('0x0'));var util=require('util');var moment=require(_0x77a1('0x1'));var BPromise=require(_0x77a1('0x2'));var rs=require(_0x77a1('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x77a1('0x4'))['db'];var utils=require(_0x77a1('0x5'));var logger=require(_0x77a1('0x6'))(_0x77a1('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x77a1('0x8')][_0x77a1('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5df2eb,_0x55d27b,_0x87f51b){return new BPromise(function(_0x44da1d,_0x554c37){return client[_0x77a1('0xa')](_0x5df2eb,_0x87f51b)['then'](function(_0x25b5b3){logger[_0x77a1('0xb')](_0x77a1('0xc'),_0x55d27b,_0x77a1('0xd'));logger[_0x77a1('0xe')](_0x77a1('0xf'),_0x55d27b,_0x77a1('0xd'),JSON['stringify'](_0x25b5b3));if(_0x25b5b3[_0x77a1('0x10')]){if(_0x25b5b3[_0x77a1('0x10')][_0x77a1('0x11')]===0x1f4){logger['error'](_0x77a1('0xc'),_0x55d27b,_0x25b5b3[_0x77a1('0x10')]['message']);return _0x554c37(_0x25b5b3['error'][_0x77a1('0x12')]);}logger[_0x77a1('0x10')](_0x77a1('0xc'),_0x55d27b,_0x25b5b3[_0x77a1('0x10')][_0x77a1('0x12')]);return _0x44da1d(_0x25b5b3[_0x77a1('0x10')][_0x77a1('0x12')]);}else{logger[_0x77a1('0xb')](_0x77a1('0xc'),_0x55d27b,'request\x20sent');_0x44da1d(_0x25b5b3[_0x77a1('0x13')][_0x77a1('0x12')]);}})['catch'](function(_0x54746c){logger[_0x77a1('0x10')](_0x77a1('0xc'),_0x55d27b,_0x54746c);_0x554c37(_0x54746c);});});}exports['GetFreshdeskAccount']=function(_0x366d8b){var _0x17d902=this;return new Promise(function(_0x5c705a,_0x3a9d00){return db['FreshdeskAccount'][_0x77a1('0x14')]({'raw':_0x366d8b[_0x77a1('0x15')]?_0x366d8b[_0x77a1('0x15')][_0x77a1('0x16')]===undefined?!![]:![]:!![],'where':_0x366d8b[_0x77a1('0x15')]?_0x366d8b[_0x77a1('0x15')][_0x77a1('0x17')]||null:null,'attributes':_0x366d8b[_0x77a1('0x15')]?_0x366d8b['options'][_0x77a1('0x18')]||null:null,'limit':_0x366d8b['options']?_0x366d8b[_0x77a1('0x15')][_0x77a1('0x19')]||null:null,'include':_0x366d8b[_0x77a1('0x15')]?_0x366d8b['options'][_0x77a1('0x1a')]?_[_0x77a1('0x1b')](_0x366d8b[_0x77a1('0x15')][_0x77a1('0x1a')],function(_0x8c5224){return{'model':db[_0x8c5224[_0x77a1('0x1c')]],'as':_0x8c5224['as'],'attributes':_0x8c5224[_0x77a1('0x18')],'include':_0x8c5224['include']?_[_0x77a1('0x1b')](_0x8c5224[_0x77a1('0x1a')],function(_0x27a40f){return{'model':db[_0x27a40f[_0x77a1('0x1c')]],'as':_0x27a40f['as'],'attributes':_0x27a40f['attributes'],'include':_0x27a40f['include']?_['map'](_0x27a40f[_0x77a1('0x1a')],function(_0x3de68b){return{'model':db[_0x3de68b['model']],'as':_0x3de68b['as'],'attributes':_0x3de68b[_0x77a1('0x18')]};}):[]};}):[]};}):[]:[]})[_0x77a1('0x1d')](function(_0x628f8f){logger[_0x77a1('0xb')](_0x77a1('0x1e'),_0x366d8b);logger[_0x77a1('0xe')](_0x77a1('0x1e'),_0x366d8b,JSON[_0x77a1('0x1f')](_0x628f8f));_0x5c705a(_0x628f8f);})[_0x77a1('0x20')](function(_0x4d3780){logger['error'](_0x77a1('0x1e'),_0x4d3780['message'],_0x366d8b);_0x3a9d00(_0x17d902[_0x77a1('0x10')](0x1f4,_0x4d3780['message']));});});};exports[_0x77a1('0x21')]=function(_0x194bc7){var _0x508a61=this;return new Promise(function(_0xe0f5da,_0x535839){return db[_0x77a1('0x22')][_0x77a1('0x23')]({'raw':_0x194bc7['options']?_0x194bc7['options'][_0x77a1('0x16')]===undefined?!![]:![]:!![],'where':_0x194bc7['options']?_0x194bc7[_0x77a1('0x15')][_0x77a1('0x17')]||null:null,'attributes':_0x194bc7[_0x77a1('0x15')]?_0x194bc7[_0x77a1('0x15')]['attributes']||null:null,'include':_0x194bc7['options']?_0x194bc7[_0x77a1('0x15')][_0x77a1('0x1a')]?_['map'](_0x194bc7[_0x77a1('0x15')][_0x77a1('0x1a')],function(_0x485a06){return{'model':db[_0x485a06[_0x77a1('0x1c')]],'as':_0x485a06['as'],'attributes':_0x485a06['attributes'],'include':_0x485a06[_0x77a1('0x1a')]?_['map'](_0x485a06[_0x77a1('0x1a')],function(_0x581cbf){return{'model':db[_0x581cbf[_0x77a1('0x1c')]],'as':_0x581cbf['as'],'attributes':_0x581cbf[_0x77a1('0x18')],'include':_0x581cbf[_0x77a1('0x1a')]?_[_0x77a1('0x1b')](_0x581cbf[_0x77a1('0x1a')],function(_0x141a6c){return{'model':db[_0x141a6c[_0x77a1('0x1c')]],'as':_0x141a6c['as'],'attributes':_0x141a6c[_0x77a1('0x18')]};}):[]};}):[]};}):[]:[]})[_0x77a1('0x1d')](function(_0x24a06f){logger['info'](_0x77a1('0x21'),_0x194bc7);logger['debug'](_0x77a1('0x21'),_0x194bc7,JSON[_0x77a1('0x1f')](_0x24a06f));_0xe0f5da(_0x24a06f);})[_0x77a1('0x20')](function(_0x5c5efa){logger[_0x77a1('0x10')](_0x77a1('0x21'),_0x5c5efa[_0x77a1('0x12')],_0x194bc7);_0x535839(_0x508a61[_0x77a1('0x10')](0x1f4,_0x5c5efa[_0x77a1('0x12')]));});});};