Built motion from commit c116dc8b.|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 _0xdbfe=['where','limit','include','map','model','attributes','then','ShowZendeskAccount','ZendeskAccount','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','request','info','ZendeskAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','GetZendeskAccount','findAll','options','raw'];(function(_0x3989f8,_0x5457b0){var _0x45a576=function(_0x2ea27b){while(--_0x2ea27b){_0x3989f8['push'](_0x3989f8['shift']());}};_0x45a576(++_0x5457b0);}(_0xdbfe,0x174));var _0xedbf=function(_0x570112,_0x25a3b3){_0x570112=_0x570112-0x0;var _0x257d14=_0xdbfe[_0x570112];return _0x257d14;};'use strict';var _=require(_0xedbf('0x0'));var util=require(_0xedbf('0x1'));var moment=require(_0xedbf('0x2'));var BPromise=require(_0xedbf('0x3'));var rs=require(_0xedbf('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xedbf('0x5'))['db'];var utils=require(_0xedbf('0x6'));var logger=require(_0xedbf('0x7'))(_0xedbf('0x8'));var config=require(_0xedbf('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xedbf('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1e89f6,_0x2a3d83,_0x194e65){return new BPromise(function(_0x39a25a,_0x4ddf4b){return client[_0xedbf('0xb')](_0x1e89f6,_0x194e65)['then'](function(_0x21e068){logger[_0xedbf('0xc')](_0xedbf('0xd'),_0x2a3d83,_0xedbf('0xe'));logger[_0xedbf('0xf')]('ZendeskAccount,\x20%s,\x20%s,\x20%s',_0x2a3d83,_0xedbf('0xe'),JSON[_0xedbf('0x10')](_0x21e068));if(_0x21e068['error']){if(_0x21e068['error']['code']===0x1f4){logger[_0xedbf('0x11')](_0xedbf('0xd'),_0x2a3d83,_0x21e068['error'][_0xedbf('0x12')]);return _0x4ddf4b(_0x21e068[_0xedbf('0x11')]['message']);}logger[_0xedbf('0x11')](_0xedbf('0xd'),_0x2a3d83,_0x21e068[_0xedbf('0x11')][_0xedbf('0x12')]);return _0x39a25a(_0x21e068[_0xedbf('0x11')]['message']);}else{logger[_0xedbf('0xc')]('ZendeskAccount,\x20%s,\x20%s',_0x2a3d83,_0xedbf('0xe'));_0x39a25a(_0x21e068[_0xedbf('0x13')]['message']);}})['catch'](function(_0x5814e8){logger['error'](_0xedbf('0xd'),_0x2a3d83,_0x5814e8);_0x4ddf4b(_0x5814e8);});});}exports[_0xedbf('0x14')]=function(_0x42d5af){var _0x54e66f=this;return new Promise(function(_0x3de258,_0x1efa74){return db['ZendeskAccount'][_0xedbf('0x15')]({'raw':_0x42d5af['options']?_0x42d5af[_0xedbf('0x16')][_0xedbf('0x17')]===undefined?!![]:![]:!![],'where':_0x42d5af[_0xedbf('0x16')]?_0x42d5af[_0xedbf('0x16')][_0xedbf('0x18')]||null:null,'attributes':_0x42d5af[_0xedbf('0x16')]?_0x42d5af['options']['attributes']||null:null,'limit':_0x42d5af[_0xedbf('0x16')]?_0x42d5af[_0xedbf('0x16')][_0xedbf('0x19')]||null:null,'include':_0x42d5af['options']?_0x42d5af[_0xedbf('0x16')][_0xedbf('0x1a')]?_[_0xedbf('0x1b')](_0x42d5af['options'][_0xedbf('0x1a')],function(_0x3d86f5){return{'model':db[_0x3d86f5[_0xedbf('0x1c')]],'as':_0x3d86f5['as'],'attributes':_0x3d86f5['attributes'],'include':_0x3d86f5[_0xedbf('0x1a')]?_['map'](_0x3d86f5['include'],function(_0x659dee){return{'model':db[_0x659dee['model']],'as':_0x659dee['as'],'attributes':_0x659dee['attributes'],'include':_0x659dee[_0xedbf('0x1a')]?_[_0xedbf('0x1b')](_0x659dee['include'],function(_0x21813c){return{'model':db[_0x21813c[_0xedbf('0x1c')]],'as':_0x21813c['as'],'attributes':_0x21813c[_0xedbf('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xedbf('0x1e')](function(_0x2f715f){logger[_0xedbf('0xc')](_0xedbf('0x14'),_0x42d5af);logger[_0xedbf('0xf')](_0xedbf('0x14'),_0x42d5af,JSON[_0xedbf('0x10')](_0x2f715f));_0x3de258(_0x2f715f);})['catch'](function(_0x7ad8cf){logger['error']('GetZendeskAccount',_0x7ad8cf['message'],_0x42d5af);_0x1efa74(_0x54e66f[_0xedbf('0x11')](0x1f4,_0x7ad8cf[_0xedbf('0x12')]));});});};exports[_0xedbf('0x1f')]=function(_0x3aabe0){var _0x331d89=this;return new Promise(function(_0x24704f,_0x59950a){return db[_0xedbf('0x20')]['find']({'raw':_0x3aabe0[_0xedbf('0x16')]?_0x3aabe0[_0xedbf('0x16')][_0xedbf('0x17')]===undefined?!![]:![]:!![],'where':_0x3aabe0['options']?_0x3aabe0[_0xedbf('0x16')][_0xedbf('0x18')]||null:null,'attributes':_0x3aabe0[_0xedbf('0x16')]?_0x3aabe0['options'][_0xedbf('0x1d')]||null:null,'include':_0x3aabe0[_0xedbf('0x16')]?_0x3aabe0[_0xedbf('0x16')][_0xedbf('0x1a')]?_[_0xedbf('0x1b')](_0x3aabe0[_0xedbf('0x16')]['include'],function(_0x3ddfd9){return{'model':db[_0x3ddfd9[_0xedbf('0x1c')]],'as':_0x3ddfd9['as'],'attributes':_0x3ddfd9[_0xedbf('0x1d')],'include':_0x3ddfd9[_0xedbf('0x1a')]?_[_0xedbf('0x1b')](_0x3ddfd9[_0xedbf('0x1a')],function(_0x4a7b17){return{'model':db[_0x4a7b17[_0xedbf('0x1c')]],'as':_0x4a7b17['as'],'attributes':_0x4a7b17['attributes'],'include':_0x4a7b17[_0xedbf('0x1a')]?_[_0xedbf('0x1b')](_0x4a7b17['include'],function(_0x1a8c49){return{'model':db[_0x1a8c49[_0xedbf('0x1c')]],'as':_0x1a8c49['as'],'attributes':_0x1a8c49[_0xedbf('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xedbf('0x1e')](function(_0x1b5bab){logger[_0xedbf('0xc')]('ShowZendeskAccount',_0x3aabe0);logger[_0xedbf('0xf')](_0xedbf('0x1f'),_0x3aabe0,JSON[_0xedbf('0x10')](_0x1b5bab));_0x24704f(_0x1b5bab);})['catch'](function(_0x2e0313){logger[_0xedbf('0x11')](_0xedbf('0x1f'),_0x2e0313['message'],_0x3aabe0);_0x59950a(_0x331d89['error'](0x1f4,_0x2e0313[_0xedbf('0x12')]));});});};