Built motion from commit 5ad77b03.|2.6.3
[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 _0x5f8b=['order','sort','pick','where','merge','VIRTUAL','filter','options','includeAll','include','findAll','catch','show','params','filters','length','find','create','body','destroy','getFields','findOne','ZendeskField','getSubjects','getDescriptions','getTags','Tag','setTags','rimraf','zip-dir','bluebird','mustache','path','sox','ejs','fs-extra','lodash','squel','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','end','json','offset','undefined','limit','count','status','set','Content-Range','apply','reject','save','update','then','error','stack','name','map','ZendeskConfiguration','rawAttributes','fieldName','type','model','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit'];(function(_0x5db99b,_0xdee23a){var _0x4b2d0e=function(_0x4deee1){while(--_0x4deee1){_0x5db99b['push'](_0x5db99b['shift']());}};_0x4b2d0e(++_0xdee23a);}(_0x5f8b,0x160));var _0xb5f8=function(_0x1a72f3,_0x217011){_0x1a72f3=_0x1a72f3-0x0;var _0x57ef47=_0x5f8b[_0x1a72f3];return _0x57ef47;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb5f8('0x0'));var zipdir=require(_0xb5f8('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xb5f8('0x2'));var Mustache=require(_0xb5f8('0x3'));var util=require('util');var path=require(_0xb5f8('0x4'));var sox=require(_0xb5f8('0x5'));var csv=require('to-csv');var ejs=require(_0xb5f8('0x6'));var fs=require('fs');var fs_extra=require(_0xb5f8('0x7'));var _=require(_0xb5f8('0x8'));var squel=require(_0xb5f8('0x9'));var crypto=require('crypto');var jsforce=require(_0xb5f8('0xa'));var deskjs=require(_0xb5f8('0xb'));var toCsv=require(_0xb5f8('0xc'));var querystring=require('querystring');var Papa=require(_0xb5f8('0xd'));var Redis=require(_0xb5f8('0xe'));var authService=require(_0xb5f8('0xf'));var qs=require(_0xb5f8('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xb5f8('0x11'));var logger=require(_0xb5f8('0x12'))('api');var utils=require(_0xb5f8('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0xb5f8('0x14'));var db=require(_0xb5f8('0x15'))['db'];function respondWithStatusCode(_0x3a178e,_0xfed86c){_0xfed86c=_0xfed86c||0xcc;return function(_0x542a47){if(_0x542a47){return _0x3a178e[_0xb5f8('0x16')](_0xfed86c);}return _0x3a178e['status'](_0xfed86c)[_0xb5f8('0x17')]();};}function respondWithResult(_0xfaa91f,_0x237304){_0x237304=_0x237304||0xc8;return function(_0x80b682){if(_0x80b682){return _0xfaa91f['status'](_0x237304)[_0xb5f8('0x18')](_0x80b682);}};}function respondWithFilteredResult(_0x2770e0,_0x2f9efe){return function(_0x200408){if(_0x200408){var _0x48bfe0=typeof _0x2f9efe[_0xb5f8('0x19')]===_0xb5f8('0x1a')&&typeof _0x2f9efe[_0xb5f8('0x1b')]==='undefined';var _0x4947d0=_0x200408[_0xb5f8('0x1c')];var _0x352a38=_0x48bfe0?0x0:_0x2f9efe[_0xb5f8('0x19')];var _0x17b2df=_0x48bfe0?_0x200408[_0xb5f8('0x1c')]:_0x2f9efe[_0xb5f8('0x19')]+_0x2f9efe[_0xb5f8('0x1b')];var _0x465ec4;if(_0x17b2df>=_0x4947d0){_0x17b2df=_0x4947d0;_0x465ec4=0xc8;}else{_0x465ec4=0xce;}_0x2770e0[_0xb5f8('0x1d')](_0x465ec4);return _0x2770e0[_0xb5f8('0x1e')](_0xb5f8('0x1f'),_0x352a38+'-'+_0x17b2df+'/'+_0x4947d0)['json'](_0x200408);}return null;};}function patchUpdates(_0x133f38){return function(_0x87141b){try{jsonpatch[_0xb5f8('0x20')](_0x87141b,_0x133f38,!![]);}catch(_0x44cc9f){return BPromise[_0xb5f8('0x21')](_0x44cc9f);}return _0x87141b[_0xb5f8('0x22')]();};}function saveUpdates(_0xca4f7f,_0x22beb9){return function(_0x383a60){if(_0x383a60){return _0x383a60[_0xb5f8('0x23')](_0xca4f7f)['then'](function(_0x379277){return _0x379277;});}return null;};}function removeEntity(_0x56fb4c,_0x16cb54){return function(_0x53e913){if(_0x53e913){return _0x53e913['destroy']()[_0xb5f8('0x24')](function(){_0x56fb4c[_0xb5f8('0x1d')](0xcc)[_0xb5f8('0x17')]();});}};}function handleEntityNotFound(_0x4bc5db,_0x117638){return function(_0x7af1fc){if(!_0x7af1fc){_0x4bc5db['sendStatus'](0x194);}return _0x7af1fc;};}function handleError(_0x3aeb57,_0xec7bf5){_0xec7bf5=_0xec7bf5||0x1f4;return function(_0x4de14d){logger[_0xb5f8('0x25')](_0x4de14d[_0xb5f8('0x26')]);if(_0x4de14d['name']){delete _0x4de14d[_0xb5f8('0x27')];}_0x3aeb57[_0xb5f8('0x1d')](_0xec7bf5)['send'](_0x4de14d);};}exports['index']=function(_0x5edfcc,_0x3eaf37){var _0x1ae82d={},_0xf8bf21={},_0x8cccb6={'count':0x0,'rows':[]};var _0x4fa3d1=_[_0xb5f8('0x28')](db[_0xb5f8('0x29')][_0xb5f8('0x2a')],function(_0x27907b){return{'name':_0x27907b[_0xb5f8('0x2b')],'type':_0x27907b[_0xb5f8('0x2c')]['key']};});_0xf8bf21[_0xb5f8('0x2d')]=_['map'](_0x4fa3d1,'name');_0xf8bf21[_0xb5f8('0x2e')]=_[_0xb5f8('0x2f')](_0x5edfcc[_0xb5f8('0x2e')]);_0xf8bf21['filters']=_[_0xb5f8('0x30')](_0xf8bf21[_0xb5f8('0x2d')],_0xf8bf21['query']);_0x1ae82d[_0xb5f8('0x31')]=_[_0xb5f8('0x30')](_0xf8bf21[_0xb5f8('0x2d')],qs[_0xb5f8('0x32')](_0x5edfcc[_0xb5f8('0x2e')][_0xb5f8('0x32')]));_0x1ae82d[_0xb5f8('0x31')]=_0x1ae82d[_0xb5f8('0x31')]['length']?_0x1ae82d[_0xb5f8('0x31')]:_0xf8bf21[_0xb5f8('0x2d')];if(!_0x5edfcc[_0xb5f8('0x2e')][_0xb5f8('0x33')](_0xb5f8('0x34'))){_0x1ae82d[_0xb5f8('0x1b')]=qs[_0xb5f8('0x1b')](_0x5edfcc[_0xb5f8('0x2e')][_0xb5f8('0x1b')]);_0x1ae82d[_0xb5f8('0x19')]=qs[_0xb5f8('0x19')](_0x5edfcc[_0xb5f8('0x2e')][_0xb5f8('0x19')]);}_0x1ae82d[_0xb5f8('0x35')]=qs[_0xb5f8('0x36')](_0x5edfcc['query'][_0xb5f8('0x36')]);_0x1ae82d['where']=qs['filters'](_[_0xb5f8('0x37')](_0x5edfcc[_0xb5f8('0x2e')],_0xf8bf21['filters']),_0x4fa3d1);if(_0x5edfcc[_0xb5f8('0x2e')]['filter']){_0x1ae82d[_0xb5f8('0x38')]=_[_0xb5f8('0x39')](_0x1ae82d['where'],{'$or':_[_0xb5f8('0x28')](_0x4fa3d1,function(_0x372eea){if(_0x372eea[_0xb5f8('0x2c')]!==_0xb5f8('0x3a')){var _0x4fb8a0={};_0x4fb8a0[_0x372eea['name']]={'$like':'%'+_0x5edfcc[_0xb5f8('0x2e')][_0xb5f8('0x3b')]+'%'};return _0x4fb8a0;}})});}_0x1ae82d=_[_0xb5f8('0x39')]({},_0x1ae82d,_0x5edfcc[_0xb5f8('0x3c')]);var _0x284bcb={'where':_0x1ae82d[_0xb5f8('0x38')]};return db[_0xb5f8('0x29')][_0xb5f8('0x1c')](_0x284bcb)['then'](function(_0x226e00){_0x8cccb6[_0xb5f8('0x1c')]=_0x226e00;if(_0x5edfcc[_0xb5f8('0x2e')][_0xb5f8('0x3d')]){_0x1ae82d[_0xb5f8('0x3e')]=[{'all':!![]}];}return db[_0xb5f8('0x29')][_0xb5f8('0x3f')](_0x1ae82d);})[_0xb5f8('0x24')](function(_0x31820e){_0x8cccb6['rows']=_0x31820e;return _0x8cccb6;})[_0xb5f8('0x24')](respondWithFilteredResult(_0x3eaf37,_0x1ae82d))[_0xb5f8('0x40')](handleError(_0x3eaf37,null));};exports[_0xb5f8('0x41')]=function(_0x1dcf44,_0x42e1a9){var _0x524a75={'raw':![],'where':{'id':_0x1dcf44[_0xb5f8('0x42')]['id']}},_0x5e11e3={};_0x5e11e3[_0xb5f8('0x2d')]=_['keys'](db[_0xb5f8('0x29')]['rawAttributes']);_0x5e11e3[_0xb5f8('0x2e')]=_[_0xb5f8('0x2f')](_0x1dcf44[_0xb5f8('0x2e')]);_0x5e11e3[_0xb5f8('0x43')]=_[_0xb5f8('0x30')](_0x5e11e3[_0xb5f8('0x2d')],_0x5e11e3[_0xb5f8('0x2e')]);_0x524a75[_0xb5f8('0x31')]=_[_0xb5f8('0x30')](_0x5e11e3[_0xb5f8('0x2d')],qs[_0xb5f8('0x32')](_0x1dcf44[_0xb5f8('0x2e')][_0xb5f8('0x32')]));_0x524a75[_0xb5f8('0x31')]=_0x524a75['attributes'][_0xb5f8('0x44')]?_0x524a75[_0xb5f8('0x31')]:_0x5e11e3['model'];if(_0x1dcf44[_0xb5f8('0x2e')]['includeAll']){_0x524a75[_0xb5f8('0x3e')]=[{'all':!![]}];}_0x524a75=_['merge']({},_0x524a75,_0x1dcf44[_0xb5f8('0x3c')]);return db[_0xb5f8('0x29')][_0xb5f8('0x45')](_0x524a75)['then'](handleEntityNotFound(_0x42e1a9,null))[_0xb5f8('0x24')](respondWithResult(_0x42e1a9,null))[_0xb5f8('0x40')](handleError(_0x42e1a9,null));};exports['create']=function(_0x18f348,_0x10fb91){return db[_0xb5f8('0x29')][_0xb5f8('0x46')](_0x18f348['body'],{})[_0xb5f8('0x24')](respondWithResult(_0x10fb91,0xc9))[_0xb5f8('0x40')](handleError(_0x10fb91,null));};exports[_0xb5f8('0x23')]=function(_0x4ad86e,_0x5a70cb){if(_0x4ad86e[_0xb5f8('0x47')]['id']){delete _0x4ad86e['body']['id'];}return db[_0xb5f8('0x29')]['find']({'where':{'id':_0x4ad86e[_0xb5f8('0x42')]['id']}})[_0xb5f8('0x24')](handleEntityNotFound(_0x5a70cb,null))[_0xb5f8('0x24')](saveUpdates(_0x4ad86e[_0xb5f8('0x47')],null))['then'](respondWithResult(_0x5a70cb,null))[_0xb5f8('0x40')](handleError(_0x5a70cb,null));};exports[_0xb5f8('0x48')]=function(_0x5cc75f,_0x321d42){return db[_0xb5f8('0x29')][_0xb5f8('0x45')]({'where':{'id':_0x5cc75f[_0xb5f8('0x42')]['id']}})['then'](handleEntityNotFound(_0x321d42,null))[_0xb5f8('0x24')](removeEntity(_0x321d42,null))['catch'](handleError(_0x321d42,null));};exports[_0xb5f8('0x49')]=function(_0x335eaf,_0x228924,_0x3c0318){var _0x2caab6={};var _0x463aad={};var _0x126150;var _0x3dbcec;return db[_0xb5f8('0x29')][_0xb5f8('0x4a')]({'where':{'id':_0x335eaf[_0xb5f8('0x42')]['id']}})['then'](handleEntityNotFound(_0x228924,null))[_0xb5f8('0x24')](function(_0x24d2e0){if(_0x24d2e0){_0x126150=_0x24d2e0;_0x463aad[_0xb5f8('0x2d')]=_['keys'](db[_0xb5f8('0x4b')]['rawAttributes']);_0x463aad[_0xb5f8('0x2e')]=_[_0xb5f8('0x2f')](_0x335eaf[_0xb5f8('0x2e')]);_0x463aad[_0xb5f8('0x43')]=_[_0xb5f8('0x30')](_0x463aad[_0xb5f8('0x2d')],_0x463aad[_0xb5f8('0x2e')]);_0x2caab6[_0xb5f8('0x31')]=_['intersection'](_0x463aad[_0xb5f8('0x2d')],qs[_0xb5f8('0x32')](_0x335eaf[_0xb5f8('0x2e')][_0xb5f8('0x32')]));_0x2caab6[_0xb5f8('0x31')]=_0x2caab6['attributes'][_0xb5f8('0x44')]?_0x2caab6['attributes']:_0x463aad[_0xb5f8('0x2d')];_0x2caab6[_0xb5f8('0x35')]=qs[_0xb5f8('0x36')](_0x335eaf[_0xb5f8('0x2e')][_0xb5f8('0x36')]);_0x2caab6[_0xb5f8('0x38')]=qs[_0xb5f8('0x43')](_[_0xb5f8('0x37')](_0x335eaf[_0xb5f8('0x2e')],_0x463aad[_0xb5f8('0x43')]));if(_0x335eaf[_0xb5f8('0x2e')][_0xb5f8('0x3b')]){_0x2caab6[_0xb5f8('0x38')]=_[_0xb5f8('0x39')](_0x2caab6[_0xb5f8('0x38')],{'$or':_[_0xb5f8('0x28')](_0x2caab6[_0xb5f8('0x31')],function(_0x28e9e7){var _0xbd1faf={};_0xbd1faf[_0x28e9e7]={'$like':'%'+_0x335eaf[_0xb5f8('0x2e')][_0xb5f8('0x3b')]+'%'};return _0xbd1faf;})});}_0x2caab6=_[_0xb5f8('0x39')]({},_0x2caab6,_0x335eaf[_0xb5f8('0x3c')]);return _0x126150[_0xb5f8('0x49')](_0x2caab6);}})['then'](function(_0x40c0f2){if(_0x40c0f2){_0x3dbcec=_0x40c0f2[_0xb5f8('0x44')];if(!_0x335eaf[_0xb5f8('0x2e')][_0xb5f8('0x33')](_0xb5f8('0x34'))){_0x2caab6['limit']=qs[_0xb5f8('0x1b')](_0x335eaf[_0xb5f8('0x2e')][_0xb5f8('0x1b')]);_0x2caab6[_0xb5f8('0x19')]=qs[_0xb5f8('0x19')](_0x335eaf[_0xb5f8('0x2e')]['offset']);}return _0x126150['getFields'](_0x2caab6);}})[_0xb5f8('0x24')](function(_0x1af25a){if(_0x1af25a){return _0x1af25a?{'count':_0x3dbcec,'rows':_0x1af25a}:null;}})['then'](respondWithResult(_0x228924,null))[_0xb5f8('0x40')](handleError(_0x228924,null));};exports['getSubjects']=function(_0x51c1e9,_0xa0b763,_0x42c2b8){var _0x1b91cc={};var _0x5c904d={};var _0x4e7d3c;var _0x5a8e98;return db['ZendeskConfiguration'][_0xb5f8('0x4a')]({'where':{'id':_0x51c1e9[_0xb5f8('0x42')]['id']}})[_0xb5f8('0x24')](handleEntityNotFound(_0xa0b763,null))[_0xb5f8('0x24')](function(_0x1e06b5){if(_0x1e06b5){_0x4e7d3c=_0x1e06b5;_0x5c904d[_0xb5f8('0x2d')]=_['keys'](db[_0xb5f8('0x4b')][_0xb5f8('0x2a')]);_0x5c904d[_0xb5f8('0x2e')]=_[_0xb5f8('0x2f')](_0x51c1e9[_0xb5f8('0x2e')]);_0x5c904d['filters']=_[_0xb5f8('0x30')](_0x5c904d[_0xb5f8('0x2d')],_0x5c904d[_0xb5f8('0x2e')]);_0x1b91cc['attributes']=_[_0xb5f8('0x30')](_0x5c904d['model'],qs[_0xb5f8('0x32')](_0x51c1e9[_0xb5f8('0x2e')][_0xb5f8('0x32')]));_0x1b91cc['attributes']=_0x1b91cc['attributes'][_0xb5f8('0x44')]?_0x1b91cc[_0xb5f8('0x31')]:_0x5c904d[_0xb5f8('0x2d')];_0x1b91cc[_0xb5f8('0x35')]=qs['sort'](_0x51c1e9[_0xb5f8('0x2e')][_0xb5f8('0x36')]);_0x1b91cc[_0xb5f8('0x38')]=qs['filters'](_[_0xb5f8('0x37')](_0x51c1e9[_0xb5f8('0x2e')],_0x5c904d[_0xb5f8('0x43')]));if(_0x51c1e9[_0xb5f8('0x2e')][_0xb5f8('0x3b')]){_0x1b91cc[_0xb5f8('0x38')]=_[_0xb5f8('0x39')](_0x1b91cc[_0xb5f8('0x38')],{'$or':_[_0xb5f8('0x28')](_0x1b91cc[_0xb5f8('0x31')],function(_0x5183e8){var _0x5bc844={};_0x5bc844[_0x5183e8]={'$like':'%'+_0x51c1e9['query'][_0xb5f8('0x3b')]+'%'};return _0x5bc844;})});}_0x1b91cc=_[_0xb5f8('0x39')]({},_0x1b91cc,_0x51c1e9[_0xb5f8('0x3c')]);return _0x4e7d3c[_0xb5f8('0x4c')](_0x1b91cc);}})['then'](function(_0x2fb410){if(_0x2fb410){_0x5a8e98=_0x2fb410[_0xb5f8('0x44')];if(!_0x51c1e9[_0xb5f8('0x2e')][_0xb5f8('0x33')]('nolimit')){_0x1b91cc[_0xb5f8('0x1b')]=qs[_0xb5f8('0x1b')](_0x51c1e9[_0xb5f8('0x2e')][_0xb5f8('0x1b')]);_0x1b91cc[_0xb5f8('0x19')]=qs[_0xb5f8('0x19')](_0x51c1e9['query'][_0xb5f8('0x19')]);}return _0x4e7d3c['getSubjects'](_0x1b91cc);}})[_0xb5f8('0x24')](function(_0x535d36){if(_0x535d36){return _0x535d36?{'count':_0x5a8e98,'rows':_0x535d36}:null;}})['then'](respondWithResult(_0xa0b763,null))[_0xb5f8('0x40')](handleError(_0xa0b763,null));};exports[_0xb5f8('0x4d')]=function(_0x352540,_0x6925f,_0x4312fd){var _0x3b8449={};var _0x92b0d0={};var _0x4ff02b;var _0x357858;return db[_0xb5f8('0x29')][_0xb5f8('0x4a')]({'where':{'id':_0x352540[_0xb5f8('0x42')]['id']}})[_0xb5f8('0x24')](handleEntityNotFound(_0x6925f,null))[_0xb5f8('0x24')](function(_0x15237a){if(_0x15237a){_0x4ff02b=_0x15237a;_0x92b0d0['model']=_['keys'](db[_0xb5f8('0x4b')][_0xb5f8('0x2a')]);_0x92b0d0[_0xb5f8('0x2e')]=_[_0xb5f8('0x2f')](_0x352540[_0xb5f8('0x2e')]);_0x92b0d0[_0xb5f8('0x43')]=_['intersection'](_0x92b0d0['model'],_0x92b0d0['query']);_0x3b8449[_0xb5f8('0x31')]=_[_0xb5f8('0x30')](_0x92b0d0[_0xb5f8('0x2d')],qs[_0xb5f8('0x32')](_0x352540[_0xb5f8('0x2e')][_0xb5f8('0x32')]));_0x3b8449[_0xb5f8('0x31')]=_0x3b8449[_0xb5f8('0x31')][_0xb5f8('0x44')]?_0x3b8449['attributes']:_0x92b0d0[_0xb5f8('0x2d')];_0x3b8449[_0xb5f8('0x35')]=qs['sort'](_0x352540['query']['sort']);_0x3b8449[_0xb5f8('0x38')]=qs[_0xb5f8('0x43')](_[_0xb5f8('0x37')](_0x352540['query'],_0x92b0d0[_0xb5f8('0x43')]));if(_0x352540['query']['filter']){_0x3b8449['where']=_['merge'](_0x3b8449['where'],{'$or':_[_0xb5f8('0x28')](_0x3b8449[_0xb5f8('0x31')],function(_0x469749){var _0x1069c1={};_0x1069c1[_0x469749]={'$like':'%'+_0x352540[_0xb5f8('0x2e')][_0xb5f8('0x3b')]+'%'};return _0x1069c1;})});}_0x3b8449=_['merge']({},_0x3b8449,_0x352540['options']);return _0x4ff02b[_0xb5f8('0x4d')](_0x3b8449);}})[_0xb5f8('0x24')](function(_0xe61766){if(_0xe61766){_0x357858=_0xe61766['length'];if(!_0x352540['query'][_0xb5f8('0x33')](_0xb5f8('0x34'))){_0x3b8449[_0xb5f8('0x1b')]=qs[_0xb5f8('0x1b')](_0x352540[_0xb5f8('0x2e')][_0xb5f8('0x1b')]);_0x3b8449[_0xb5f8('0x19')]=qs[_0xb5f8('0x19')](_0x352540[_0xb5f8('0x2e')]['offset']);}return _0x4ff02b[_0xb5f8('0x4d')](_0x3b8449);}})[_0xb5f8('0x24')](function(_0x5632f4){if(_0x5632f4){return _0x5632f4?{'count':_0x357858,'rows':_0x5632f4}:null;}})[_0xb5f8('0x24')](respondWithResult(_0x6925f,null))[_0xb5f8('0x40')](handleError(_0x6925f,null));};exports[_0xb5f8('0x4e')]=function(_0x1fed81,_0xe567b8,_0x497efa){var _0x115c99={};var _0x33e223={};var _0x533916;var _0x234baf;return db[_0xb5f8('0x29')][_0xb5f8('0x4a')]({'where':{'id':_0x1fed81['params']['id']}})[_0xb5f8('0x24')](handleEntityNotFound(_0xe567b8,null))[_0xb5f8('0x24')](function(_0x18e350){if(_0x18e350){_0x533916=_0x18e350;_0x33e223['model']=_[_0xb5f8('0x2f')](db[_0xb5f8('0x4f')]['rawAttributes']);_0x33e223[_0xb5f8('0x2e')]=_[_0xb5f8('0x2f')](_0x1fed81[_0xb5f8('0x2e')]);_0x33e223[_0xb5f8('0x43')]=_[_0xb5f8('0x30')](_0x33e223[_0xb5f8('0x2d')],_0x33e223['query']);_0x115c99[_0xb5f8('0x31')]=_[_0xb5f8('0x30')](_0x33e223[_0xb5f8('0x2d')],qs[_0xb5f8('0x32')](_0x1fed81[_0xb5f8('0x2e')]['fields']));_0x115c99[_0xb5f8('0x31')]=_0x115c99['attributes'][_0xb5f8('0x44')]?_0x115c99[_0xb5f8('0x31')]:_0x33e223[_0xb5f8('0x2d')];_0x115c99['order']=qs[_0xb5f8('0x36')](_0x1fed81[_0xb5f8('0x2e')][_0xb5f8('0x36')]);_0x115c99[_0xb5f8('0x38')]=qs[_0xb5f8('0x43')](_[_0xb5f8('0x37')](_0x1fed81[_0xb5f8('0x2e')],_0x33e223['filters']));if(_0x1fed81[_0xb5f8('0x2e')]['filter']){_0x115c99[_0xb5f8('0x38')]=_[_0xb5f8('0x39')](_0x115c99[_0xb5f8('0x38')],{'$or':_[_0xb5f8('0x28')](_0x115c99[_0xb5f8('0x31')],function(_0x16b47c){var _0x20eb50={};_0x20eb50[_0x16b47c]={'$like':'%'+_0x1fed81[_0xb5f8('0x2e')][_0xb5f8('0x3b')]+'%'};return _0x20eb50;})});}_0x115c99=_['merge']({},_0x115c99,_0x1fed81['options']);return _0x533916[_0xb5f8('0x4e')](_0x115c99);}})[_0xb5f8('0x24')](function(_0xf231){if(_0xf231){_0x234baf=_0xf231[_0xb5f8('0x44')];if(!_0x1fed81['query'][_0xb5f8('0x33')]('nolimit')){_0x115c99['limit']=qs[_0xb5f8('0x1b')](_0x1fed81[_0xb5f8('0x2e')][_0xb5f8('0x1b')]);_0x115c99[_0xb5f8('0x19')]=qs[_0xb5f8('0x19')](_0x1fed81[_0xb5f8('0x2e')]['offset']);}return _0x533916[_0xb5f8('0x4e')](_0x115c99);}})[_0xb5f8('0x24')](function(_0x2eade7){if(_0x2eade7){return _0x2eade7?{'count':_0x234baf,'rows':_0x2eade7}:null;}})[_0xb5f8('0x24')](respondWithResult(_0xe567b8,null))[_0xb5f8('0x40')](handleError(_0xe567b8,null));};exports[_0xb5f8('0x50')]=function(_0x32c73f,_0x115a22,_0x576355){if(_0x32c73f[_0xb5f8('0x47')]['id']){delete _0x32c73f[_0xb5f8('0x47')]['id'];}return db['ZendeskConfiguration'][_0xb5f8('0x4a')]({'where':{'id':_0x32c73f[_0xb5f8('0x42')]['id']}})[_0xb5f8('0x24')](handleEntityNotFound(_0x115a22,null))[_0xb5f8('0x24')](function(_0x1567b0){if(_0x1567b0){return _0x1567b0[_0xb5f8('0x50')](_0x32c73f[_0xb5f8('0x47')]['ids']||[]);}return null;})[_0xb5f8('0x24')](respondWithResult(_0x115a22,null))[_0xb5f8('0x40')](handleError(_0x115a22,null));};