64b37c74079309d260b9b7031ef03b324bf439ca
[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 _0x3aca=['attributes','ShowFreshdeskAccount','raw','lodash','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','FreshdeskAccount,\x20%s,\x20%s','message','catch','GetFreshdeskAccount','FreshdeskAccount','options','where','limit','map','include','model'];(function(_0x142412,_0x189a3b){var _0x3274b3=function(_0xd6e26f){while(--_0xd6e26f){_0x142412['push'](_0x142412['shift']());}};_0x3274b3(++_0x189a3b);}(_0x3aca,0x83));var _0xa3ac=function(_0x3fba9f,_0x3b7b9b){_0x3fba9f=_0x3fba9f-0x0;var _0x192cf1=_0x3aca[_0x3fba9f];return _0x192cf1;};'use strict';var _=require(_0xa3ac('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xa3ac('0x1'));var rs=require(_0xa3ac('0x2'));var fs=require('fs');var Redis=require(_0xa3ac('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xa3ac('0x4'));var logger=require(_0xa3ac('0x5'))(_0xa3ac('0x6'));var config=require(_0xa3ac('0x7'));var jayson=require(_0xa3ac('0x8'));var client=jayson['client'][_0xa3ac('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5d9b73,_0x4fd108,_0x389abc){return new BPromise(function(_0x4da43d,_0x423126){return client[_0xa3ac('0xa')](_0x5d9b73,_0x389abc)[_0xa3ac('0xb')](function(_0xd5985e){logger[_0xa3ac('0xc')]('FreshdeskAccount,\x20%s,\x20%s',_0x4fd108,_0xa3ac('0xd'));logger[_0xa3ac('0xe')](_0xa3ac('0xf'),_0x4fd108,'request\x20sent',JSON[_0xa3ac('0x10')](_0xd5985e));if(_0xd5985e[_0xa3ac('0x11')]){if(_0xd5985e[_0xa3ac('0x11')]['code']===0x1f4){logger[_0xa3ac('0x11')](_0xa3ac('0x12'),_0x4fd108,_0xd5985e[_0xa3ac('0x11')][_0xa3ac('0x13')]);return _0x423126(_0xd5985e[_0xa3ac('0x11')][_0xa3ac('0x13')]);}logger[_0xa3ac('0x11')]('FreshdeskAccount,\x20%s,\x20%s',_0x4fd108,_0xd5985e[_0xa3ac('0x11')]['message']);return _0x4da43d(_0xd5985e['error']['message']);}else{logger[_0xa3ac('0xc')](_0xa3ac('0x12'),_0x4fd108,_0xa3ac('0xd'));_0x4da43d(_0xd5985e['result'][_0xa3ac('0x13')]);}})[_0xa3ac('0x14')](function(_0x4ee54e){logger[_0xa3ac('0x11')](_0xa3ac('0x12'),_0x4fd108,_0x4ee54e);_0x423126(_0x4ee54e);});});}exports[_0xa3ac('0x15')]=function(_0x40d38a){var _0xf7521d=this;return new Promise(function(_0x5d1ab4,_0x48c8c7){return db[_0xa3ac('0x16')]['findAll']({'raw':_0x40d38a['options']?_0x40d38a[_0xa3ac('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x40d38a['options']?_0x40d38a['options'][_0xa3ac('0x18')]||null:null,'attributes':_0x40d38a[_0xa3ac('0x17')]?_0x40d38a[_0xa3ac('0x17')]['attributes']||null:null,'limit':_0x40d38a[_0xa3ac('0x17')]?_0x40d38a[_0xa3ac('0x17')][_0xa3ac('0x19')]||null:null,'include':_0x40d38a[_0xa3ac('0x17')]?_0x40d38a['options']['include']?_[_0xa3ac('0x1a')](_0x40d38a[_0xa3ac('0x17')][_0xa3ac('0x1b')],function(_0x331aba){return{'model':db[_0x331aba[_0xa3ac('0x1c')]],'as':_0x331aba['as'],'attributes':_0x331aba[_0xa3ac('0x1d')],'include':_0x331aba[_0xa3ac('0x1b')]?_[_0xa3ac('0x1a')](_0x331aba[_0xa3ac('0x1b')],function(_0x23b644){return{'model':db[_0x23b644['model']],'as':_0x23b644['as'],'attributes':_0x23b644['attributes'],'include':_0x23b644[_0xa3ac('0x1b')]?_[_0xa3ac('0x1a')](_0x23b644[_0xa3ac('0x1b')],function(_0x2a8dec){return{'model':db[_0x2a8dec[_0xa3ac('0x1c')]],'as':_0x2a8dec['as'],'attributes':_0x2a8dec[_0xa3ac('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xa3ac('0xb')](function(_0x189801){logger['info'](_0xa3ac('0x15'),_0x40d38a);logger[_0xa3ac('0xe')](_0xa3ac('0x15'),_0x40d38a,JSON[_0xa3ac('0x10')](_0x189801));_0x5d1ab4(_0x189801);})[_0xa3ac('0x14')](function(_0x4c1a2f){logger[_0xa3ac('0x11')]('GetFreshdeskAccount',_0x4c1a2f[_0xa3ac('0x13')],_0x40d38a);_0x48c8c7(_0xf7521d[_0xa3ac('0x11')](0x1f4,_0x4c1a2f[_0xa3ac('0x13')]));});});};exports[_0xa3ac('0x1e')]=function(_0x47f852){var _0x195845=this;return new Promise(function(_0x5a5847,_0x5e7d9b){return db[_0xa3ac('0x16')]['find']({'raw':_0x47f852[_0xa3ac('0x17')]?_0x47f852[_0xa3ac('0x17')][_0xa3ac('0x1f')]===undefined?!![]:![]:!![],'where':_0x47f852['options']?_0x47f852['options']['where']||null:null,'attributes':_0x47f852[_0xa3ac('0x17')]?_0x47f852[_0xa3ac('0x17')]['attributes']||null:null,'include':_0x47f852[_0xa3ac('0x17')]?_0x47f852[_0xa3ac('0x17')]['include']?_[_0xa3ac('0x1a')](_0x47f852[_0xa3ac('0x17')]['include'],function(_0x9ca2ca){return{'model':db[_0x9ca2ca[_0xa3ac('0x1c')]],'as':_0x9ca2ca['as'],'attributes':_0x9ca2ca['attributes'],'include':_0x9ca2ca['include']?_[_0xa3ac('0x1a')](_0x9ca2ca[_0xa3ac('0x1b')],function(_0x5bef2b){return{'model':db[_0x5bef2b[_0xa3ac('0x1c')]],'as':_0x5bef2b['as'],'attributes':_0x5bef2b[_0xa3ac('0x1d')],'include':_0x5bef2b['include']?_['map'](_0x5bef2b[_0xa3ac('0x1b')],function(_0x4ac44e){return{'model':db[_0x4ac44e[_0xa3ac('0x1c')]],'as':_0x4ac44e['as'],'attributes':_0x4ac44e[_0xa3ac('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xa3ac('0xb')](function(_0x2dd735){logger[_0xa3ac('0xc')]('ShowFreshdeskAccount',_0x47f852);logger[_0xa3ac('0xe')](_0xa3ac('0x1e'),_0x47f852,JSON[_0xa3ac('0x10')](_0x2dd735));_0x5a5847(_0x2dd735);})[_0xa3ac('0x14')](function(_0x4f66c6){logger[_0xa3ac('0x11')]('ShowFreshdeskAccount',_0x4f66c6[_0xa3ac('0x13')],_0x47f852);_0x5e7d9b(_0x195845[_0xa3ac('0x11')](0x1f4,_0x4f66c6['message']));});});};