Built motion from commit f94df7f0.|2.5.48
[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 _0x8075=['find','lodash','util','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','client','request','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetFreshdeskAccount','findAll','options','raw','where','attributes','limit','include','map','model','then','ShowFreshdeskAccount','FreshdeskAccount'];(function(_0xbcd8d9,_0x16451e){var _0x4e7d8f=function(_0x1f198a){while(--_0x1f198a){_0xbcd8d9['push'](_0xbcd8d9['shift']());}};_0x4e7d8f(++_0x16451e);}(_0x8075,0xab));var _0x5807=function(_0x3563b0,_0x3ebb72){_0x3563b0=_0x3563b0-0x0;var _0x5d1c9d=_0x8075[_0x3563b0];return _0x5d1c9d;};'use strict';var _=require(_0x5807('0x0'));var util=require(_0x5807('0x1'));var moment=require('moment');var BPromise=require(_0x5807('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5807('0x3'));var db=require(_0x5807('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x5807('0x5'))(_0x5807('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x5807('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x308e83,_0x1f2ddc,_0x2b84d0){return new BPromise(function(_0x1e98cf,_0x29e888){return client[_0x5807('0x8')](_0x308e83,_0x2b84d0)['then'](function(_0x47f3dc){logger[_0x5807('0x9')](_0x5807('0xa'),_0x1f2ddc,_0x5807('0xb'));logger[_0x5807('0xc')](_0x5807('0xd'),_0x1f2ddc,_0x5807('0xb'),JSON[_0x5807('0xe')](_0x47f3dc));if(_0x47f3dc[_0x5807('0xf')]){if(_0x47f3dc[_0x5807('0xf')][_0x5807('0x10')]===0x1f4){logger[_0x5807('0xf')]('FreshdeskAccount,\x20%s,\x20%s',_0x1f2ddc,_0x47f3dc[_0x5807('0xf')][_0x5807('0x11')]);return _0x29e888(_0x47f3dc[_0x5807('0xf')][_0x5807('0x11')]);}logger[_0x5807('0xf')](_0x5807('0xa'),_0x1f2ddc,_0x47f3dc[_0x5807('0xf')][_0x5807('0x11')]);return _0x1e98cf(_0x47f3dc[_0x5807('0xf')][_0x5807('0x11')]);}else{logger[_0x5807('0x9')](_0x5807('0xa'),_0x1f2ddc,_0x5807('0xb'));_0x1e98cf(_0x47f3dc[_0x5807('0x12')][_0x5807('0x11')]);}})[_0x5807('0x13')](function(_0x3db6ea){logger[_0x5807('0xf')]('FreshdeskAccount,\x20%s,\x20%s',_0x1f2ddc,_0x3db6ea);_0x29e888(_0x3db6ea);});});}exports[_0x5807('0x14')]=function(_0x24dec8){var _0x3c6121=this;return new Promise(function(_0x9c184c,_0x2015d0){return db['FreshdeskAccount'][_0x5807('0x15')]({'raw':_0x24dec8[_0x5807('0x16')]?_0x24dec8[_0x5807('0x16')][_0x5807('0x17')]===undefined?!![]:![]:!![],'where':_0x24dec8['options']?_0x24dec8[_0x5807('0x16')][_0x5807('0x18')]||null:null,'attributes':_0x24dec8[_0x5807('0x16')]?_0x24dec8[_0x5807('0x16')][_0x5807('0x19')]||null:null,'limit':_0x24dec8[_0x5807('0x16')]?_0x24dec8[_0x5807('0x16')][_0x5807('0x1a')]||null:null,'include':_0x24dec8['options']?_0x24dec8['options'][_0x5807('0x1b')]?_[_0x5807('0x1c')](_0x24dec8[_0x5807('0x16')]['include'],function(_0x32360e){return{'model':db[_0x32360e[_0x5807('0x1d')]],'as':_0x32360e['as'],'attributes':_0x32360e['attributes'],'include':_0x32360e[_0x5807('0x1b')]?_[_0x5807('0x1c')](_0x32360e[_0x5807('0x1b')],function(_0x50dac1){return{'model':db[_0x50dac1[_0x5807('0x1d')]],'as':_0x50dac1['as'],'attributes':_0x50dac1[_0x5807('0x19')],'include':_0x50dac1[_0x5807('0x1b')]?_[_0x5807('0x1c')](_0x50dac1['include'],function(_0x5ccaf1){return{'model':db[_0x5ccaf1[_0x5807('0x1d')]],'as':_0x5ccaf1['as'],'attributes':_0x5ccaf1['attributes']};}):[]};}):[]};}):[]:[]})[_0x5807('0x1e')](function(_0x73ac38){logger[_0x5807('0x9')]('GetFreshdeskAccount',_0x24dec8);logger[_0x5807('0xc')]('GetFreshdeskAccount',_0x24dec8,JSON['stringify'](_0x73ac38));_0x9c184c(_0x73ac38);})[_0x5807('0x13')](function(_0x4966fa){logger[_0x5807('0xf')]('GetFreshdeskAccount',_0x4966fa[_0x5807('0x11')],_0x24dec8);_0x2015d0(_0x3c6121[_0x5807('0xf')](0x1f4,_0x4966fa[_0x5807('0x11')]));});});};exports[_0x5807('0x1f')]=function(_0x3815d4){var _0x45e977=this;return new Promise(function(_0x3bf634,_0x5cecce){return db[_0x5807('0x20')][_0x5807('0x21')]({'raw':_0x3815d4['options']?_0x3815d4['options'][_0x5807('0x17')]===undefined?!![]:![]:!![],'where':_0x3815d4[_0x5807('0x16')]?_0x3815d4[_0x5807('0x16')][_0x5807('0x18')]||null:null,'attributes':_0x3815d4[_0x5807('0x16')]?_0x3815d4[_0x5807('0x16')]['attributes']||null:null,'include':_0x3815d4[_0x5807('0x16')]?_0x3815d4[_0x5807('0x16')][_0x5807('0x1b')]?_[_0x5807('0x1c')](_0x3815d4['options'][_0x5807('0x1b')],function(_0x49713f){return{'model':db[_0x49713f[_0x5807('0x1d')]],'as':_0x49713f['as'],'attributes':_0x49713f[_0x5807('0x19')],'include':_0x49713f[_0x5807('0x1b')]?_[_0x5807('0x1c')](_0x49713f['include'],function(_0x3eb149){return{'model':db[_0x3eb149[_0x5807('0x1d')]],'as':_0x3eb149['as'],'attributes':_0x3eb149[_0x5807('0x19')],'include':_0x3eb149[_0x5807('0x1b')]?_[_0x5807('0x1c')](_0x3eb149[_0x5807('0x1b')],function(_0x299a33){return{'model':db[_0x299a33['model']],'as':_0x299a33['as'],'attributes':_0x299a33[_0x5807('0x19')]};}):[]};}):[]};}):[]:[]})[_0x5807('0x1e')](function(_0x5f289c){logger[_0x5807('0x9')](_0x5807('0x1f'),_0x3815d4);logger['debug'](_0x5807('0x1f'),_0x3815d4,JSON[_0x5807('0xe')](_0x5f289c));_0x3bf634(_0x5f289c);})[_0x5807('0x13')](function(_0x4b243e){logger['error']('ShowFreshdeskAccount',_0x4b243e['message'],_0x3815d4);_0x5cecce(_0x45e977[_0x5807('0xf')](0x1f4,_0x4b243e[_0x5807('0x11')]));});});};