Built motion from commit 3c2ce842.|2.6.31
[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 _0xd5b1=['ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','info','ZendeskAccount,\x20%s,\x20%s','request\x20sent','ZendeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetZendeskAccount','ZendeskAccount','findAll','options','raw','where','attributes','limit','include','map','model','find','ShowZendeskAccount','debug','lodash','bluebird'];(function(_0x184b1e,_0x35d3d9){var _0x51900b=function(_0x4a1d5d){while(--_0x4a1d5d){_0x184b1e['push'](_0x184b1e['shift']());}};_0x51900b(++_0x35d3d9);}(_0xd5b1,0x116));var _0x1d5b=function(_0x2943d9,_0x12fe5d){_0x2943d9=_0x2943d9-0x0;var _0x49313b=_0xd5b1[_0x2943d9];return _0x49313b;};'use strict';var _=require(_0x1d5b('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x1d5b('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x1d5b('0x2'));var db=require(_0x1d5b('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x1d5b('0x4'))('rpc');var config=require(_0x1d5b('0x5'));var jayson=require(_0x1d5b('0x6'));var client=jayson[_0x1d5b('0x7')][_0x1d5b('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x1aba5a,_0x29b1c6,_0x4a8370){return new BPromise(function(_0x7c8b0e,_0x23f05a){return client[_0x1d5b('0x9')](_0x1aba5a,_0x4a8370)[_0x1d5b('0xa')](function(_0x32066f){logger[_0x1d5b('0xb')](_0x1d5b('0xc'),_0x29b1c6,_0x1d5b('0xd'));logger['debug'](_0x1d5b('0xe'),_0x29b1c6,'request\x20sent',JSON[_0x1d5b('0xf')](_0x32066f));if(_0x32066f[_0x1d5b('0x10')]){if(_0x32066f[_0x1d5b('0x10')][_0x1d5b('0x11')]===0x1f4){logger[_0x1d5b('0x10')]('ZendeskAccount,\x20%s,\x20%s',_0x29b1c6,_0x32066f[_0x1d5b('0x10')][_0x1d5b('0x12')]);return _0x23f05a(_0x32066f[_0x1d5b('0x10')][_0x1d5b('0x12')]);}logger[_0x1d5b('0x10')]('ZendeskAccount,\x20%s,\x20%s',_0x29b1c6,_0x32066f[_0x1d5b('0x10')][_0x1d5b('0x12')]);return _0x7c8b0e(_0x32066f[_0x1d5b('0x10')]['message']);}else{logger[_0x1d5b('0xb')]('ZendeskAccount,\x20%s,\x20%s',_0x29b1c6,_0x1d5b('0xd'));_0x7c8b0e(_0x32066f[_0x1d5b('0x13')][_0x1d5b('0x12')]);}})[_0x1d5b('0x14')](function(_0x22ff82){logger[_0x1d5b('0x10')]('ZendeskAccount,\x20%s,\x20%s',_0x29b1c6,_0x22ff82);_0x23f05a(_0x22ff82);});});}exports[_0x1d5b('0x15')]=function(_0x25b1e8){var _0x333b25=this;return new Promise(function(_0x3907f9,_0x29834a){return db[_0x1d5b('0x16')][_0x1d5b('0x17')]({'raw':_0x25b1e8['options']?_0x25b1e8[_0x1d5b('0x18')][_0x1d5b('0x19')]===undefined?!![]:![]:!![],'where':_0x25b1e8[_0x1d5b('0x18')]?_0x25b1e8['options'][_0x1d5b('0x1a')]||null:null,'attributes':_0x25b1e8[_0x1d5b('0x18')]?_0x25b1e8['options'][_0x1d5b('0x1b')]||null:null,'limit':_0x25b1e8['options']?_0x25b1e8[_0x1d5b('0x18')][_0x1d5b('0x1c')]||null:null,'include':_0x25b1e8[_0x1d5b('0x18')]?_0x25b1e8[_0x1d5b('0x18')][_0x1d5b('0x1d')]?_[_0x1d5b('0x1e')](_0x25b1e8['options'][_0x1d5b('0x1d')],function(_0x129bd7){return{'model':db[_0x129bd7[_0x1d5b('0x1f')]],'as':_0x129bd7['as'],'attributes':_0x129bd7[_0x1d5b('0x1b')],'include':_0x129bd7[_0x1d5b('0x1d')]?_[_0x1d5b('0x1e')](_0x129bd7['include'],function(_0x556e86){return{'model':db[_0x556e86[_0x1d5b('0x1f')]],'as':_0x556e86['as'],'attributes':_0x556e86['attributes'],'include':_0x556e86[_0x1d5b('0x1d')]?_[_0x1d5b('0x1e')](_0x556e86['include'],function(_0x58f7b5){return{'model':db[_0x58f7b5[_0x1d5b('0x1f')]],'as':_0x58f7b5['as'],'attributes':_0x58f7b5[_0x1d5b('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x1d5b('0xa')](function(_0x3630af){logger[_0x1d5b('0xb')](_0x1d5b('0x15'),_0x25b1e8);logger['debug']('GetZendeskAccount',_0x25b1e8,JSON[_0x1d5b('0xf')](_0x3630af));_0x3907f9(_0x3630af);})['catch'](function(_0x2904de){logger[_0x1d5b('0x10')](_0x1d5b('0x15'),_0x2904de[_0x1d5b('0x12')],_0x25b1e8);_0x29834a(_0x333b25[_0x1d5b('0x10')](0x1f4,_0x2904de[_0x1d5b('0x12')]));});});};exports['ShowZendeskAccount']=function(_0x256f38){var _0x3b3286=this;return new Promise(function(_0xb2d930,_0x2b3a97){return db[_0x1d5b('0x16')][_0x1d5b('0x20')]({'raw':_0x256f38[_0x1d5b('0x18')]?_0x256f38[_0x1d5b('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x256f38[_0x1d5b('0x18')]?_0x256f38[_0x1d5b('0x18')]['where']||null:null,'attributes':_0x256f38['options']?_0x256f38[_0x1d5b('0x18')][_0x1d5b('0x1b')]||null:null,'include':_0x256f38[_0x1d5b('0x18')]?_0x256f38[_0x1d5b('0x18')]['include']?_['map'](_0x256f38['options'][_0x1d5b('0x1d')],function(_0x347fb4){return{'model':db[_0x347fb4['model']],'as':_0x347fb4['as'],'attributes':_0x347fb4[_0x1d5b('0x1b')],'include':_0x347fb4['include']?_['map'](_0x347fb4[_0x1d5b('0x1d')],function(_0x5e0b27){return{'model':db[_0x5e0b27['model']],'as':_0x5e0b27['as'],'attributes':_0x5e0b27['attributes'],'include':_0x5e0b27['include']?_['map'](_0x5e0b27[_0x1d5b('0x1d')],function(_0x8e8666){return{'model':db[_0x8e8666[_0x1d5b('0x1f')]],'as':_0x8e8666['as'],'attributes':_0x8e8666[_0x1d5b('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x1d5b('0xa')](function(_0x5bf0a2){logger[_0x1d5b('0xb')](_0x1d5b('0x21'),_0x256f38);logger[_0x1d5b('0x22')](_0x1d5b('0x21'),_0x256f38,JSON[_0x1d5b('0xf')](_0x5bf0a2));_0xb2d930(_0x5bf0a2);})[_0x1d5b('0x14')](function(_0x3f6572){logger['error'](_0x1d5b('0x21'),_0x3f6572[_0x1d5b('0x12')],_0x256f38);_0x2b3a97(_0x3b3286[_0x1d5b('0x10')](0x1f4,_0x3f6572['message']));});});};