Built motion from commit (unavailable).|2.5.23
[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 _0x267a=['result','catch','GetFreshdeskAccount','FreshdeskAccount','findAll','options','raw','limit','map','include','attributes','model','where','ShowFreshdeskAccount','moment','bluebird','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','request','then','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','FreshdeskAccount,\x20%s,\x20%s','message','info'];(function(_0x14572b,_0x123f18){var _0x1812e8=function(_0x435f15){while(--_0x435f15){_0x14572b['push'](_0x14572b['shift']());}};_0x1812e8(++_0x123f18);}(_0x267a,0x140));var _0xa267=function(_0x4ae6ef,_0xc2af80){_0x4ae6ef=_0x4ae6ef-0x0;var _0x3cbb4e=_0x267a[_0x4ae6ef];return _0x3cbb4e;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xa267('0x0'));var BPromise=require(_0xa267('0x1'));var rs=require(_0xa267('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa267('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xa267('0x4'));var config=require(_0xa267('0x5'));var jayson=require(_0xa267('0x6'));var client=jayson[_0xa267('0x7')][_0xa267('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x14d113,_0x3c9cec,_0x257cc9){return new BPromise(function(_0x40e69f,_0x523608){return client[_0xa267('0x9')](_0x14d113,_0x257cc9)[_0xa267('0xa')](function(_0x23a7f9){logger['info']('FreshdeskAccount,\x20%s,\x20%s',_0x3c9cec,_0xa267('0xb'));logger[_0xa267('0xc')](_0xa267('0xd'),_0x3c9cec,_0xa267('0xb'),JSON[_0xa267('0xe')](_0x23a7f9));if(_0x23a7f9[_0xa267('0xf')]){if(_0x23a7f9[_0xa267('0xf')][_0xa267('0x10')]===0x1f4){logger['error'](_0xa267('0x11'),_0x3c9cec,_0x23a7f9[_0xa267('0xf')][_0xa267('0x12')]);return _0x523608(_0x23a7f9[_0xa267('0xf')][_0xa267('0x12')]);}logger[_0xa267('0xf')](_0xa267('0x11'),_0x3c9cec,_0x23a7f9[_0xa267('0xf')][_0xa267('0x12')]);return _0x40e69f(_0x23a7f9[_0xa267('0xf')][_0xa267('0x12')]);}else{logger[_0xa267('0x13')](_0xa267('0x11'),_0x3c9cec,_0xa267('0xb'));_0x40e69f(_0x23a7f9[_0xa267('0x14')][_0xa267('0x12')]);}})[_0xa267('0x15')](function(_0x2144da){logger['error'](_0xa267('0x11'),_0x3c9cec,_0x2144da);_0x523608(_0x2144da);});});}exports[_0xa267('0x16')]=function(_0x11a0c5){var _0x1f71bc=this;return new Promise(function(_0x4b544b,_0x3f2d1d){return db[_0xa267('0x17')][_0xa267('0x18')]({'raw':_0x11a0c5[_0xa267('0x19')]?_0x11a0c5[_0xa267('0x19')][_0xa267('0x1a')]===undefined?!![]:![]:!![],'where':_0x11a0c5[_0xa267('0x19')]?_0x11a0c5[_0xa267('0x19')]['where']||null:null,'attributes':_0x11a0c5['options']?_0x11a0c5[_0xa267('0x19')]['attributes']||null:null,'limit':_0x11a0c5[_0xa267('0x19')]?_0x11a0c5['options'][_0xa267('0x1b')]||null:null,'include':_0x11a0c5['options']?_0x11a0c5[_0xa267('0x19')]['include']?_[_0xa267('0x1c')](_0x11a0c5[_0xa267('0x19')][_0xa267('0x1d')],function(_0x4eae01){return{'model':db[_0x4eae01['model']],'as':_0x4eae01['as'],'attributes':_0x4eae01[_0xa267('0x1e')],'include':_0x4eae01['include']?_['map'](_0x4eae01[_0xa267('0x1d')],function(_0x3156c9){return{'model':db[_0x3156c9[_0xa267('0x1f')]],'as':_0x3156c9['as'],'attributes':_0x3156c9[_0xa267('0x1e')],'include':_0x3156c9[_0xa267('0x1d')]?_[_0xa267('0x1c')](_0x3156c9[_0xa267('0x1d')],function(_0x470796){return{'model':db[_0x470796['model']],'as':_0x470796['as'],'attributes':_0x470796[_0xa267('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xa267('0xa')](function(_0x163e31){logger['info']('GetFreshdeskAccount',_0x11a0c5);logger['debug'](_0xa267('0x16'),_0x11a0c5,JSON[_0xa267('0xe')](_0x163e31));_0x4b544b(_0x163e31);})[_0xa267('0x15')](function(_0xdddf25){logger[_0xa267('0xf')](_0xa267('0x16'),_0xdddf25[_0xa267('0x12')],_0x11a0c5);_0x3f2d1d(_0x1f71bc['error'](0x1f4,_0xdddf25[_0xa267('0x12')]));});});};exports['ShowFreshdeskAccount']=function(_0x172857){var _0x5a85ee=this;return new Promise(function(_0x5087d3,_0x47bffe){return db[_0xa267('0x17')]['find']({'raw':_0x172857[_0xa267('0x19')]?_0x172857[_0xa267('0x19')][_0xa267('0x1a')]===undefined?!![]:![]:!![],'where':_0x172857[_0xa267('0x19')]?_0x172857['options'][_0xa267('0x20')]||null:null,'attributes':_0x172857['options']?_0x172857[_0xa267('0x19')][_0xa267('0x1e')]||null:null,'include':_0x172857[_0xa267('0x19')]?_0x172857['options'][_0xa267('0x1d')]?_[_0xa267('0x1c')](_0x172857[_0xa267('0x19')][_0xa267('0x1d')],function(_0x3e53b2){return{'model':db[_0x3e53b2[_0xa267('0x1f')]],'as':_0x3e53b2['as'],'attributes':_0x3e53b2[_0xa267('0x1e')],'include':_0x3e53b2[_0xa267('0x1d')]?_['map'](_0x3e53b2[_0xa267('0x1d')],function(_0x3fa0e1){return{'model':db[_0x3fa0e1['model']],'as':_0x3fa0e1['as'],'attributes':_0x3fa0e1[_0xa267('0x1e')],'include':_0x3fa0e1['include']?_[_0xa267('0x1c')](_0x3fa0e1[_0xa267('0x1d')],function(_0x13f437){return{'model':db[_0x13f437[_0xa267('0x1f')]],'as':_0x13f437['as'],'attributes':_0x13f437['attributes']};}):[]};}):[]};}):[]:[]})[_0xa267('0xa')](function(_0x4e7efb){logger['info'](_0xa267('0x21'),_0x172857);logger['debug']('ShowFreshdeskAccount',_0x172857,JSON['stringify'](_0x4e7efb));_0x5087d3(_0x4e7efb);})['catch'](function(_0x51e531){logger[_0xa267('0xf')](_0xa267('0x21'),_0x51e531[_0xa267('0x12')],_0x172857);_0x47bffe(_0x5a85ee[_0xa267('0xf')](0x1f4,_0x51e531[_0xa267('0x12')]));});});};