Built motion from commit 1efd3d96.|2.6.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 _0xe7f2=['FreshdeskAccount,\x20%s,\x20%s','message','result','GetFreshdeskAccount','FreshdeskAccount','findAll','options','raw','where','attributes','include','map','model','then','debug','catch','ShowFreshdeskAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','info','FreshdeskAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code'];(function(_0x3f9d90,_0x3dc68f){var _0x3c73c8=function(_0x477960){while(--_0x477960){_0x3f9d90['push'](_0x3f9d90['shift']());}};_0x3c73c8(++_0x3dc68f);}(_0xe7f2,0x10e));var _0x2e7f=function(_0x29090c,_0x1dce06){_0x29090c=_0x29090c-0x0;var _0x269e06=_0xe7f2[_0x29090c];return _0x269e06;};'use strict';var _=require(_0x2e7f('0x0'));var util=require(_0x2e7f('0x1'));var moment=require(_0x2e7f('0x2'));var BPromise=require(_0x2e7f('0x3'));var rs=require(_0x2e7f('0x4'));var fs=require('fs');var Redis=require(_0x2e7f('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x2e7f('0x6'));var logger=require(_0x2e7f('0x7'))('rpc');var config=require(_0x2e7f('0x8'));var jayson=require(_0x2e7f('0x9'));var client=jayson[_0x2e7f('0xa')][_0x2e7f('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x5ab511,_0x28c64c,_0x4dc2b0){return new BPromise(function(_0x11c9a7,_0x477ffe){return client['request'](_0x5ab511,_0x4dc2b0)['then'](function(_0x371fb6){logger[_0x2e7f('0xc')]('FreshdeskAccount,\x20%s,\x20%s',_0x28c64c,'request\x20sent');logger['debug'](_0x2e7f('0xd'),_0x28c64c,_0x2e7f('0xe'),JSON[_0x2e7f('0xf')](_0x371fb6));if(_0x371fb6[_0x2e7f('0x10')]){if(_0x371fb6[_0x2e7f('0x10')][_0x2e7f('0x11')]===0x1f4){logger[_0x2e7f('0x10')](_0x2e7f('0x12'),_0x28c64c,_0x371fb6[_0x2e7f('0x10')]['message']);return _0x477ffe(_0x371fb6[_0x2e7f('0x10')]['message']);}logger[_0x2e7f('0x10')](_0x2e7f('0x12'),_0x28c64c,_0x371fb6['error']['message']);return _0x11c9a7(_0x371fb6[_0x2e7f('0x10')][_0x2e7f('0x13')]);}else{logger[_0x2e7f('0xc')]('FreshdeskAccount,\x20%s,\x20%s',_0x28c64c,_0x2e7f('0xe'));_0x11c9a7(_0x371fb6[_0x2e7f('0x14')][_0x2e7f('0x13')]);}})['catch'](function(_0x5cea5c){logger[_0x2e7f('0x10')](_0x2e7f('0x12'),_0x28c64c,_0x5cea5c);_0x477ffe(_0x5cea5c);});});}exports[_0x2e7f('0x15')]=function(_0x4cc1ea){var _0x4183fb=this;return new Promise(function(_0x480467,_0x16c466){return db[_0x2e7f('0x16')][_0x2e7f('0x17')]({'raw':_0x4cc1ea['options']?_0x4cc1ea[_0x2e7f('0x18')][_0x2e7f('0x19')]===undefined?!![]:![]:!![],'where':_0x4cc1ea['options']?_0x4cc1ea[_0x2e7f('0x18')][_0x2e7f('0x1a')]||null:null,'attributes':_0x4cc1ea[_0x2e7f('0x18')]?_0x4cc1ea['options'][_0x2e7f('0x1b')]||null:null,'limit':_0x4cc1ea['options']?_0x4cc1ea['options']['limit']||null:null,'include':_0x4cc1ea[_0x2e7f('0x18')]?_0x4cc1ea[_0x2e7f('0x18')][_0x2e7f('0x1c')]?_[_0x2e7f('0x1d')](_0x4cc1ea['options'][_0x2e7f('0x1c')],function(_0x4aec93){return{'model':db[_0x4aec93[_0x2e7f('0x1e')]],'as':_0x4aec93['as'],'attributes':_0x4aec93['attributes'],'include':_0x4aec93[_0x2e7f('0x1c')]?_[_0x2e7f('0x1d')](_0x4aec93['include'],function(_0x4e6eeb){return{'model':db[_0x4e6eeb['model']],'as':_0x4e6eeb['as'],'attributes':_0x4e6eeb['attributes'],'include':_0x4e6eeb['include']?_[_0x2e7f('0x1d')](_0x4e6eeb[_0x2e7f('0x1c')],function(_0x495bc5){return{'model':db[_0x495bc5[_0x2e7f('0x1e')]],'as':_0x495bc5['as'],'attributes':_0x495bc5['attributes']};}):[]};}):[]};}):[]:[]})[_0x2e7f('0x1f')](function(_0x4672b1){logger[_0x2e7f('0xc')](_0x2e7f('0x15'),_0x4cc1ea);logger[_0x2e7f('0x20')](_0x2e7f('0x15'),_0x4cc1ea,JSON['stringify'](_0x4672b1));_0x480467(_0x4672b1);})[_0x2e7f('0x21')](function(_0x123acd){logger['error'](_0x2e7f('0x15'),_0x123acd['message'],_0x4cc1ea);_0x16c466(_0x4183fb[_0x2e7f('0x10')](0x1f4,_0x123acd[_0x2e7f('0x13')]));});});};exports[_0x2e7f('0x22')]=function(_0x1eb37a){var _0x397053=this;return new Promise(function(_0xa9e635,_0xd37e0c){return db['FreshdeskAccount'][_0x2e7f('0x23')]({'raw':_0x1eb37a['options']?_0x1eb37a[_0x2e7f('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x1eb37a[_0x2e7f('0x18')]?_0x1eb37a[_0x2e7f('0x18')]['where']||null:null,'attributes':_0x1eb37a[_0x2e7f('0x18')]?_0x1eb37a[_0x2e7f('0x18')][_0x2e7f('0x1b')]||null:null,'include':_0x1eb37a[_0x2e7f('0x18')]?_0x1eb37a[_0x2e7f('0x18')][_0x2e7f('0x1c')]?_[_0x2e7f('0x1d')](_0x1eb37a[_0x2e7f('0x18')][_0x2e7f('0x1c')],function(_0xa8bf10){return{'model':db[_0xa8bf10[_0x2e7f('0x1e')]],'as':_0xa8bf10['as'],'attributes':_0xa8bf10[_0x2e7f('0x1b')],'include':_0xa8bf10[_0x2e7f('0x1c')]?_[_0x2e7f('0x1d')](_0xa8bf10[_0x2e7f('0x1c')],function(_0x30cd18){return{'model':db[_0x30cd18[_0x2e7f('0x1e')]],'as':_0x30cd18['as'],'attributes':_0x30cd18['attributes'],'include':_0x30cd18[_0x2e7f('0x1c')]?_['map'](_0x30cd18['include'],function(_0x286302){return{'model':db[_0x286302[_0x2e7f('0x1e')]],'as':_0x286302['as'],'attributes':_0x286302[_0x2e7f('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x44cc8c){logger[_0x2e7f('0xc')](_0x2e7f('0x22'),_0x1eb37a);logger[_0x2e7f('0x20')](_0x2e7f('0x22'),_0x1eb37a,JSON['stringify'](_0x44cc8c));_0xa9e635(_0x44cc8c);})['catch'](function(_0x56a7c9){logger[_0x2e7f('0x10')](_0x2e7f('0x22'),_0x56a7c9[_0x2e7f('0x13')],_0x1eb37a);_0xd37e0c(_0x397053['error'](0x1f4,_0x56a7c9[_0x2e7f('0x13')]));});});};