Built motion from commit (unavailable).|2.5.30
[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 _0x1cc9=['jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/environment','../../config/license/util','jayson/promise','http','request','info','ZendeskConfiguration,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','sendStatus','end','status','json','offset','undefined','count','apply','reject','save','update','then','destroy','stack','name','send','index','map','rawAttributes','fieldName','type','key','query','keys','attributes','intersection','model','fields','length','nolimit','limit','order','sort','where','filters','pick','filter','VIRTUAL','merge','ZendeskConfiguration','includeAll','include','findAll','rows','show','params','options','find','create','body','getFields','ZendeskField','hasOwnProperty','getSubjects','findOne','getDescriptions','getTags','Tag','setTags','rimraf','request-promise','util','sox','to-csv','ejs','fs-extra','lodash','squel'];(function(_0x894b6,_0x5f1511){var _0x1d09d5=function(_0x3ce3cf){while(--_0x3ce3cf){_0x894b6['push'](_0x894b6['shift']());}};_0x1d09d5(++_0x5f1511);}(_0x1cc9,0x102));var _0x91cc=function(_0x57f5bc,_0x64e046){_0x57f5bc=_0x57f5bc-0x0;var _0x1dfba2=_0x1cc9[_0x57f5bc];return _0x1dfba2;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x91cc('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x91cc('0x1'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x91cc('0x2'));var path=require('path');var sox=require(_0x91cc('0x3'));var csv=require(_0x91cc('0x4'));var ejs=require(_0x91cc('0x5'));var fs=require('fs');var fs_extra=require(_0x91cc('0x6'));var _=require(_0x91cc('0x7'));var squel=require(_0x91cc('0x8'));var crypto=require('crypto');var jsforce=require(_0x91cc('0x9'));var deskjs=require(_0x91cc('0xa'));var toCsv=require('to-csv');var querystring=require(_0x91cc('0xb'));var Papa=require(_0x91cc('0xc'));var Redis=require(_0x91cc('0xd'));var authService=require(_0x91cc('0xe'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x91cc('0xf'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x91cc('0x10'));var licenseUtil=require(_0x91cc('0x11'));var db=require('../../mysqldb')['db'];var jayson=require(_0x91cc('0x12'));var client=jayson['client'][_0x91cc('0x13')]({'port':0x232a});function respondWithRpcPromise(_0x144ac2,_0x2da247,_0x27720f,_0x5bd667){return new BPromise(function(_0x464897,_0x3b3d15){var _0xdb674a=_0x5bd667||client;return _0xdb674a[_0x91cc('0x14')](_0x144ac2,_0x27720f)['then'](function(_0x1ad7fe){logger[_0x91cc('0x15')](_0x91cc('0x16'),_0x2da247,_0x91cc('0x17'));logger['debug']('ZendeskConfiguration,\x20%s,\x20%s,\x20%s',_0x2da247,_0x91cc('0x17'),JSON[_0x91cc('0x18')](_0x1ad7fe));if(_0x1ad7fe[_0x91cc('0x19')]){if(_0x1ad7fe[_0x91cc('0x19')][_0x91cc('0x1a')]===0x1f4){logger[_0x91cc('0x19')]('ZendeskConfiguration,\x20%s,\x20%s',_0x2da247,_0x1ad7fe[_0x91cc('0x19')]['message']);return _0x3b3d15(_0x1ad7fe[_0x91cc('0x19')][_0x91cc('0x1b')]);}logger[_0x91cc('0x19')]('ZendeskConfiguration,\x20%s,\x20%s',_0x2da247,_0x1ad7fe['error'][_0x91cc('0x1b')]);return _0x464897(_0x1ad7fe[_0x91cc('0x19')]['message']);}else{logger['info']('ZendeskConfiguration,\x20%s,\x20%s',_0x2da247,_0x91cc('0x17'));_0x464897(_0x1ad7fe[_0x91cc('0x1c')]['message']);}})[_0x91cc('0x1d')](function(_0x58f922){logger[_0x91cc('0x19')](_0x91cc('0x16'),_0x2da247,_0x58f922);_0x3b3d15(_0x58f922);});});}function respondWithStatusCode(_0xd4cb04,_0x327569){_0x327569=_0x327569||0xcc;return function(_0x4cc59e){if(_0x4cc59e){return _0xd4cb04[_0x91cc('0x1e')](_0x327569);}return _0xd4cb04['status'](_0x327569)[_0x91cc('0x1f')]();};}function respondWithResult(_0x275e77,_0x2871a6){_0x2871a6=_0x2871a6||0xc8;return function(_0x5cf52b){if(_0x5cf52b){return _0x275e77[_0x91cc('0x20')](_0x2871a6)[_0x91cc('0x21')](_0x5cf52b);}};}function respondWithFilteredResult(_0x51f559,_0xaa0866){return function(_0x35f9ca){if(_0x35f9ca){var _0x13cd97=typeof _0xaa0866[_0x91cc('0x22')]===_0x91cc('0x23')&&typeof _0xaa0866['limit']===_0x91cc('0x23');var _0x522a05=_0x35f9ca[_0x91cc('0x24')];var _0x1f794c=_0x13cd97?0x0:_0xaa0866[_0x91cc('0x22')];var _0x59f58d=_0x13cd97?_0x35f9ca[_0x91cc('0x24')]:_0xaa0866[_0x91cc('0x22')]+_0xaa0866['limit'];var _0x573acb;if(_0x59f58d>=_0x522a05){_0x59f58d=_0x522a05;_0x573acb=0xc8;}else{_0x573acb=0xce;}_0x51f559[_0x91cc('0x20')](_0x573acb);return _0x51f559['set']('Content-Range',_0x1f794c+'-'+_0x59f58d+'/'+_0x522a05)[_0x91cc('0x21')](_0x35f9ca);}return null;};}function patchUpdates(_0x13dceb){return function(_0x20bd1a){try{jsonpatch[_0x91cc('0x25')](_0x20bd1a,_0x13dceb,!![]);}catch(_0x10abcb){return BPromise[_0x91cc('0x26')](_0x10abcb);}return _0x20bd1a[_0x91cc('0x27')]();};}function saveUpdates(_0x32ae23,_0x3a2bf8){return function(_0x2c4e9c){if(_0x2c4e9c){return _0x2c4e9c[_0x91cc('0x28')](_0x32ae23)[_0x91cc('0x29')](function(_0x15a20f){return _0x15a20f;});}return null;};}function removeEntity(_0xfae1cb,_0x197071){return function(_0x417928){if(_0x417928){return _0x417928[_0x91cc('0x2a')]()[_0x91cc('0x29')](function(){_0xfae1cb[_0x91cc('0x20')](0xcc)[_0x91cc('0x1f')]();});}};}function handleEntityNotFound(_0x2a645f,_0x5e5e64){return function(_0x2141c9){if(!_0x2141c9){_0x2a645f[_0x91cc('0x1e')](0x194);}return _0x2141c9;};}function handleError(_0x16f591,_0x506f87){_0x506f87=_0x506f87||0x1f4;return function(_0x2d8bf8){logger['error'](_0x2d8bf8[_0x91cc('0x2b')]);if(_0x2d8bf8[_0x91cc('0x2c')]){delete _0x2d8bf8[_0x91cc('0x2c')];}_0x16f591['status'](_0x506f87)[_0x91cc('0x2d')](_0x2d8bf8);};}exports[_0x91cc('0x2e')]=function(_0x38dff8,_0x496c4e){var _0x4a871c={},_0x3d79d8={},_0x1c73e4={'count':0x0,'rows':[]};var _0x168773=_[_0x91cc('0x2f')](db['ZendeskConfiguration'][_0x91cc('0x30')],function(_0x4724cb){return{'name':_0x4724cb[_0x91cc('0x31')],'type':_0x4724cb[_0x91cc('0x32')][_0x91cc('0x33')]};});_0x3d79d8['model']=_[_0x91cc('0x2f')](_0x168773,_0x91cc('0x2c'));_0x3d79d8[_0x91cc('0x34')]=_[_0x91cc('0x35')](_0x38dff8[_0x91cc('0x34')]);_0x3d79d8['filters']=_['intersection'](_0x3d79d8['model'],_0x3d79d8['query']);_0x4a871c[_0x91cc('0x36')]=_[_0x91cc('0x37')](_0x3d79d8[_0x91cc('0x38')],qs['fields'](_0x38dff8['query'][_0x91cc('0x39')]));_0x4a871c[_0x91cc('0x36')]=_0x4a871c['attributes'][_0x91cc('0x3a')]?_0x4a871c[_0x91cc('0x36')]:_0x3d79d8[_0x91cc('0x38')];if(!_0x38dff8[_0x91cc('0x34')]['hasOwnProperty'](_0x91cc('0x3b'))){_0x4a871c[_0x91cc('0x3c')]=qs['limit'](_0x38dff8['query'][_0x91cc('0x3c')]);_0x4a871c[_0x91cc('0x22')]=qs[_0x91cc('0x22')](_0x38dff8[_0x91cc('0x34')][_0x91cc('0x22')]);}_0x4a871c[_0x91cc('0x3d')]=qs['sort'](_0x38dff8[_0x91cc('0x34')][_0x91cc('0x3e')]);_0x4a871c[_0x91cc('0x3f')]=qs[_0x91cc('0x40')](_[_0x91cc('0x41')](_0x38dff8['query'],_0x3d79d8[_0x91cc('0x40')]),_0x168773);if(_0x38dff8[_0x91cc('0x34')][_0x91cc('0x42')]){_0x4a871c['where']=_['merge'](_0x4a871c['where'],{'$or':_[_0x91cc('0x2f')](_0x168773,function(_0x1d20e8){if(_0x1d20e8['type']!==_0x91cc('0x43')){var _0x30c110={};_0x30c110[_0x1d20e8[_0x91cc('0x2c')]]={'$like':'%'+_0x38dff8['query'][_0x91cc('0x42')]+'%'};return _0x30c110;}})});}_0x4a871c=_[_0x91cc('0x44')]({},_0x4a871c,_0x38dff8['options']);var _0xabf8c8={'where':_0x4a871c[_0x91cc('0x3f')]};return db[_0x91cc('0x45')][_0x91cc('0x24')](_0xabf8c8)[_0x91cc('0x29')](function(_0x4b61ab){_0x1c73e4[_0x91cc('0x24')]=_0x4b61ab;if(_0x38dff8[_0x91cc('0x34')][_0x91cc('0x46')]){_0x4a871c[_0x91cc('0x47')]=[{'all':!![]}];}return db[_0x91cc('0x45')][_0x91cc('0x48')](_0x4a871c);})[_0x91cc('0x29')](function(_0x1f4a2d){_0x1c73e4[_0x91cc('0x49')]=_0x1f4a2d;return _0x1c73e4;})[_0x91cc('0x29')](respondWithFilteredResult(_0x496c4e,_0x4a871c))[_0x91cc('0x1d')](handleError(_0x496c4e,null));};exports[_0x91cc('0x4a')]=function(_0x5942bc,_0x58a9db){var _0x350c12={'raw':![],'where':{'id':_0x5942bc[_0x91cc('0x4b')]['id']}},_0x1b0183={};_0x1b0183['model']=_[_0x91cc('0x35')](db[_0x91cc('0x45')]['rawAttributes']);_0x1b0183[_0x91cc('0x34')]=_['keys'](_0x5942bc[_0x91cc('0x34')]);_0x1b0183[_0x91cc('0x40')]=_[_0x91cc('0x37')](_0x1b0183[_0x91cc('0x38')],_0x1b0183[_0x91cc('0x34')]);_0x350c12[_0x91cc('0x36')]=_[_0x91cc('0x37')](_0x1b0183['model'],qs[_0x91cc('0x39')](_0x5942bc[_0x91cc('0x34')][_0x91cc('0x39')]));_0x350c12[_0x91cc('0x36')]=_0x350c12[_0x91cc('0x36')]['length']?_0x350c12['attributes']:_0x1b0183['model'];if(_0x5942bc[_0x91cc('0x34')]['includeAll']){_0x350c12[_0x91cc('0x47')]=[{'all':!![]}];}_0x350c12=_[_0x91cc('0x44')]({},_0x350c12,_0x5942bc[_0x91cc('0x4c')]);return db[_0x91cc('0x45')][_0x91cc('0x4d')](_0x350c12)[_0x91cc('0x29')](handleEntityNotFound(_0x58a9db,null))[_0x91cc('0x29')](respondWithResult(_0x58a9db,null))[_0x91cc('0x1d')](handleError(_0x58a9db,null));};exports[_0x91cc('0x4e')]=function(_0x5c77ed,_0x3d7069){return db[_0x91cc('0x45')]['create'](_0x5c77ed[_0x91cc('0x4f')],{})[_0x91cc('0x29')](respondWithResult(_0x3d7069,0xc9))[_0x91cc('0x1d')](handleError(_0x3d7069,null));};exports[_0x91cc('0x28')]=function(_0x21c179,_0x45d0a3){if(_0x21c179[_0x91cc('0x4f')]['id']){delete _0x21c179[_0x91cc('0x4f')]['id'];}return db[_0x91cc('0x45')][_0x91cc('0x4d')]({'where':{'id':_0x21c179[_0x91cc('0x4b')]['id']}})[_0x91cc('0x29')](handleEntityNotFound(_0x45d0a3,null))[_0x91cc('0x29')](saveUpdates(_0x21c179[_0x91cc('0x4f')],null))['then'](respondWithResult(_0x45d0a3,null))[_0x91cc('0x1d')](handleError(_0x45d0a3,null));};exports[_0x91cc('0x2a')]=function(_0x14ad80,_0x38a7f5){return db['ZendeskConfiguration']['find']({'where':{'id':_0x14ad80[_0x91cc('0x4b')]['id']}})[_0x91cc('0x29')](handleEntityNotFound(_0x38a7f5,null))[_0x91cc('0x29')](removeEntity(_0x38a7f5,null))[_0x91cc('0x1d')](handleError(_0x38a7f5,null));};exports[_0x91cc('0x50')]=function(_0x36f4bf,_0x2337f7,_0x1adc5e){var _0x278d79={};var _0x53569e={};var _0x1778e;var _0x5d73f4;return db[_0x91cc('0x45')]['findOne']({'where':{'id':_0x36f4bf['params']['id']}})[_0x91cc('0x29')](handleEntityNotFound(_0x2337f7,null))[_0x91cc('0x29')](function(_0x1a040d){if(_0x1a040d){_0x1778e=_0x1a040d;_0x53569e[_0x91cc('0x38')]=_['keys'](db[_0x91cc('0x51')]['rawAttributes']);_0x53569e[_0x91cc('0x34')]=_[_0x91cc('0x35')](_0x36f4bf['query']);_0x53569e[_0x91cc('0x40')]=_['intersection'](_0x53569e[_0x91cc('0x38')],_0x53569e[_0x91cc('0x34')]);_0x278d79['attributes']=_[_0x91cc('0x37')](_0x53569e[_0x91cc('0x38')],qs[_0x91cc('0x39')](_0x36f4bf['query']['fields']));_0x278d79[_0x91cc('0x36')]=_0x278d79[_0x91cc('0x36')][_0x91cc('0x3a')]?_0x278d79[_0x91cc('0x36')]:_0x53569e[_0x91cc('0x38')];_0x278d79[_0x91cc('0x3d')]=qs[_0x91cc('0x3e')](_0x36f4bf[_0x91cc('0x34')][_0x91cc('0x3e')]);_0x278d79['where']=qs['filters'](_[_0x91cc('0x41')](_0x36f4bf[_0x91cc('0x34')],_0x53569e['filters']));if(_0x36f4bf[_0x91cc('0x34')][_0x91cc('0x42')]){_0x278d79[_0x91cc('0x3f')]=_[_0x91cc('0x44')](_0x278d79[_0x91cc('0x3f')],{'$or':_[_0x91cc('0x2f')](_0x278d79[_0x91cc('0x36')],function(_0x3f20f9){var _0x595c41={};_0x595c41[_0x3f20f9]={'$like':'%'+_0x36f4bf['query'][_0x91cc('0x42')]+'%'};return _0x595c41;})});}_0x278d79=_['merge']({},_0x278d79,_0x36f4bf[_0x91cc('0x4c')]);return _0x1778e['getFields'](_0x278d79);}})[_0x91cc('0x29')](function(_0x18df24){if(_0x18df24){_0x5d73f4=_0x18df24[_0x91cc('0x3a')];if(!_0x36f4bf[_0x91cc('0x34')][_0x91cc('0x52')](_0x91cc('0x3b'))){_0x278d79[_0x91cc('0x3c')]=qs[_0x91cc('0x3c')](_0x36f4bf[_0x91cc('0x34')][_0x91cc('0x3c')]);_0x278d79['offset']=qs[_0x91cc('0x22')](_0x36f4bf[_0x91cc('0x34')][_0x91cc('0x22')]);}return _0x1778e[_0x91cc('0x50')](_0x278d79);}})[_0x91cc('0x29')](function(_0x321f46){if(_0x321f46){return _0x321f46?{'count':_0x5d73f4,'rows':_0x321f46}:null;}})[_0x91cc('0x29')](respondWithResult(_0x2337f7,null))['catch'](handleError(_0x2337f7,null));};exports[_0x91cc('0x53')]=function(_0xf9545,_0x57eadb,_0x58322c){var _0x17cb13={};var _0x254d06={};var _0x573c41;var _0x1a4cb6;return db[_0x91cc('0x45')][_0x91cc('0x54')]({'where':{'id':_0xf9545['params']['id']}})[_0x91cc('0x29')](handleEntityNotFound(_0x57eadb,null))['then'](function(_0x1f23fd){if(_0x1f23fd){_0x573c41=_0x1f23fd;_0x254d06[_0x91cc('0x38')]=_['keys'](db[_0x91cc('0x51')][_0x91cc('0x30')]);_0x254d06[_0x91cc('0x34')]=_[_0x91cc('0x35')](_0xf9545[_0x91cc('0x34')]);_0x254d06['filters']=_[_0x91cc('0x37')](_0x254d06[_0x91cc('0x38')],_0x254d06[_0x91cc('0x34')]);_0x17cb13['attributes']=_[_0x91cc('0x37')](_0x254d06[_0x91cc('0x38')],qs[_0x91cc('0x39')](_0xf9545[_0x91cc('0x34')]['fields']));_0x17cb13['attributes']=_0x17cb13['attributes'][_0x91cc('0x3a')]?_0x17cb13[_0x91cc('0x36')]:_0x254d06['model'];_0x17cb13[_0x91cc('0x3d')]=qs[_0x91cc('0x3e')](_0xf9545[_0x91cc('0x34')][_0x91cc('0x3e')]);_0x17cb13[_0x91cc('0x3f')]=qs[_0x91cc('0x40')](_[_0x91cc('0x41')](_0xf9545['query'],_0x254d06[_0x91cc('0x40')]));if(_0xf9545[_0x91cc('0x34')][_0x91cc('0x42')]){_0x17cb13[_0x91cc('0x3f')]=_[_0x91cc('0x44')](_0x17cb13['where'],{'$or':_['map'](_0x17cb13[_0x91cc('0x36')],function(_0x1f0f88){var _0x1dd2f5={};_0x1dd2f5[_0x1f0f88]={'$like':'%'+_0xf9545['query']['filter']+'%'};return _0x1dd2f5;})});}_0x17cb13=_[_0x91cc('0x44')]({},_0x17cb13,_0xf9545[_0x91cc('0x4c')]);return _0x573c41[_0x91cc('0x53')](_0x17cb13);}})[_0x91cc('0x29')](function(_0x727c7){if(_0x727c7){_0x1a4cb6=_0x727c7[_0x91cc('0x3a')];if(!_0xf9545[_0x91cc('0x34')][_0x91cc('0x52')](_0x91cc('0x3b'))){_0x17cb13[_0x91cc('0x3c')]=qs[_0x91cc('0x3c')](_0xf9545[_0x91cc('0x34')]['limit']);_0x17cb13[_0x91cc('0x22')]=qs[_0x91cc('0x22')](_0xf9545[_0x91cc('0x34')][_0x91cc('0x22')]);}return _0x573c41[_0x91cc('0x53')](_0x17cb13);}})[_0x91cc('0x29')](function(_0x4d8282){if(_0x4d8282){return _0x4d8282?{'count':_0x1a4cb6,'rows':_0x4d8282}:null;}})['then'](respondWithResult(_0x57eadb,null))[_0x91cc('0x1d')](handleError(_0x57eadb,null));};exports[_0x91cc('0x55')]=function(_0x3e7329,_0x4a0bc0,_0x3708e5){var _0x1dd860={};var _0x42af01={};var _0x54d364;var _0x3e5c42;return db['ZendeskConfiguration'][_0x91cc('0x54')]({'where':{'id':_0x3e7329['params']['id']}})[_0x91cc('0x29')](handleEntityNotFound(_0x4a0bc0,null))[_0x91cc('0x29')](function(_0x3b12c0){if(_0x3b12c0){_0x54d364=_0x3b12c0;_0x42af01[_0x91cc('0x38')]=_[_0x91cc('0x35')](db['ZendeskField'][_0x91cc('0x30')]);_0x42af01[_0x91cc('0x34')]=_['keys'](_0x3e7329['query']);_0x42af01[_0x91cc('0x40')]=_[_0x91cc('0x37')](_0x42af01[_0x91cc('0x38')],_0x42af01['query']);_0x1dd860['attributes']=_[_0x91cc('0x37')](_0x42af01[_0x91cc('0x38')],qs[_0x91cc('0x39')](_0x3e7329[_0x91cc('0x34')][_0x91cc('0x39')]));_0x1dd860[_0x91cc('0x36')]=_0x1dd860[_0x91cc('0x36')][_0x91cc('0x3a')]?_0x1dd860[_0x91cc('0x36')]:_0x42af01['model'];_0x1dd860['order']=qs[_0x91cc('0x3e')](_0x3e7329[_0x91cc('0x34')]['sort']);_0x1dd860[_0x91cc('0x3f')]=qs[_0x91cc('0x40')](_[_0x91cc('0x41')](_0x3e7329['query'],_0x42af01[_0x91cc('0x40')]));if(_0x3e7329[_0x91cc('0x34')]['filter']){_0x1dd860[_0x91cc('0x3f')]=_[_0x91cc('0x44')](_0x1dd860['where'],{'$or':_[_0x91cc('0x2f')](_0x1dd860[_0x91cc('0x36')],function(_0x3e243c){var _0x283621={};_0x283621[_0x3e243c]={'$like':'%'+_0x3e7329['query']['filter']+'%'};return _0x283621;})});}_0x1dd860=_[_0x91cc('0x44')]({},_0x1dd860,_0x3e7329[_0x91cc('0x4c')]);return _0x54d364[_0x91cc('0x55')](_0x1dd860);}})[_0x91cc('0x29')](function(_0x1a4c64){if(_0x1a4c64){_0x3e5c42=_0x1a4c64[_0x91cc('0x3a')];if(!_0x3e7329[_0x91cc('0x34')][_0x91cc('0x52')](_0x91cc('0x3b'))){_0x1dd860[_0x91cc('0x3c')]=qs[_0x91cc('0x3c')](_0x3e7329[_0x91cc('0x34')][_0x91cc('0x3c')]);_0x1dd860[_0x91cc('0x22')]=qs[_0x91cc('0x22')](_0x3e7329['query'][_0x91cc('0x22')]);}return _0x54d364[_0x91cc('0x55')](_0x1dd860);}})[_0x91cc('0x29')](function(_0x4c39d7){if(_0x4c39d7){return _0x4c39d7?{'count':_0x3e5c42,'rows':_0x4c39d7}:null;}})['then'](respondWithResult(_0x4a0bc0,null))[_0x91cc('0x1d')](handleError(_0x4a0bc0,null));};exports[_0x91cc('0x56')]=function(_0x5af34e,_0x349d32,_0x719783){var _0x498e67={};var _0x4684c5={};var _0x60b9c6;var _0x5782c6;return db['ZendeskConfiguration'][_0x91cc('0x54')]({'where':{'id':_0x5af34e[_0x91cc('0x4b')]['id']}})[_0x91cc('0x29')](handleEntityNotFound(_0x349d32,null))[_0x91cc('0x29')](function(_0x325f14){if(_0x325f14){_0x60b9c6=_0x325f14;_0x4684c5[_0x91cc('0x38')]=_[_0x91cc('0x35')](db[_0x91cc('0x57')]['rawAttributes']);_0x4684c5['query']=_['keys'](_0x5af34e['query']);_0x4684c5[_0x91cc('0x40')]=_[_0x91cc('0x37')](_0x4684c5[_0x91cc('0x38')],_0x4684c5[_0x91cc('0x34')]);_0x498e67[_0x91cc('0x36')]=_[_0x91cc('0x37')](_0x4684c5[_0x91cc('0x38')],qs[_0x91cc('0x39')](_0x5af34e[_0x91cc('0x34')][_0x91cc('0x39')]));_0x498e67['attributes']=_0x498e67['attributes'][_0x91cc('0x3a')]?_0x498e67[_0x91cc('0x36')]:_0x4684c5['model'];_0x498e67[_0x91cc('0x3d')]=qs[_0x91cc('0x3e')](_0x5af34e[_0x91cc('0x34')][_0x91cc('0x3e')]);_0x498e67['where']=qs[_0x91cc('0x40')](_['pick'](_0x5af34e[_0x91cc('0x34')],_0x4684c5[_0x91cc('0x40')]));if(_0x5af34e[_0x91cc('0x34')][_0x91cc('0x42')]){_0x498e67[_0x91cc('0x3f')]=_[_0x91cc('0x44')](_0x498e67[_0x91cc('0x3f')],{'$or':_[_0x91cc('0x2f')](_0x498e67[_0x91cc('0x36')],function(_0x34ecd6){var _0x3c6a71={};_0x3c6a71[_0x34ecd6]={'$like':'%'+_0x5af34e[_0x91cc('0x34')][_0x91cc('0x42')]+'%'};return _0x3c6a71;})});}_0x498e67=_[_0x91cc('0x44')]({},_0x498e67,_0x5af34e[_0x91cc('0x4c')]);return _0x60b9c6['getTags'](_0x498e67);}})[_0x91cc('0x29')](function(_0x2447d7){if(_0x2447d7){_0x5782c6=_0x2447d7[_0x91cc('0x3a')];if(!_0x5af34e[_0x91cc('0x34')][_0x91cc('0x52')](_0x91cc('0x3b'))){_0x498e67[_0x91cc('0x3c')]=qs[_0x91cc('0x3c')](_0x5af34e['query'][_0x91cc('0x3c')]);_0x498e67[_0x91cc('0x22')]=qs[_0x91cc('0x22')](_0x5af34e[_0x91cc('0x34')][_0x91cc('0x22')]);}return _0x60b9c6[_0x91cc('0x56')](_0x498e67);}})[_0x91cc('0x29')](function(_0x82a695){if(_0x82a695){return _0x82a695?{'count':_0x5782c6,'rows':_0x82a695}:null;}})[_0x91cc('0x29')](respondWithResult(_0x349d32,null))[_0x91cc('0x1d')](handleError(_0x349d32,null));};exports[_0x91cc('0x58')]=function(_0x1ca82e,_0x5de2c5,_0x269ec3){if(_0x1ca82e[_0x91cc('0x4f')]['id']){delete _0x1ca82e[_0x91cc('0x4f')]['id'];}return db[_0x91cc('0x45')][_0x91cc('0x54')]({'where':{'id':_0x1ca82e[_0x91cc('0x4b')]['id']}})['then'](handleEntityNotFound(_0x5de2c5,null))[_0x91cc('0x29')](function(_0x3d7a8f){if(_0x3d7a8f){return _0x3d7a8f[_0x91cc('0x58')](_0x1ca82e[_0x91cc('0x4f')]['ids']||[]);}return null;})['then'](respondWithResult(_0x5de2c5,null))[_0x91cc('0x1d')](handleError(_0x5de2c5,null));};