62dd4a1fcba75fb3125c7c1e39e8486723ff4275
[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 _0x2b4b=['request','then','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','FreshdeskAccount','findAll','options','raw','where','attributes','limit','include','map','model','GetFreshdeskAccount','ShowFreshdeskAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','client','http'];(function(_0x142020,_0x1f7233){var _0x40da8f=function(_0x17f0a3){while(--_0x17f0a3){_0x142020['push'](_0x142020['shift']());}};_0x40da8f(++_0x1f7233);}(_0x2b4b,0x89));var _0xb2b4=function(_0x2d21aa,_0x13fad7){_0x2d21aa=_0x2d21aa-0x0;var _0x5b9e22=_0x2b4b[_0x2d21aa];return _0x5b9e22;};'use strict';var _=require(_0xb2b4('0x0'));var util=require(_0xb2b4('0x1'));var moment=require(_0xb2b4('0x2'));var BPromise=require(_0xb2b4('0x3'));var rs=require(_0xb2b4('0x4'));var fs=require('fs');var Redis=require(_0xb2b4('0x5'));var db=require(_0xb2b4('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xb2b4('0x7'))(_0xb2b4('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xb2b4('0x9')][_0xb2b4('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x166a4d,_0x1c5fe1,_0x23ae43){return new BPromise(function(_0x2c2504,_0x3826bc){return client[_0xb2b4('0xb')](_0x166a4d,_0x23ae43)[_0xb2b4('0xc')](function(_0x45c57c){logger[_0xb2b4('0xd')](_0xb2b4('0xe'),_0x1c5fe1,_0xb2b4('0xf'));logger[_0xb2b4('0x10')](_0xb2b4('0x11'),_0x1c5fe1,_0xb2b4('0xf'),JSON[_0xb2b4('0x12')](_0x45c57c));if(_0x45c57c[_0xb2b4('0x13')]){if(_0x45c57c[_0xb2b4('0x13')][_0xb2b4('0x14')]===0x1f4){logger[_0xb2b4('0x13')](_0xb2b4('0xe'),_0x1c5fe1,_0x45c57c[_0xb2b4('0x13')]['message']);return _0x3826bc(_0x45c57c[_0xb2b4('0x13')][_0xb2b4('0x15')]);}logger[_0xb2b4('0x13')](_0xb2b4('0xe'),_0x1c5fe1,_0x45c57c[_0xb2b4('0x13')][_0xb2b4('0x15')]);return _0x2c2504(_0x45c57c['error']['message']);}else{logger[_0xb2b4('0xd')](_0xb2b4('0xe'),_0x1c5fe1,_0xb2b4('0xf'));_0x2c2504(_0x45c57c[_0xb2b4('0x16')][_0xb2b4('0x15')]);}})[_0xb2b4('0x17')](function(_0x1618d2){logger[_0xb2b4('0x13')]('FreshdeskAccount,\x20%s,\x20%s',_0x1c5fe1,_0x1618d2);_0x3826bc(_0x1618d2);});});}exports['GetFreshdeskAccount']=function(_0x16b345){var _0x598eb4=this;return new Promise(function(_0x11d1fa,_0x211e9b){return db[_0xb2b4('0x18')][_0xb2b4('0x19')]({'raw':_0x16b345[_0xb2b4('0x1a')]?_0x16b345['options'][_0xb2b4('0x1b')]===undefined?!![]:![]:!![],'where':_0x16b345[_0xb2b4('0x1a')]?_0x16b345[_0xb2b4('0x1a')][_0xb2b4('0x1c')]||null:null,'attributes':_0x16b345[_0xb2b4('0x1a')]?_0x16b345[_0xb2b4('0x1a')][_0xb2b4('0x1d')]||null:null,'limit':_0x16b345['options']?_0x16b345[_0xb2b4('0x1a')][_0xb2b4('0x1e')]||null:null,'include':_0x16b345[_0xb2b4('0x1a')]?_0x16b345[_0xb2b4('0x1a')][_0xb2b4('0x1f')]?_[_0xb2b4('0x20')](_0x16b345[_0xb2b4('0x1a')][_0xb2b4('0x1f')],function(_0x1e2540){return{'model':db[_0x1e2540[_0xb2b4('0x21')]],'as':_0x1e2540['as'],'attributes':_0x1e2540['attributes'],'include':_0x1e2540[_0xb2b4('0x1f')]?_['map'](_0x1e2540[_0xb2b4('0x1f')],function(_0x24ce0f){return{'model':db[_0x24ce0f[_0xb2b4('0x21')]],'as':_0x24ce0f['as'],'attributes':_0x24ce0f[_0xb2b4('0x1d')],'include':_0x24ce0f['include']?_[_0xb2b4('0x20')](_0x24ce0f[_0xb2b4('0x1f')],function(_0x445265){return{'model':db[_0x445265[_0xb2b4('0x21')]],'as':_0x445265['as'],'attributes':_0x445265[_0xb2b4('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xb2b4('0xc')](function(_0x5656f2){logger['info']('GetFreshdeskAccount',_0x16b345);logger['debug'](_0xb2b4('0x22'),_0x16b345,JSON[_0xb2b4('0x12')](_0x5656f2));_0x11d1fa(_0x5656f2);})[_0xb2b4('0x17')](function(_0x558648){logger[_0xb2b4('0x13')](_0xb2b4('0x22'),_0x558648[_0xb2b4('0x15')],_0x16b345);_0x211e9b(_0x598eb4[_0xb2b4('0x13')](0x1f4,_0x558648[_0xb2b4('0x15')]));});});};exports[_0xb2b4('0x23')]=function(_0x5dcb27){var _0x193d9b=this;return new Promise(function(_0x37c31a,_0x3e6cfd){return db[_0xb2b4('0x18')][_0xb2b4('0x24')]({'raw':_0x5dcb27[_0xb2b4('0x1a')]?_0x5dcb27[_0xb2b4('0x1a')][_0xb2b4('0x1b')]===undefined?!![]:![]:!![],'where':_0x5dcb27[_0xb2b4('0x1a')]?_0x5dcb27[_0xb2b4('0x1a')][_0xb2b4('0x1c')]||null:null,'attributes':_0x5dcb27['options']?_0x5dcb27[_0xb2b4('0x1a')][_0xb2b4('0x1d')]||null:null,'include':_0x5dcb27[_0xb2b4('0x1a')]?_0x5dcb27['options'][_0xb2b4('0x1f')]?_[_0xb2b4('0x20')](_0x5dcb27[_0xb2b4('0x1a')][_0xb2b4('0x1f')],function(_0x10409b){return{'model':db[_0x10409b['model']],'as':_0x10409b['as'],'attributes':_0x10409b[_0xb2b4('0x1d')],'include':_0x10409b[_0xb2b4('0x1f')]?_['map'](_0x10409b[_0xb2b4('0x1f')],function(_0xf68d8f){return{'model':db[_0xf68d8f[_0xb2b4('0x21')]],'as':_0xf68d8f['as'],'attributes':_0xf68d8f[_0xb2b4('0x1d')],'include':_0xf68d8f[_0xb2b4('0x1f')]?_[_0xb2b4('0x20')](_0xf68d8f[_0xb2b4('0x1f')],function(_0x899cb4){return{'model':db[_0x899cb4['model']],'as':_0x899cb4['as'],'attributes':_0x899cb4['attributes']};}):[]};}):[]};}):[]:[]})[_0xb2b4('0xc')](function(_0xa17f0f){logger[_0xb2b4('0xd')](_0xb2b4('0x23'),_0x5dcb27);logger[_0xb2b4('0x10')](_0xb2b4('0x23'),_0x5dcb27,JSON[_0xb2b4('0x12')](_0xa17f0f));_0x37c31a(_0xa17f0f);})[_0xb2b4('0x17')](function(_0x20d3de){logger[_0xb2b4('0x13')](_0xb2b4('0x23'),_0x20d3de[_0xb2b4('0x15')],_0x5dcb27);_0x3e6cfd(_0x193d9b[_0xb2b4('0x13')](0x1f4,_0x20d3de[_0xb2b4('0x15')]));});});};