b2de83f1d74a37c08005e67026b17e85bee2481f
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.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 _0xef2a=['map','model','then','GetZendeskAccount','stringify','ZendeskAccount','find','ShowZendeskAccount','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','info','ZendeskAccount,\x20%s,\x20%s','request\x20sent','debug','ZendeskAccount,\x20%s,\x20%s,\x20%s','error','message','catch','findAll','options','raw','where','attributes','limit','include'];(function(_0x2be67f,_0x238c6d){var _0x1d94b4=function(_0x42562b){while(--_0x42562b){_0x2be67f['push'](_0x2be67f['shift']());}};_0x1d94b4(++_0x238c6d);}(_0xef2a,0x1a0));var _0xaef2=function(_0x53fbb7,_0xa2b591){_0x53fbb7=_0x53fbb7-0x0;var _0x15123a=_0xef2a[_0x53fbb7];return _0x15123a;};'use strict';var _=require(_0xaef2('0x0'));var util=require(_0xaef2('0x1'));var moment=require(_0xaef2('0x2'));var BPromise=require(_0xaef2('0x3'));var rs=require(_0xaef2('0x4'));var fs=require('fs');var Redis=require(_0xaef2('0x5'));var db=require(_0xaef2('0x6'))['db'];var utils=require(_0xaef2('0x7'));var logger=require('../../config/logger')(_0xaef2('0x8'));var config=require(_0xaef2('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xaef2('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x309da5,_0x50be70,_0x1909c1){return new BPromise(function(_0x5cdb8a,_0x5cc05d){return client['request'](_0x309da5,_0x1909c1)['then'](function(_0x6ea364){logger[_0xaef2('0xb')](_0xaef2('0xc'),_0x50be70,_0xaef2('0xd'));logger[_0xaef2('0xe')](_0xaef2('0xf'),_0x50be70,_0xaef2('0xd'),JSON['stringify'](_0x6ea364));if(_0x6ea364['error']){if(_0x6ea364[_0xaef2('0x10')]['code']===0x1f4){logger[_0xaef2('0x10')](_0xaef2('0xc'),_0x50be70,_0x6ea364['error'][_0xaef2('0x11')]);return _0x5cc05d(_0x6ea364[_0xaef2('0x10')][_0xaef2('0x11')]);}logger[_0xaef2('0x10')](_0xaef2('0xc'),_0x50be70,_0x6ea364[_0xaef2('0x10')][_0xaef2('0x11')]);return _0x5cdb8a(_0x6ea364['error'][_0xaef2('0x11')]);}else{logger[_0xaef2('0xb')]('ZendeskAccount,\x20%s,\x20%s',_0x50be70,_0xaef2('0xd'));_0x5cdb8a(_0x6ea364['result']['message']);}})[_0xaef2('0x12')](function(_0x2f276e){logger[_0xaef2('0x10')](_0xaef2('0xc'),_0x50be70,_0x2f276e);_0x5cc05d(_0x2f276e);});});}exports['GetZendeskAccount']=function(_0x57d47b){var _0x22e732=this;return new Promise(function(_0x3411fe,_0x3067ed){return db['ZendeskAccount'][_0xaef2('0x13')]({'raw':_0x57d47b['options']?_0x57d47b[_0xaef2('0x14')][_0xaef2('0x15')]===undefined?!![]:![]:!![],'where':_0x57d47b[_0xaef2('0x14')]?_0x57d47b[_0xaef2('0x14')][_0xaef2('0x16')]||null:null,'attributes':_0x57d47b[_0xaef2('0x14')]?_0x57d47b[_0xaef2('0x14')][_0xaef2('0x17')]||null:null,'limit':_0x57d47b[_0xaef2('0x14')]?_0x57d47b[_0xaef2('0x14')][_0xaef2('0x18')]||null:null,'include':_0x57d47b[_0xaef2('0x14')]?_0x57d47b[_0xaef2('0x14')][_0xaef2('0x19')]?_[_0xaef2('0x1a')](_0x57d47b[_0xaef2('0x14')]['include'],function(_0x33f5cc){return{'model':db[_0x33f5cc[_0xaef2('0x1b')]],'as':_0x33f5cc['as'],'attributes':_0x33f5cc[_0xaef2('0x17')],'include':_0x33f5cc[_0xaef2('0x19')]?_[_0xaef2('0x1a')](_0x33f5cc['include'],function(_0x1fc9b9){return{'model':db[_0x1fc9b9[_0xaef2('0x1b')]],'as':_0x1fc9b9['as'],'attributes':_0x1fc9b9['attributes'],'include':_0x1fc9b9[_0xaef2('0x19')]?_[_0xaef2('0x1a')](_0x1fc9b9[_0xaef2('0x19')],function(_0x16115f){return{'model':db[_0x16115f[_0xaef2('0x1b')]],'as':_0x16115f['as'],'attributes':_0x16115f[_0xaef2('0x17')]};}):[]};}):[]};}):[]:[]})[_0xaef2('0x1c')](function(_0x236fa6){logger[_0xaef2('0xb')]('GetZendeskAccount',_0x57d47b);logger[_0xaef2('0xe')](_0xaef2('0x1d'),_0x57d47b,JSON[_0xaef2('0x1e')](_0x236fa6));_0x3411fe(_0x236fa6);})['catch'](function(_0x10d3ad){logger['error'](_0xaef2('0x1d'),_0x10d3ad[_0xaef2('0x11')],_0x57d47b);_0x3067ed(_0x22e732[_0xaef2('0x10')](0x1f4,_0x10d3ad[_0xaef2('0x11')]));});});};exports['ShowZendeskAccount']=function(_0x15b18f){var _0x99a598=this;return new Promise(function(_0x561654,_0x49f6d1){return db[_0xaef2('0x1f')][_0xaef2('0x20')]({'raw':_0x15b18f[_0xaef2('0x14')]?_0x15b18f[_0xaef2('0x14')][_0xaef2('0x15')]===undefined?!![]:![]:!![],'where':_0x15b18f[_0xaef2('0x14')]?_0x15b18f[_0xaef2('0x14')][_0xaef2('0x16')]||null:null,'attributes':_0x15b18f['options']?_0x15b18f[_0xaef2('0x14')]['attributes']||null:null,'include':_0x15b18f['options']?_0x15b18f[_0xaef2('0x14')][_0xaef2('0x19')]?_[_0xaef2('0x1a')](_0x15b18f[_0xaef2('0x14')]['include'],function(_0x4adb3e){return{'model':db[_0x4adb3e[_0xaef2('0x1b')]],'as':_0x4adb3e['as'],'attributes':_0x4adb3e[_0xaef2('0x17')],'include':_0x4adb3e['include']?_[_0xaef2('0x1a')](_0x4adb3e[_0xaef2('0x19')],function(_0x50bc5b){return{'model':db[_0x50bc5b[_0xaef2('0x1b')]],'as':_0x50bc5b['as'],'attributes':_0x50bc5b[_0xaef2('0x17')],'include':_0x50bc5b[_0xaef2('0x19')]?_[_0xaef2('0x1a')](_0x50bc5b[_0xaef2('0x19')],function(_0x4065d0){return{'model':db[_0x4065d0[_0xaef2('0x1b')]],'as':_0x4065d0['as'],'attributes':_0x4065d0['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x178f28){logger['info'](_0xaef2('0x21'),_0x15b18f);logger['debug'](_0xaef2('0x21'),_0x15b18f,JSON[_0xaef2('0x1e')](_0x178f28));_0x561654(_0x178f28);})[_0xaef2('0x12')](function(_0xd04352){logger[_0xaef2('0x10')](_0xaef2('0x21'),_0xd04352[_0xaef2('0x11')],_0x15b18f);_0x49f6d1(_0x99a598[_0xaef2('0x10')](0x1f4,_0xd04352[_0xaef2('0x11')]));});});};