Built motion from commit c738b9ac.|2.6.25
[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 _0x64b7=['../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','request\x20sent','debug','stringify','error','FreshdeskAccount,\x20%s,\x20%s','message','info','result','catch','GetFreshdeskAccount','findAll','options','attributes','limit','include','map','model','ShowFreshdeskAccount','FreshdeskAccount','find','raw','util','moment','bluebird','ioredis'];(function(_0xc78307,_0x1eeb36){var _0x17c9c0=function(_0x7a219c){while(--_0x7a219c){_0xc78307['push'](_0xc78307['shift']());}};_0x17c9c0(++_0x1eeb36);}(_0x64b7,0x194));var _0x764b=function(_0x1d1779,_0x284147){_0x1d1779=_0x1d1779-0x0;var _0x2377e9=_0x64b7[_0x1d1779];return _0x2377e9;};'use strict';var _=require('lodash');var util=require(_0x764b('0x0'));var moment=require(_0x764b('0x1'));var BPromise=require(_0x764b('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x764b('0x3'));var db=require(_0x764b('0x4'))['db'];var utils=require(_0x764b('0x5'));var logger=require(_0x764b('0x6'))(_0x764b('0x7'));var config=require(_0x764b('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x764b('0x9')][_0x764b('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3b3038,_0x53d658,_0x59816a){return new BPromise(function(_0x4821b3,_0x47ae39){return client[_0x764b('0xb')](_0x3b3038,_0x59816a)[_0x764b('0xc')](function(_0x16a7ac){logger['info']('FreshdeskAccount,\x20%s,\x20%s',_0x53d658,_0x764b('0xd'));logger[_0x764b('0xe')]('FreshdeskAccount,\x20%s,\x20%s,\x20%s',_0x53d658,_0x764b('0xd'),JSON[_0x764b('0xf')](_0x16a7ac));if(_0x16a7ac['error']){if(_0x16a7ac[_0x764b('0x10')]['code']===0x1f4){logger[_0x764b('0x10')](_0x764b('0x11'),_0x53d658,_0x16a7ac['error'][_0x764b('0x12')]);return _0x47ae39(_0x16a7ac[_0x764b('0x10')][_0x764b('0x12')]);}logger[_0x764b('0x10')]('FreshdeskAccount,\x20%s,\x20%s',_0x53d658,_0x16a7ac[_0x764b('0x10')][_0x764b('0x12')]);return _0x4821b3(_0x16a7ac[_0x764b('0x10')][_0x764b('0x12')]);}else{logger[_0x764b('0x13')](_0x764b('0x11'),_0x53d658,_0x764b('0xd'));_0x4821b3(_0x16a7ac[_0x764b('0x14')][_0x764b('0x12')]);}})[_0x764b('0x15')](function(_0x251105){logger[_0x764b('0x10')](_0x764b('0x11'),_0x53d658,_0x251105);_0x47ae39(_0x251105);});});}exports[_0x764b('0x16')]=function(_0x54dbff){var _0x2a33eb=this;return new Promise(function(_0x191bd0,_0x57dd2c){return db['FreshdeskAccount'][_0x764b('0x17')]({'raw':_0x54dbff[_0x764b('0x18')]?_0x54dbff[_0x764b('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x54dbff[_0x764b('0x18')]?_0x54dbff[_0x764b('0x18')]['where']||null:null,'attributes':_0x54dbff[_0x764b('0x18')]?_0x54dbff[_0x764b('0x18')][_0x764b('0x19')]||null:null,'limit':_0x54dbff[_0x764b('0x18')]?_0x54dbff[_0x764b('0x18')][_0x764b('0x1a')]||null:null,'include':_0x54dbff[_0x764b('0x18')]?_0x54dbff['options'][_0x764b('0x1b')]?_[_0x764b('0x1c')](_0x54dbff[_0x764b('0x18')][_0x764b('0x1b')],function(_0x4881df){return{'model':db[_0x4881df[_0x764b('0x1d')]],'as':_0x4881df['as'],'attributes':_0x4881df[_0x764b('0x19')],'include':_0x4881df[_0x764b('0x1b')]?_['map'](_0x4881df[_0x764b('0x1b')],function(_0x4024b5){return{'model':db[_0x4024b5[_0x764b('0x1d')]],'as':_0x4024b5['as'],'attributes':_0x4024b5[_0x764b('0x19')],'include':_0x4024b5[_0x764b('0x1b')]?_[_0x764b('0x1c')](_0x4024b5[_0x764b('0x1b')],function(_0x2b1013){return{'model':db[_0x2b1013['model']],'as':_0x2b1013['as'],'attributes':_0x2b1013['attributes']};}):[]};}):[]};}):[]:[]})[_0x764b('0xc')](function(_0x4ba373){logger['info'](_0x764b('0x16'),_0x54dbff);logger['debug'](_0x764b('0x16'),_0x54dbff,JSON[_0x764b('0xf')](_0x4ba373));_0x191bd0(_0x4ba373);})[_0x764b('0x15')](function(_0x5246fe){logger['error'](_0x764b('0x16'),_0x5246fe['message'],_0x54dbff);_0x57dd2c(_0x2a33eb[_0x764b('0x10')](0x1f4,_0x5246fe[_0x764b('0x12')]));});});};exports[_0x764b('0x1e')]=function(_0x276546){var _0x41a9a7=this;return new Promise(function(_0x583769,_0x33d36b){return db[_0x764b('0x1f')][_0x764b('0x20')]({'raw':_0x276546[_0x764b('0x18')]?_0x276546[_0x764b('0x18')][_0x764b('0x21')]===undefined?!![]:![]:!![],'where':_0x276546['options']?_0x276546['options']['where']||null:null,'attributes':_0x276546[_0x764b('0x18')]?_0x276546[_0x764b('0x18')]['attributes']||null:null,'include':_0x276546[_0x764b('0x18')]?_0x276546['options'][_0x764b('0x1b')]?_['map'](_0x276546[_0x764b('0x18')][_0x764b('0x1b')],function(_0x40570e){return{'model':db[_0x40570e[_0x764b('0x1d')]],'as':_0x40570e['as'],'attributes':_0x40570e['attributes'],'include':_0x40570e[_0x764b('0x1b')]?_['map'](_0x40570e['include'],function(_0x3860f1){return{'model':db[_0x3860f1[_0x764b('0x1d')]],'as':_0x3860f1['as'],'attributes':_0x3860f1['attributes'],'include':_0x3860f1['include']?_[_0x764b('0x1c')](_0x3860f1['include'],function(_0x30ccce){return{'model':db[_0x30ccce['model']],'as':_0x30ccce['as'],'attributes':_0x30ccce[_0x764b('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x11fc72){logger[_0x764b('0x13')]('ShowFreshdeskAccount',_0x276546);logger[_0x764b('0xe')](_0x764b('0x1e'),_0x276546,JSON['stringify'](_0x11fc72));_0x583769(_0x11fc72);})[_0x764b('0x15')](function(_0x404196){logger['error'](_0x764b('0x1e'),_0x404196[_0x764b('0x12')],_0x276546);_0x33d36b(_0x41a9a7[_0x764b('0x10')](0x1f4,_0x404196['message']));});});};