Built motion from commit fda31434.|2.5.44
[motion2.git] / server / api / intZendeskConfiguration / intZendeskConfiguration.controller.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 _0xa0ac=['util','sox','to-csv','ejs','fs-extra','lodash','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','undefined','limit','offset','count','set','Content-Range','json','apply','save','update','destroy','then','end','error','stack','name','send','map','ZendeskConfiguration','rawAttributes','fieldName','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','type','VIRTUAL','filter','includeAll','include','rows','catch','show','params','find','create','body','getFields','findOne','options','getSubjects','getDescriptions','ZendeskField','getTags','Tag','setTags','ids','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird'];(function(_0xa1e3e3,_0x29fe0e){var _0xc980e9=function(_0x1f5adc){while(--_0x1f5adc){_0xa1e3e3['push'](_0xa1e3e3['shift']());}};_0xc980e9(++_0x29fe0e);}(_0xa0ac,0x14d));var _0xca0a=function(_0x253e47,_0x38c9d3){_0x253e47=_0x253e47-0x0;var _0x392b22=_0xa0ac[_0x253e47];return _0x392b22;};'use strict';var emlformat=require(_0xca0a('0x0'));var rimraf=require(_0xca0a('0x1'));var zipdir=require(_0xca0a('0x2'));var jsonpatch=require(_0xca0a('0x3'));var rp=require(_0xca0a('0x4'));var moment=require(_0xca0a('0x5'));var BPromise=require(_0xca0a('0x6'));var Mustache=require('mustache');var util=require(_0xca0a('0x7'));var path=require('path');var sox=require(_0xca0a('0x8'));var csv=require(_0xca0a('0x9'));var ejs=require(_0xca0a('0xa'));var fs=require('fs');var fs_extra=require(_0xca0a('0xb'));var _=require(_0xca0a('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xca0a('0xd'));var toCsv=require('to-csv');var querystring=require(_0xca0a('0xe'));var Papa=require('papaparse');var Redis=require(_0xca0a('0xf'));var authService=require(_0xca0a('0x10'));var qs=require(_0xca0a('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xca0a('0x12'));var logger=require(_0xca0a('0x13'))(_0xca0a('0x14'));var utils=require(_0xca0a('0x15'));var config=require(_0xca0a('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xca0a('0x17'))['db'];function respondWithStatusCode(_0x512bd1,_0x5756d3){_0x5756d3=_0x5756d3||0xcc;return function(_0x10f908){if(_0x10f908){return _0x512bd1[_0xca0a('0x18')](_0x5756d3);}return _0x512bd1[_0xca0a('0x19')](_0x5756d3)['end']();};}function respondWithResult(_0x1ed887,_0x4947bb){_0x4947bb=_0x4947bb||0xc8;return function(_0x16097b){if(_0x16097b){return _0x1ed887[_0xca0a('0x19')](_0x4947bb)['json'](_0x16097b);}};}function respondWithFilteredResult(_0x1e9371,_0x1e2c35){return function(_0x3bcb33){if(_0x3bcb33){var _0xc8aa5b=typeof _0x1e2c35['offset']===_0xca0a('0x1a')&&typeof _0x1e2c35[_0xca0a('0x1b')]==='undefined';var _0x167a4f=_0x3bcb33['count'];var _0x527b1f=_0xc8aa5b?0x0:_0x1e2c35[_0xca0a('0x1c')];var _0x319151=_0xc8aa5b?_0x3bcb33[_0xca0a('0x1d')]:_0x1e2c35[_0xca0a('0x1c')]+_0x1e2c35['limit'];var _0x1edcda;if(_0x319151>=_0x167a4f){_0x319151=_0x167a4f;_0x1edcda=0xc8;}else{_0x1edcda=0xce;}_0x1e9371[_0xca0a('0x19')](_0x1edcda);return _0x1e9371[_0xca0a('0x1e')](_0xca0a('0x1f'),_0x527b1f+'-'+_0x319151+'/'+_0x167a4f)[_0xca0a('0x20')](_0x3bcb33);}return null;};}function patchUpdates(_0x2ff746){return function(_0x4bdf7f){try{jsonpatch[_0xca0a('0x21')](_0x4bdf7f,_0x2ff746,!![]);}catch(_0x84a05b){return BPromise['reject'](_0x84a05b);}return _0x4bdf7f[_0xca0a('0x22')]();};}function saveUpdates(_0x36b95f,_0x23f8bd){return function(_0x4beabc){if(_0x4beabc){return _0x4beabc[_0xca0a('0x23')](_0x36b95f)['then'](function(_0x5ae817){return _0x5ae817;});}return null;};}function removeEntity(_0x1000dc,_0x5c362d){return function(_0x221f76){if(_0x221f76){return _0x221f76[_0xca0a('0x24')]()[_0xca0a('0x25')](function(){_0x1000dc[_0xca0a('0x19')](0xcc)[_0xca0a('0x26')]();});}};}function handleEntityNotFound(_0x47c4e5,_0x25f811){return function(_0x253b45){if(!_0x253b45){_0x47c4e5[_0xca0a('0x18')](0x194);}return _0x253b45;};}function handleError(_0x295c72,_0x1f1208){_0x1f1208=_0x1f1208||0x1f4;return function(_0x3da12e){logger[_0xca0a('0x27')](_0x3da12e[_0xca0a('0x28')]);if(_0x3da12e[_0xca0a('0x29')]){delete _0x3da12e[_0xca0a('0x29')];}_0x295c72['status'](_0x1f1208)[_0xca0a('0x2a')](_0x3da12e);};}exports['index']=function(_0x32108e,_0x1b178f){var _0x119163={},_0x4b24d7={},_0x37e3f4={'count':0x0,'rows':[]};var _0x353f93=_[_0xca0a('0x2b')](db[_0xca0a('0x2c')][_0xca0a('0x2d')],function(_0x1debd6){return{'name':_0x1debd6[_0xca0a('0x2e')],'type':_0x1debd6['type'][_0xca0a('0x2f')]};});_0x4b24d7[_0xca0a('0x30')]=_['map'](_0x353f93,_0xca0a('0x29'));_0x4b24d7[_0xca0a('0x31')]=_[_0xca0a('0x32')](_0x32108e[_0xca0a('0x31')]);_0x4b24d7[_0xca0a('0x33')]=_[_0xca0a('0x34')](_0x4b24d7[_0xca0a('0x30')],_0x4b24d7['query']);_0x119163['attributes']=_[_0xca0a('0x34')](_0x4b24d7[_0xca0a('0x30')],qs[_0xca0a('0x35')](_0x32108e[_0xca0a('0x31')][_0xca0a('0x35')]));_0x119163[_0xca0a('0x36')]=_0x119163['attributes'][_0xca0a('0x37')]?_0x119163[_0xca0a('0x36')]:_0x4b24d7[_0xca0a('0x30')];if(!_0x32108e[_0xca0a('0x31')][_0xca0a('0x38')](_0xca0a('0x39'))){_0x119163[_0xca0a('0x1b')]=qs['limit'](_0x32108e['query'][_0xca0a('0x1b')]);_0x119163['offset']=qs['offset'](_0x32108e[_0xca0a('0x31')][_0xca0a('0x1c')]);}_0x119163[_0xca0a('0x3a')]=qs[_0xca0a('0x3b')](_0x32108e['query'][_0xca0a('0x3b')]);_0x119163[_0xca0a('0x3c')]=qs[_0xca0a('0x33')](_[_0xca0a('0x3d')](_0x32108e[_0xca0a('0x31')],_0x4b24d7[_0xca0a('0x33')]),_0x353f93);if(_0x32108e['query']['filter']){_0x119163[_0xca0a('0x3c')]=_[_0xca0a('0x3e')](_0x119163[_0xca0a('0x3c')],{'$or':_[_0xca0a('0x2b')](_0x353f93,function(_0x2ab38e){if(_0x2ab38e[_0xca0a('0x3f')]!==_0xca0a('0x40')){var _0x3f0447={};_0x3f0447[_0x2ab38e[_0xca0a('0x29')]]={'$like':'%'+_0x32108e['query'][_0xca0a('0x41')]+'%'};return _0x3f0447;}})});}_0x119163=_['merge']({},_0x119163,_0x32108e['options']);var _0x5c84ee={'where':_0x119163[_0xca0a('0x3c')]};return db[_0xca0a('0x2c')]['count'](_0x5c84ee)[_0xca0a('0x25')](function(_0x43ab19){_0x37e3f4[_0xca0a('0x1d')]=_0x43ab19;if(_0x32108e[_0xca0a('0x31')][_0xca0a('0x42')]){_0x119163[_0xca0a('0x43')]=[{'all':!![]}];}return db['ZendeskConfiguration']['findAll'](_0x119163);})['then'](function(_0x12d69c){_0x37e3f4[_0xca0a('0x44')]=_0x12d69c;return _0x37e3f4;})[_0xca0a('0x25')](respondWithFilteredResult(_0x1b178f,_0x119163))[_0xca0a('0x45')](handleError(_0x1b178f,null));};exports[_0xca0a('0x46')]=function(_0x1c2c05,_0x1b6d8a){var _0x1e1c3e={'raw':![],'where':{'id':_0x1c2c05[_0xca0a('0x47')]['id']}},_0x3f3f0e={};_0x3f3f0e[_0xca0a('0x30')]=_[_0xca0a('0x32')](db['ZendeskConfiguration'][_0xca0a('0x2d')]);_0x3f3f0e['query']=_['keys'](_0x1c2c05[_0xca0a('0x31')]);_0x3f3f0e[_0xca0a('0x33')]=_[_0xca0a('0x34')](_0x3f3f0e[_0xca0a('0x30')],_0x3f3f0e[_0xca0a('0x31')]);_0x1e1c3e['attributes']=_[_0xca0a('0x34')](_0x3f3f0e[_0xca0a('0x30')],qs[_0xca0a('0x35')](_0x1c2c05[_0xca0a('0x31')][_0xca0a('0x35')]));_0x1e1c3e[_0xca0a('0x36')]=_0x1e1c3e[_0xca0a('0x36')][_0xca0a('0x37')]?_0x1e1c3e['attributes']:_0x3f3f0e[_0xca0a('0x30')];if(_0x1c2c05[_0xca0a('0x31')][_0xca0a('0x42')]){_0x1e1c3e[_0xca0a('0x43')]=[{'all':!![]}];}_0x1e1c3e=_['merge']({},_0x1e1c3e,_0x1c2c05['options']);return db[_0xca0a('0x2c')][_0xca0a('0x48')](_0x1e1c3e)[_0xca0a('0x25')](handleEntityNotFound(_0x1b6d8a,null))[_0xca0a('0x25')](respondWithResult(_0x1b6d8a,null))[_0xca0a('0x45')](handleError(_0x1b6d8a,null));};exports[_0xca0a('0x49')]=function(_0x1c8802,_0x15f91e){return db[_0xca0a('0x2c')]['create'](_0x1c8802[_0xca0a('0x4a')],{})[_0xca0a('0x25')](respondWithResult(_0x15f91e,0xc9))[_0xca0a('0x45')](handleError(_0x15f91e,null));};exports[_0xca0a('0x23')]=function(_0x2052c4,_0x2ddc40){if(_0x2052c4[_0xca0a('0x4a')]['id']){delete _0x2052c4[_0xca0a('0x4a')]['id'];}return db[_0xca0a('0x2c')][_0xca0a('0x48')]({'where':{'id':_0x2052c4[_0xca0a('0x47')]['id']}})['then'](handleEntityNotFound(_0x2ddc40,null))['then'](saveUpdates(_0x2052c4[_0xca0a('0x4a')],null))[_0xca0a('0x25')](respondWithResult(_0x2ddc40,null))[_0xca0a('0x45')](handleError(_0x2ddc40,null));};exports[_0xca0a('0x24')]=function(_0x13bb70,_0x1d909f){return db[_0xca0a('0x2c')][_0xca0a('0x48')]({'where':{'id':_0x13bb70[_0xca0a('0x47')]['id']}})[_0xca0a('0x25')](handleEntityNotFound(_0x1d909f,null))[_0xca0a('0x25')](removeEntity(_0x1d909f,null))[_0xca0a('0x45')](handleError(_0x1d909f,null));};exports[_0xca0a('0x4b')]=function(_0x482279,_0x4bf045,_0x1fb563){var _0x3bb8ef={};var _0x560b0c={};var _0xbfe9f9;var _0x2ec94a;return db[_0xca0a('0x2c')][_0xca0a('0x4c')]({'where':{'id':_0x482279[_0xca0a('0x47')]['id']}})['then'](handleEntityNotFound(_0x4bf045,null))['then'](function(_0x37e265){if(_0x37e265){_0xbfe9f9=_0x37e265;_0x560b0c['model']=_[_0xca0a('0x32')](db['ZendeskField']['rawAttributes']);_0x560b0c[_0xca0a('0x31')]=_['keys'](_0x482279[_0xca0a('0x31')]);_0x560b0c['filters']=_['intersection'](_0x560b0c[_0xca0a('0x30')],_0x560b0c[_0xca0a('0x31')]);_0x3bb8ef['attributes']=_[_0xca0a('0x34')](_0x560b0c[_0xca0a('0x30')],qs['fields'](_0x482279[_0xca0a('0x31')][_0xca0a('0x35')]));_0x3bb8ef[_0xca0a('0x36')]=_0x3bb8ef[_0xca0a('0x36')]['length']?_0x3bb8ef['attributes']:_0x560b0c[_0xca0a('0x30')];_0x3bb8ef[_0xca0a('0x3a')]=qs[_0xca0a('0x3b')](_0x482279[_0xca0a('0x31')]['sort']);_0x3bb8ef['where']=qs[_0xca0a('0x33')](_[_0xca0a('0x3d')](_0x482279[_0xca0a('0x31')],_0x560b0c[_0xca0a('0x33')]));if(_0x482279[_0xca0a('0x31')][_0xca0a('0x41')]){_0x3bb8ef['where']=_['merge'](_0x3bb8ef[_0xca0a('0x3c')],{'$or':_['map'](_0x3bb8ef[_0xca0a('0x36')],function(_0x25e137){var _0x39b259={};_0x39b259[_0x25e137]={'$like':'%'+_0x482279['query'][_0xca0a('0x41')]+'%'};return _0x39b259;})});}_0x3bb8ef=_[_0xca0a('0x3e')]({},_0x3bb8ef,_0x482279[_0xca0a('0x4d')]);return _0xbfe9f9[_0xca0a('0x4b')](_0x3bb8ef);}})[_0xca0a('0x25')](function(_0x209afc){if(_0x209afc){_0x2ec94a=_0x209afc[_0xca0a('0x37')];if(!_0x482279[_0xca0a('0x31')]['hasOwnProperty']('nolimit')){_0x3bb8ef[_0xca0a('0x1b')]=qs[_0xca0a('0x1b')](_0x482279[_0xca0a('0x31')][_0xca0a('0x1b')]);_0x3bb8ef[_0xca0a('0x1c')]=qs[_0xca0a('0x1c')](_0x482279['query'][_0xca0a('0x1c')]);}return _0xbfe9f9['getFields'](_0x3bb8ef);}})[_0xca0a('0x25')](function(_0x1e08ec){if(_0x1e08ec){return _0x1e08ec?{'count':_0x2ec94a,'rows':_0x1e08ec}:null;}})[_0xca0a('0x25')](respondWithResult(_0x4bf045,null))['catch'](handleError(_0x4bf045,null));};exports[_0xca0a('0x4e')]=function(_0x26e22d,_0x2d4a18,_0x668585){var _0x8c6bd9={};var _0x3da729={};var _0x20bdc4;var _0x4b67f3;return db[_0xca0a('0x2c')][_0xca0a('0x4c')]({'where':{'id':_0x26e22d[_0xca0a('0x47')]['id']}})[_0xca0a('0x25')](handleEntityNotFound(_0x2d4a18,null))[_0xca0a('0x25')](function(_0x2c34e6){if(_0x2c34e6){_0x20bdc4=_0x2c34e6;_0x3da729[_0xca0a('0x30')]=_['keys'](db['ZendeskField']['rawAttributes']);_0x3da729[_0xca0a('0x31')]=_[_0xca0a('0x32')](_0x26e22d[_0xca0a('0x31')]);_0x3da729[_0xca0a('0x33')]=_[_0xca0a('0x34')](_0x3da729[_0xca0a('0x30')],_0x3da729[_0xca0a('0x31')]);_0x8c6bd9[_0xca0a('0x36')]=_['intersection'](_0x3da729[_0xca0a('0x30')],qs[_0xca0a('0x35')](_0x26e22d[_0xca0a('0x31')]['fields']));_0x8c6bd9['attributes']=_0x8c6bd9[_0xca0a('0x36')][_0xca0a('0x37')]?_0x8c6bd9[_0xca0a('0x36')]:_0x3da729[_0xca0a('0x30')];_0x8c6bd9[_0xca0a('0x3a')]=qs[_0xca0a('0x3b')](_0x26e22d[_0xca0a('0x31')]['sort']);_0x8c6bd9[_0xca0a('0x3c')]=qs[_0xca0a('0x33')](_[_0xca0a('0x3d')](_0x26e22d[_0xca0a('0x31')],_0x3da729[_0xca0a('0x33')]));if(_0x26e22d[_0xca0a('0x31')]['filter']){_0x8c6bd9[_0xca0a('0x3c')]=_['merge'](_0x8c6bd9['where'],{'$or':_[_0xca0a('0x2b')](_0x8c6bd9[_0xca0a('0x36')],function(_0x277294){var _0x1c70a0={};_0x1c70a0[_0x277294]={'$like':'%'+_0x26e22d[_0xca0a('0x31')][_0xca0a('0x41')]+'%'};return _0x1c70a0;})});}_0x8c6bd9=_['merge']({},_0x8c6bd9,_0x26e22d[_0xca0a('0x4d')]);return _0x20bdc4['getSubjects'](_0x8c6bd9);}})['then'](function(_0x4a26fd){if(_0x4a26fd){_0x4b67f3=_0x4a26fd[_0xca0a('0x37')];if(!_0x26e22d[_0xca0a('0x31')][_0xca0a('0x38')](_0xca0a('0x39'))){_0x8c6bd9[_0xca0a('0x1b')]=qs[_0xca0a('0x1b')](_0x26e22d[_0xca0a('0x31')][_0xca0a('0x1b')]);_0x8c6bd9['offset']=qs['offset'](_0x26e22d['query'][_0xca0a('0x1c')]);}return _0x20bdc4[_0xca0a('0x4e')](_0x8c6bd9);}})[_0xca0a('0x25')](function(_0x2b3a79){if(_0x2b3a79){return _0x2b3a79?{'count':_0x4b67f3,'rows':_0x2b3a79}:null;}})[_0xca0a('0x25')](respondWithResult(_0x2d4a18,null))['catch'](handleError(_0x2d4a18,null));};exports[_0xca0a('0x4f')]=function(_0x3b534f,_0x1d4462,_0x6d463b){var _0x1e2021={};var _0x35f26c={};var _0x1a0a9e;var _0xafd094;return db[_0xca0a('0x2c')][_0xca0a('0x4c')]({'where':{'id':_0x3b534f[_0xca0a('0x47')]['id']}})[_0xca0a('0x25')](handleEntityNotFound(_0x1d4462,null))[_0xca0a('0x25')](function(_0x436382){if(_0x436382){_0x1a0a9e=_0x436382;_0x35f26c['model']=_[_0xca0a('0x32')](db[_0xca0a('0x50')][_0xca0a('0x2d')]);_0x35f26c[_0xca0a('0x31')]=_[_0xca0a('0x32')](_0x3b534f[_0xca0a('0x31')]);_0x35f26c['filters']=_[_0xca0a('0x34')](_0x35f26c['model'],_0x35f26c[_0xca0a('0x31')]);_0x1e2021['attributes']=_['intersection'](_0x35f26c[_0xca0a('0x30')],qs['fields'](_0x3b534f[_0xca0a('0x31')][_0xca0a('0x35')]));_0x1e2021[_0xca0a('0x36')]=_0x1e2021[_0xca0a('0x36')][_0xca0a('0x37')]?_0x1e2021[_0xca0a('0x36')]:_0x35f26c[_0xca0a('0x30')];_0x1e2021[_0xca0a('0x3a')]=qs[_0xca0a('0x3b')](_0x3b534f[_0xca0a('0x31')][_0xca0a('0x3b')]);_0x1e2021['where']=qs[_0xca0a('0x33')](_[_0xca0a('0x3d')](_0x3b534f[_0xca0a('0x31')],_0x35f26c['filters']));if(_0x3b534f[_0xca0a('0x31')]['filter']){_0x1e2021['where']=_[_0xca0a('0x3e')](_0x1e2021[_0xca0a('0x3c')],{'$or':_[_0xca0a('0x2b')](_0x1e2021[_0xca0a('0x36')],function(_0xed2877){var _0x48756e={};_0x48756e[_0xed2877]={'$like':'%'+_0x3b534f[_0xca0a('0x31')][_0xca0a('0x41')]+'%'};return _0x48756e;})});}_0x1e2021=_[_0xca0a('0x3e')]({},_0x1e2021,_0x3b534f[_0xca0a('0x4d')]);return _0x1a0a9e[_0xca0a('0x4f')](_0x1e2021);}})['then'](function(_0xd7e03b){if(_0xd7e03b){_0xafd094=_0xd7e03b[_0xca0a('0x37')];if(!_0x3b534f['query']['hasOwnProperty']('nolimit')){_0x1e2021[_0xca0a('0x1b')]=qs[_0xca0a('0x1b')](_0x3b534f['query'][_0xca0a('0x1b')]);_0x1e2021[_0xca0a('0x1c')]=qs[_0xca0a('0x1c')](_0x3b534f[_0xca0a('0x31')][_0xca0a('0x1c')]);}return _0x1a0a9e[_0xca0a('0x4f')](_0x1e2021);}})[_0xca0a('0x25')](function(_0x3aaf08){if(_0x3aaf08){return _0x3aaf08?{'count':_0xafd094,'rows':_0x3aaf08}:null;}})[_0xca0a('0x25')](respondWithResult(_0x1d4462,null))[_0xca0a('0x45')](handleError(_0x1d4462,null));};exports[_0xca0a('0x51')]=function(_0x2059a5,_0x5c72c3,_0x473d67){var _0x2bf74d={};var _0x105ab2={};var _0x4420a4;var _0x2a5d33;return db[_0xca0a('0x2c')][_0xca0a('0x4c')]({'where':{'id':_0x2059a5[_0xca0a('0x47')]['id']}})[_0xca0a('0x25')](handleEntityNotFound(_0x5c72c3,null))[_0xca0a('0x25')](function(_0x56c72f){if(_0x56c72f){_0x4420a4=_0x56c72f;_0x105ab2[_0xca0a('0x30')]=_['keys'](db[_0xca0a('0x52')][_0xca0a('0x2d')]);_0x105ab2[_0xca0a('0x31')]=_['keys'](_0x2059a5['query']);_0x105ab2[_0xca0a('0x33')]=_[_0xca0a('0x34')](_0x105ab2[_0xca0a('0x30')],_0x105ab2['query']);_0x2bf74d[_0xca0a('0x36')]=_[_0xca0a('0x34')](_0x105ab2['model'],qs[_0xca0a('0x35')](_0x2059a5[_0xca0a('0x31')][_0xca0a('0x35')]));_0x2bf74d[_0xca0a('0x36')]=_0x2bf74d[_0xca0a('0x36')][_0xca0a('0x37')]?_0x2bf74d[_0xca0a('0x36')]:_0x105ab2[_0xca0a('0x30')];_0x2bf74d[_0xca0a('0x3a')]=qs[_0xca0a('0x3b')](_0x2059a5[_0xca0a('0x31')][_0xca0a('0x3b')]);_0x2bf74d[_0xca0a('0x3c')]=qs[_0xca0a('0x33')](_[_0xca0a('0x3d')](_0x2059a5[_0xca0a('0x31')],_0x105ab2[_0xca0a('0x33')]));if(_0x2059a5[_0xca0a('0x31')][_0xca0a('0x41')]){_0x2bf74d['where']=_[_0xca0a('0x3e')](_0x2bf74d[_0xca0a('0x3c')],{'$or':_[_0xca0a('0x2b')](_0x2bf74d['attributes'],function(_0x223155){var _0x34581a={};_0x34581a[_0x223155]={'$like':'%'+_0x2059a5[_0xca0a('0x31')]['filter']+'%'};return _0x34581a;})});}_0x2bf74d=_['merge']({},_0x2bf74d,_0x2059a5['options']);return _0x4420a4['getTags'](_0x2bf74d);}})['then'](function(_0x5562fb){if(_0x5562fb){_0x2a5d33=_0x5562fb[_0xca0a('0x37')];if(!_0x2059a5[_0xca0a('0x31')][_0xca0a('0x38')]('nolimit')){_0x2bf74d[_0xca0a('0x1b')]=qs[_0xca0a('0x1b')](_0x2059a5[_0xca0a('0x31')][_0xca0a('0x1b')]);_0x2bf74d[_0xca0a('0x1c')]=qs[_0xca0a('0x1c')](_0x2059a5[_0xca0a('0x31')][_0xca0a('0x1c')]);}return _0x4420a4[_0xca0a('0x51')](_0x2bf74d);}})[_0xca0a('0x25')](function(_0x2b9076){if(_0x2b9076){return _0x2b9076?{'count':_0x2a5d33,'rows':_0x2b9076}:null;}})[_0xca0a('0x25')](respondWithResult(_0x5c72c3,null))[_0xca0a('0x45')](handleError(_0x5c72c3,null));};exports[_0xca0a('0x53')]=function(_0x2036c1,_0x1f9522,_0x55c59e){if(_0x2036c1[_0xca0a('0x4a')]['id']){delete _0x2036c1[_0xca0a('0x4a')]['id'];}return db['ZendeskConfiguration'][_0xca0a('0x4c')]({'where':{'id':_0x2036c1[_0xca0a('0x47')]['id']}})[_0xca0a('0x25')](handleEntityNotFound(_0x1f9522,null))[_0xca0a('0x25')](function(_0x47dbe1){if(_0x47dbe1){return _0x47dbe1[_0xca0a('0x53')](_0x2036c1[_0xca0a('0x4a')][_0xca0a('0x54')]||[]);}return null;})[_0xca0a('0x25')](respondWithResult(_0x1f9522,null))[_0xca0a('0x45')](handleError(_0x1f9522,null));};