Built motion from commit 5293bb2a.|2.6.30
[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 _0x8343=['find','ShowZendeskAccount','debug','stringify','lodash','util','moment','randomstring','../../mysqldb','../../config/environment','jayson/promise','client','then','info','ZendeskAccount,\x20%s,\x20%s','request\x20sent','ZendeskAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetZendeskAccount','ZendeskAccount','findAll','options','raw','where','attributes','limit','map','model','include'];(function(_0xbf2cb4,_0x184020){var _0x4f68a1=function(_0x1cf0a2){while(--_0x1cf0a2){_0xbf2cb4['push'](_0xbf2cb4['shift']());}};_0x4f68a1(++_0x184020);}(_0x8343,0xa9));var _0x3834=function(_0x168ec1,_0x4992ff){_0x168ec1=_0x168ec1-0x0;var _0x14d4fe=_0x8343[_0x168ec1];return _0x14d4fe;};'use strict';var _=require(_0x3834('0x0'));var util=require(_0x3834('0x1'));var moment=require(_0x3834('0x2'));var BPromise=require('bluebird');var rs=require(_0x3834('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x3834('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x3834('0x5'));var jayson=require(_0x3834('0x6'));var client=jayson[_0x3834('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x236509,_0x1c0b23,_0x469e80){return new BPromise(function(_0x994230,_0x520a4f){return client['request'](_0x236509,_0x469e80)[_0x3834('0x8')](function(_0x2faafa){logger[_0x3834('0x9')](_0x3834('0xa'),_0x1c0b23,_0x3834('0xb'));logger['debug'](_0x3834('0xc'),_0x1c0b23,'request\x20sent',JSON['stringify'](_0x2faafa));if(_0x2faafa['error']){if(_0x2faafa[_0x3834('0xd')][_0x3834('0xe')]===0x1f4){logger[_0x3834('0xd')](_0x3834('0xa'),_0x1c0b23,_0x2faafa[_0x3834('0xd')][_0x3834('0xf')]);return _0x520a4f(_0x2faafa[_0x3834('0xd')][_0x3834('0xf')]);}logger[_0x3834('0xd')](_0x3834('0xa'),_0x1c0b23,_0x2faafa[_0x3834('0xd')][_0x3834('0xf')]);return _0x994230(_0x2faafa['error'][_0x3834('0xf')]);}else{logger[_0x3834('0x9')](_0x3834('0xa'),_0x1c0b23,_0x3834('0xb'));_0x994230(_0x2faafa[_0x3834('0x10')][_0x3834('0xf')]);}})[_0x3834('0x11')](function(_0x3871c3){logger[_0x3834('0xd')]('ZendeskAccount,\x20%s,\x20%s',_0x1c0b23,_0x3871c3);_0x520a4f(_0x3871c3);});});}exports[_0x3834('0x12')]=function(_0x82ab35){var _0x225f2c=this;return new Promise(function(_0x46fd33,_0x590549){return db[_0x3834('0x13')][_0x3834('0x14')]({'raw':_0x82ab35[_0x3834('0x15')]?_0x82ab35[_0x3834('0x15')][_0x3834('0x16')]===undefined?!![]:![]:!![],'where':_0x82ab35[_0x3834('0x15')]?_0x82ab35[_0x3834('0x15')][_0x3834('0x17')]||null:null,'attributes':_0x82ab35[_0x3834('0x15')]?_0x82ab35[_0x3834('0x15')][_0x3834('0x18')]||null:null,'limit':_0x82ab35['options']?_0x82ab35[_0x3834('0x15')][_0x3834('0x19')]||null:null,'include':_0x82ab35[_0x3834('0x15')]?_0x82ab35[_0x3834('0x15')]['include']?_[_0x3834('0x1a')](_0x82ab35[_0x3834('0x15')]['include'],function(_0x5b33b5){return{'model':db[_0x5b33b5[_0x3834('0x1b')]],'as':_0x5b33b5['as'],'attributes':_0x5b33b5[_0x3834('0x18')],'include':_0x5b33b5[_0x3834('0x1c')]?_['map'](_0x5b33b5[_0x3834('0x1c')],function(_0x49f763){return{'model':db[_0x49f763[_0x3834('0x1b')]],'as':_0x49f763['as'],'attributes':_0x49f763[_0x3834('0x18')],'include':_0x49f763[_0x3834('0x1c')]?_['map'](_0x49f763[_0x3834('0x1c')],function(_0x38c59d){return{'model':db[_0x38c59d['model']],'as':_0x38c59d['as'],'attributes':_0x38c59d[_0x3834('0x18')]};}):[]};}):[]};}):[]:[]})[_0x3834('0x8')](function(_0x1ff1ed){logger[_0x3834('0x9')](_0x3834('0x12'),_0x82ab35);logger['debug'](_0x3834('0x12'),_0x82ab35,JSON['stringify'](_0x1ff1ed));_0x46fd33(_0x1ff1ed);})[_0x3834('0x11')](function(_0x1f36fb){logger['error'](_0x3834('0x12'),_0x1f36fb[_0x3834('0xf')],_0x82ab35);_0x590549(_0x225f2c[_0x3834('0xd')](0x1f4,_0x1f36fb[_0x3834('0xf')]));});});};exports['ShowZendeskAccount']=function(_0x40289e){var _0x338057=this;return new Promise(function(_0x40fc1a,_0x12065e){return db['ZendeskAccount'][_0x3834('0x1d')]({'raw':_0x40289e[_0x3834('0x15')]?_0x40289e[_0x3834('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x40289e[_0x3834('0x15')]?_0x40289e['options'][_0x3834('0x17')]||null:null,'attributes':_0x40289e[_0x3834('0x15')]?_0x40289e[_0x3834('0x15')][_0x3834('0x18')]||null:null,'include':_0x40289e[_0x3834('0x15')]?_0x40289e[_0x3834('0x15')]['include']?_['map'](_0x40289e[_0x3834('0x15')][_0x3834('0x1c')],function(_0x479f45){return{'model':db[_0x479f45[_0x3834('0x1b')]],'as':_0x479f45['as'],'attributes':_0x479f45['attributes'],'include':_0x479f45[_0x3834('0x1c')]?_[_0x3834('0x1a')](_0x479f45['include'],function(_0x159459){return{'model':db[_0x159459[_0x3834('0x1b')]],'as':_0x159459['as'],'attributes':_0x159459['attributes'],'include':_0x159459[_0x3834('0x1c')]?_[_0x3834('0x1a')](_0x159459[_0x3834('0x1c')],function(_0x123bf9){return{'model':db[_0x123bf9['model']],'as':_0x123bf9['as'],'attributes':_0x123bf9[_0x3834('0x18')]};}):[]};}):[]};}):[]:[]})[_0x3834('0x8')](function(_0xa4ee24){logger['info'](_0x3834('0x1e'),_0x40289e);logger[_0x3834('0x1f')]('ShowZendeskAccount',_0x40289e,JSON[_0x3834('0x20')](_0xa4ee24));_0x40fc1a(_0xa4ee24);})[_0x3834('0x11')](function(_0x50f62a){logger['error']('ShowZendeskAccount',_0x50f62a[_0x3834('0xf')],_0x40289e);_0x12065e(_0x338057[_0x3834('0xd')](0x1f4,_0x50f62a[_0x3834('0xf')]));});});};