Built motion from commit (unavailable).|2.5.4
[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 _0x2641=['../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','info','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','FreshdeskAccount,\x20%s,\x20%s','message','result','catch','GetFreshdeskAccount','FreshdeskAccount','findAll','options','where','limit','include','map','attributes','model','raw','ShowFreshdeskAccount','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb'];(function(_0x201b7b,_0x166c79){var _0x5c2011=function(_0x35437e){while(--_0x35437e){_0x201b7b['push'](_0x201b7b['shift']());}};_0x5c2011(++_0x166c79);}(_0x2641,0xd7));var _0x1264=function(_0xaf60d2,_0x56cd4b){_0xaf60d2=_0xaf60d2-0x0;var _0x1d6cc5=_0x2641[_0xaf60d2];return _0x1d6cc5;};'use strict';var _=require(_0x1264('0x0'));var util=require(_0x1264('0x1'));var moment=require(_0x1264('0x2'));var BPromise=require(_0x1264('0x3'));var rs=require(_0x1264('0x4'));var fs=require('fs');var Redis=require(_0x1264('0x5'));var db=require(_0x1264('0x6'))['db'];var utils=require(_0x1264('0x7'));var logger=require(_0x1264('0x8'))(_0x1264('0x9'));var config=require(_0x1264('0xa'));var jayson=require(_0x1264('0xb'));var client=jayson[_0x1264('0xc')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5e26c8,_0x539eb8,_0x558845){return new BPromise(function(_0x585b1a,_0x139b7a){return client[_0x1264('0xd')](_0x5e26c8,_0x558845)[_0x1264('0xe')](function(_0x5a0e6d){logger[_0x1264('0xf')]('FreshdeskAccount,\x20%s,\x20%s',_0x539eb8,_0x1264('0x10'));logger[_0x1264('0x11')](_0x1264('0x12'),_0x539eb8,'request\x20sent',JSON[_0x1264('0x13')](_0x5a0e6d));if(_0x5a0e6d[_0x1264('0x14')]){if(_0x5a0e6d['error']['code']===0x1f4){logger[_0x1264('0x14')](_0x1264('0x15'),_0x539eb8,_0x5a0e6d[_0x1264('0x14')][_0x1264('0x16')]);return _0x139b7a(_0x5a0e6d['error'][_0x1264('0x16')]);}logger[_0x1264('0x14')](_0x1264('0x15'),_0x539eb8,_0x5a0e6d['error'][_0x1264('0x16')]);return _0x585b1a(_0x5a0e6d['error']['message']);}else{logger['info']('FreshdeskAccount,\x20%s,\x20%s',_0x539eb8,'request\x20sent');_0x585b1a(_0x5a0e6d[_0x1264('0x17')][_0x1264('0x16')]);}})[_0x1264('0x18')](function(_0x34544e){logger[_0x1264('0x14')](_0x1264('0x15'),_0x539eb8,_0x34544e);_0x139b7a(_0x34544e);});});}exports[_0x1264('0x19')]=function(_0x43bfc0){var _0x2cca3e=this;return new Promise(function(_0x365820,_0x3a7121){return db[_0x1264('0x1a')][_0x1264('0x1b')]({'raw':_0x43bfc0['options']?_0x43bfc0[_0x1264('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x43bfc0[_0x1264('0x1c')]?_0x43bfc0[_0x1264('0x1c')][_0x1264('0x1d')]||null:null,'attributes':_0x43bfc0[_0x1264('0x1c')]?_0x43bfc0['options']['attributes']||null:null,'limit':_0x43bfc0['options']?_0x43bfc0['options'][_0x1264('0x1e')]||null:null,'include':_0x43bfc0[_0x1264('0x1c')]?_0x43bfc0[_0x1264('0x1c')][_0x1264('0x1f')]?_[_0x1264('0x20')](_0x43bfc0[_0x1264('0x1c')][_0x1264('0x1f')],function(_0x366944){return{'model':db[_0x366944['model']],'as':_0x366944['as'],'attributes':_0x366944[_0x1264('0x21')],'include':_0x366944[_0x1264('0x1f')]?_[_0x1264('0x20')](_0x366944[_0x1264('0x1f')],function(_0x58c839){return{'model':db[_0x58c839[_0x1264('0x22')]],'as':_0x58c839['as'],'attributes':_0x58c839['attributes'],'include':_0x58c839[_0x1264('0x1f')]?_[_0x1264('0x20')](_0x58c839['include'],function(_0x2c8333){return{'model':db[_0x2c8333['model']],'as':_0x2c8333['as'],'attributes':_0x2c8333['attributes']};}):[]};}):[]};}):[]:[]})[_0x1264('0xe')](function(_0xa2b826){logger['info'](_0x1264('0x19'),_0x43bfc0);logger[_0x1264('0x11')]('GetFreshdeskAccount',_0x43bfc0,JSON[_0x1264('0x13')](_0xa2b826));_0x365820(_0xa2b826);})[_0x1264('0x18')](function(_0x1b690e){logger['error'](_0x1264('0x19'),_0x1b690e[_0x1264('0x16')],_0x43bfc0);_0x3a7121(_0x2cca3e[_0x1264('0x14')](0x1f4,_0x1b690e[_0x1264('0x16')]));});});};exports['ShowFreshdeskAccount']=function(_0x36725d){var _0x570cfd=this;return new Promise(function(_0x3ef1c3,_0x3afdf4){return db['FreshdeskAccount']['find']({'raw':_0x36725d[_0x1264('0x1c')]?_0x36725d['options'][_0x1264('0x23')]===undefined?!![]:![]:!![],'where':_0x36725d['options']?_0x36725d['options'][_0x1264('0x1d')]||null:null,'attributes':_0x36725d['options']?_0x36725d[_0x1264('0x1c')][_0x1264('0x21')]||null:null,'include':_0x36725d[_0x1264('0x1c')]?_0x36725d[_0x1264('0x1c')][_0x1264('0x1f')]?_[_0x1264('0x20')](_0x36725d[_0x1264('0x1c')][_0x1264('0x1f')],function(_0x529ee0){return{'model':db[_0x529ee0[_0x1264('0x22')]],'as':_0x529ee0['as'],'attributes':_0x529ee0[_0x1264('0x21')],'include':_0x529ee0[_0x1264('0x1f')]?_[_0x1264('0x20')](_0x529ee0['include'],function(_0x34057d){return{'model':db[_0x34057d['model']],'as':_0x34057d['as'],'attributes':_0x34057d['attributes'],'include':_0x34057d[_0x1264('0x1f')]?_[_0x1264('0x20')](_0x34057d[_0x1264('0x1f')],function(_0x49658e){return{'model':db[_0x49658e[_0x1264('0x22')]],'as':_0x49658e['as'],'attributes':_0x49658e[_0x1264('0x21')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2167d6){logger['info'](_0x1264('0x24'),_0x36725d);logger[_0x1264('0x11')](_0x1264('0x24'),_0x36725d,JSON[_0x1264('0x13')](_0x2167d6));_0x3ef1c3(_0x2167d6);})['catch'](function(_0x1cd8e4){logger[_0x1264('0x14')]('ShowFreshdeskAccount',_0x1cd8e4['message'],_0x36725d);_0x3afdf4(_0x570cfd['error'](0x1f4,_0x1cd8e4[_0x1264('0x16')]));});});};