Built motion from commit (unavailable).|2.5.31
[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 _0xcd98=['../../config/utils','jayson/promise','client','http','request','then','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetFreshdeskAccount','FreshdeskAccount','options','raw','where','attributes','limit','map','include','model','ShowFreshdeskAccount','find','stringify','lodash','moment','bluebird','../../mysqldb'];(function(_0x3ac769,_0x2825df){var _0x2185eb=function(_0x43cc1d){while(--_0x43cc1d){_0x3ac769['push'](_0x3ac769['shift']());}};_0x2185eb(++_0x2825df);}(_0xcd98,0xc2));var _0x8cd9=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xcd98[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x8cd9('0x0'));var util=require('util');var moment=require(_0x8cd9('0x1'));var BPromise=require(_0x8cd9('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x8cd9('0x3'))['db'];var utils=require(_0x8cd9('0x4'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x8cd9('0x5'));var client=jayson[_0x8cd9('0x6')][_0x8cd9('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x5218f5,_0x3098e7,_0x2f94b1){return new BPromise(function(_0x547052,_0x583f48){return client[_0x8cd9('0x8')](_0x5218f5,_0x2f94b1)[_0x8cd9('0x9')](function(_0x2f2691){logger[_0x8cd9('0xa')](_0x8cd9('0xb'),_0x3098e7,_0x8cd9('0xc'));logger[_0x8cd9('0xd')](_0x8cd9('0xe'),_0x3098e7,_0x8cd9('0xc'),JSON['stringify'](_0x2f2691));if(_0x2f2691[_0x8cd9('0xf')]){if(_0x2f2691[_0x8cd9('0xf')][_0x8cd9('0x10')]===0x1f4){logger[_0x8cd9('0xf')]('FreshdeskAccount,\x20%s,\x20%s',_0x3098e7,_0x2f2691[_0x8cd9('0xf')][_0x8cd9('0x11')]);return _0x583f48(_0x2f2691[_0x8cd9('0xf')][_0x8cd9('0x11')]);}logger[_0x8cd9('0xf')](_0x8cd9('0xb'),_0x3098e7,_0x2f2691[_0x8cd9('0xf')]['message']);return _0x547052(_0x2f2691['error'][_0x8cd9('0x11')]);}else{logger['info'](_0x8cd9('0xb'),_0x3098e7,'request\x20sent');_0x547052(_0x2f2691[_0x8cd9('0x12')][_0x8cd9('0x11')]);}})[_0x8cd9('0x13')](function(_0x71ea3){logger[_0x8cd9('0xf')](_0x8cd9('0xb'),_0x3098e7,_0x71ea3);_0x583f48(_0x71ea3);});});}exports[_0x8cd9('0x14')]=function(_0x2862f6){var _0x455816=this;return new Promise(function(_0x3606b5,_0x4fe47c){return db[_0x8cd9('0x15')]['findAll']({'raw':_0x2862f6['options']?_0x2862f6[_0x8cd9('0x16')][_0x8cd9('0x17')]===undefined?!![]:![]:!![],'where':_0x2862f6[_0x8cd9('0x16')]?_0x2862f6[_0x8cd9('0x16')][_0x8cd9('0x18')]||null:null,'attributes':_0x2862f6[_0x8cd9('0x16')]?_0x2862f6['options'][_0x8cd9('0x19')]||null:null,'limit':_0x2862f6[_0x8cd9('0x16')]?_0x2862f6['options'][_0x8cd9('0x1a')]||null:null,'include':_0x2862f6[_0x8cd9('0x16')]?_0x2862f6[_0x8cd9('0x16')]['include']?_[_0x8cd9('0x1b')](_0x2862f6[_0x8cd9('0x16')][_0x8cd9('0x1c')],function(_0x39f080){return{'model':db[_0x39f080[_0x8cd9('0x1d')]],'as':_0x39f080['as'],'attributes':_0x39f080[_0x8cd9('0x19')],'include':_0x39f080[_0x8cd9('0x1c')]?_[_0x8cd9('0x1b')](_0x39f080[_0x8cd9('0x1c')],function(_0x586ef5){return{'model':db[_0x586ef5[_0x8cd9('0x1d')]],'as':_0x586ef5['as'],'attributes':_0x586ef5[_0x8cd9('0x19')],'include':_0x586ef5['include']?_[_0x8cd9('0x1b')](_0x586ef5[_0x8cd9('0x1c')],function(_0x5be820){return{'model':db[_0x5be820[_0x8cd9('0x1d')]],'as':_0x5be820['as'],'attributes':_0x5be820[_0x8cd9('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x10639e){logger[_0x8cd9('0xa')](_0x8cd9('0x14'),_0x2862f6);logger['debug']('GetFreshdeskAccount',_0x2862f6,JSON['stringify'](_0x10639e));_0x3606b5(_0x10639e);})[_0x8cd9('0x13')](function(_0x3cd813){logger[_0x8cd9('0xf')](_0x8cd9('0x14'),_0x3cd813[_0x8cd9('0x11')],_0x2862f6);_0x4fe47c(_0x455816[_0x8cd9('0xf')](0x1f4,_0x3cd813[_0x8cd9('0x11')]));});});};exports[_0x8cd9('0x1e')]=function(_0xb598d4){var _0xb8fbb0=this;return new Promise(function(_0x183af8,_0x4a08fa){return db[_0x8cd9('0x15')][_0x8cd9('0x1f')]({'raw':_0xb598d4[_0x8cd9('0x16')]?_0xb598d4[_0x8cd9('0x16')][_0x8cd9('0x17')]===undefined?!![]:![]:!![],'where':_0xb598d4['options']?_0xb598d4[_0x8cd9('0x16')][_0x8cd9('0x18')]||null:null,'attributes':_0xb598d4[_0x8cd9('0x16')]?_0xb598d4['options'][_0x8cd9('0x19')]||null:null,'include':_0xb598d4[_0x8cd9('0x16')]?_0xb598d4[_0x8cd9('0x16')][_0x8cd9('0x1c')]?_[_0x8cd9('0x1b')](_0xb598d4[_0x8cd9('0x16')][_0x8cd9('0x1c')],function(_0x57d756){return{'model':db[_0x57d756[_0x8cd9('0x1d')]],'as':_0x57d756['as'],'attributes':_0x57d756[_0x8cd9('0x19')],'include':_0x57d756[_0x8cd9('0x1c')]?_[_0x8cd9('0x1b')](_0x57d756[_0x8cd9('0x1c')],function(_0x2e5ad5){return{'model':db[_0x2e5ad5[_0x8cd9('0x1d')]],'as':_0x2e5ad5['as'],'attributes':_0x2e5ad5[_0x8cd9('0x19')],'include':_0x2e5ad5['include']?_[_0x8cd9('0x1b')](_0x2e5ad5['include'],function(_0x1f9f57){return{'model':db[_0x1f9f57[_0x8cd9('0x1d')]],'as':_0x1f9f57['as'],'attributes':_0x1f9f57[_0x8cd9('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x24f078){logger['info'](_0x8cd9('0x1e'),_0xb598d4);logger[_0x8cd9('0xd')]('ShowFreshdeskAccount',_0xb598d4,JSON[_0x8cd9('0x20')](_0x24f078));_0x183af8(_0x24f078);})[_0x8cd9('0x13')](function(_0x12a1ba){logger[_0x8cd9('0xf')](_0x8cd9('0x1e'),_0x12a1ba[_0x8cd9('0x11')],_0xb598d4);_0x4a08fa(_0xb8fbb0[_0x8cd9('0xf')](0x1f4,_0x12a1ba[_0x8cd9('0x11')]));});});};