Built motion from commit b5996064.|2.6.21
[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 _0xcd1b=['info','result','catch','findAll','options','attributes','limit','map','include','model','GetFreshdeskAccount','ShowFreshdeskAccount','find','where','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','client','request','then','request\x20sent','debug','stringify','error','code','FreshdeskAccount,\x20%s,\x20%s','message'];(function(_0x3670c5,_0x5a5ee2){var _0x52ab45=function(_0x85d5e1){while(--_0x85d5e1){_0x3670c5['push'](_0x3670c5['shift']());}};_0x52ab45(++_0x5a5ee2);}(_0xcd1b,0x18e));var _0xbcd1=function(_0xf008da,_0x395d94){_0xf008da=_0xf008da-0x0;var _0x2e0b55=_0xcd1b[_0xf008da];return _0x2e0b55;};'use strict';var _=require(_0xbcd1('0x0'));var util=require(_0xbcd1('0x1'));var moment=require('moment');var BPromise=require(_0xbcd1('0x2'));var rs=require(_0xbcd1('0x3'));var fs=require('fs');var Redis=require(_0xbcd1('0x4'));var db=require(_0xbcd1('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xbcd1('0x6'))(_0xbcd1('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xbcd1('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x187ec1,_0x46d5f8,_0x26f7e5){return new BPromise(function(_0x19d0da,_0x76c75c){return client[_0xbcd1('0x9')](_0x187ec1,_0x26f7e5)[_0xbcd1('0xa')](function(_0x579920){logger['info']('FreshdeskAccount,\x20%s,\x20%s',_0x46d5f8,_0xbcd1('0xb'));logger[_0xbcd1('0xc')]('FreshdeskAccount,\x20%s,\x20%s,\x20%s',_0x46d5f8,_0xbcd1('0xb'),JSON[_0xbcd1('0xd')](_0x579920));if(_0x579920[_0xbcd1('0xe')]){if(_0x579920[_0xbcd1('0xe')][_0xbcd1('0xf')]===0x1f4){logger['error'](_0xbcd1('0x10'),_0x46d5f8,_0x579920[_0xbcd1('0xe')][_0xbcd1('0x11')]);return _0x76c75c(_0x579920[_0xbcd1('0xe')]['message']);}logger[_0xbcd1('0xe')]('FreshdeskAccount,\x20%s,\x20%s',_0x46d5f8,_0x579920[_0xbcd1('0xe')][_0xbcd1('0x11')]);return _0x19d0da(_0x579920[_0xbcd1('0xe')]['message']);}else{logger[_0xbcd1('0x12')](_0xbcd1('0x10'),_0x46d5f8,'request\x20sent');_0x19d0da(_0x579920[_0xbcd1('0x13')][_0xbcd1('0x11')]);}})[_0xbcd1('0x14')](function(_0x5411c2){logger['error']('FreshdeskAccount,\x20%s,\x20%s',_0x46d5f8,_0x5411c2);_0x76c75c(_0x5411c2);});});}exports['GetFreshdeskAccount']=function(_0x546e15){var _0x17931e=this;return new Promise(function(_0x407299,_0x34ba97){return db['FreshdeskAccount'][_0xbcd1('0x15')]({'raw':_0x546e15[_0xbcd1('0x16')]?_0x546e15[_0xbcd1('0x16')]['raw']===undefined?!![]:![]:!![],'where':_0x546e15[_0xbcd1('0x16')]?_0x546e15[_0xbcd1('0x16')]['where']||null:null,'attributes':_0x546e15[_0xbcd1('0x16')]?_0x546e15[_0xbcd1('0x16')][_0xbcd1('0x17')]||null:null,'limit':_0x546e15[_0xbcd1('0x16')]?_0x546e15[_0xbcd1('0x16')][_0xbcd1('0x18')]||null:null,'include':_0x546e15[_0xbcd1('0x16')]?_0x546e15[_0xbcd1('0x16')]['include']?_[_0xbcd1('0x19')](_0x546e15[_0xbcd1('0x16')][_0xbcd1('0x1a')],function(_0x2b05f6){return{'model':db[_0x2b05f6[_0xbcd1('0x1b')]],'as':_0x2b05f6['as'],'attributes':_0x2b05f6['attributes'],'include':_0x2b05f6[_0xbcd1('0x1a')]?_[_0xbcd1('0x19')](_0x2b05f6[_0xbcd1('0x1a')],function(_0x427f9d){return{'model':db[_0x427f9d[_0xbcd1('0x1b')]],'as':_0x427f9d['as'],'attributes':_0x427f9d[_0xbcd1('0x17')],'include':_0x427f9d['include']?_[_0xbcd1('0x19')](_0x427f9d[_0xbcd1('0x1a')],function(_0x4d743d){return{'model':db[_0x4d743d[_0xbcd1('0x1b')]],'as':_0x4d743d['as'],'attributes':_0x4d743d[_0xbcd1('0x17')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5e80cb){logger[_0xbcd1('0x12')](_0xbcd1('0x1c'),_0x546e15);logger[_0xbcd1('0xc')](_0xbcd1('0x1c'),_0x546e15,JSON[_0xbcd1('0xd')](_0x5e80cb));_0x407299(_0x5e80cb);})[_0xbcd1('0x14')](function(_0x459868){logger[_0xbcd1('0xe')](_0xbcd1('0x1c'),_0x459868['message'],_0x546e15);_0x34ba97(_0x17931e[_0xbcd1('0xe')](0x1f4,_0x459868[_0xbcd1('0x11')]));});});};exports[_0xbcd1('0x1d')]=function(_0x8c93d){var _0x21dedd=this;return new Promise(function(_0x3c8872,_0x26e295){return db['FreshdeskAccount'][_0xbcd1('0x1e')]({'raw':_0x8c93d['options']?_0x8c93d[_0xbcd1('0x16')]['raw']===undefined?!![]:![]:!![],'where':_0x8c93d[_0xbcd1('0x16')]?_0x8c93d['options'][_0xbcd1('0x1f')]||null:null,'attributes':_0x8c93d[_0xbcd1('0x16')]?_0x8c93d[_0xbcd1('0x16')]['attributes']||null:null,'include':_0x8c93d[_0xbcd1('0x16')]?_0x8c93d[_0xbcd1('0x16')][_0xbcd1('0x1a')]?_[_0xbcd1('0x19')](_0x8c93d[_0xbcd1('0x16')][_0xbcd1('0x1a')],function(_0x664296){return{'model':db[_0x664296[_0xbcd1('0x1b')]],'as':_0x664296['as'],'attributes':_0x664296['attributes'],'include':_0x664296['include']?_['map'](_0x664296['include'],function(_0x2dd0d1){return{'model':db[_0x2dd0d1['model']],'as':_0x2dd0d1['as'],'attributes':_0x2dd0d1[_0xbcd1('0x17')],'include':_0x2dd0d1[_0xbcd1('0x1a')]?_[_0xbcd1('0x19')](_0x2dd0d1[_0xbcd1('0x1a')],function(_0x459d43){return{'model':db[_0x459d43['model']],'as':_0x459d43['as'],'attributes':_0x459d43[_0xbcd1('0x17')]};}):[]};}):[]};}):[]:[]})[_0xbcd1('0xa')](function(_0x30f875){logger[_0xbcd1('0x12')]('ShowFreshdeskAccount',_0x8c93d);logger['debug'](_0xbcd1('0x1d'),_0x8c93d,JSON[_0xbcd1('0xd')](_0x30f875));_0x3c8872(_0x30f875);})['catch'](function(_0x41762f){logger[_0xbcd1('0xe')](_0xbcd1('0x1d'),_0x41762f['message'],_0x8c93d);_0x26e295(_0x21dedd[_0xbcd1('0xe')](0x1f4,_0x41762f[_0xbcd1('0x11')]));});});};