Built motion from commit (unavailable).|2.5.24
[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 _0xcf5f=['filter','where','merge','VIRTUAL','options','includeAll','ZendeskConfiguration','findAll','params','include','find','create','body','getFields','order','getSubjects','ZendeskField','findOne','getDescriptions','getTags','Tag','setTags','ids','html-pdf','rimraf','fast-json-patch','request-promise','mustache','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','request','then','info','request\x20sent','debug','ZendeskConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','ZendeskConfiguration,\x20%s,\x20%s','message','result','catch','status','end','json','count','offset','set','Content-Range','apply','reject','save','update','destroy','sendStatus','stack','name','send','index','map','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','sort','pick'];(function(_0x3fb166,_0x4eb985){var _0x5e91be=function(_0x53f4d9){while(--_0x53f4d9){_0x3fb166['push'](_0x3fb166['shift']());}};_0x5e91be(++_0x4eb985);}(_0xcf5f,0x12e));var _0xfcf5=function(_0x5a9938,_0x1e8cc8){_0x5a9938=_0x5a9938-0x0;var _0x2de653=_0xcf5f[_0x5a9938];return _0x2de653;};'use strict';var pdf=require(_0xfcf5('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xfcf5('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xfcf5('0x2'));var rp=require(_0xfcf5('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xfcf5('0x4'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0xfcf5('0x5'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xfcf5('0x6'));var squel=require(_0xfcf5('0x7'));var crypto=require(_0xfcf5('0x8'));var jsforce=require(_0xfcf5('0x9'));var deskjs=require(_0xfcf5('0xa'));var toCsv=require(_0xfcf5('0x5'));var querystring=require(_0xfcf5('0xb'));var Papa=require(_0xfcf5('0xc'));var Redis=require(_0xfcf5('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xfcf5('0xe'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xfcf5('0xf'));var logger=require(_0xfcf5('0x10'))(_0xfcf5('0x11'));var utils=require(_0xfcf5('0x12'));var config=require(_0xfcf5('0x13'));var licenseUtil=require(_0xfcf5('0x14'));var db=require(_0xfcf5('0x15'))['db'];var jayson=require(_0xfcf5('0x16'));var client=jayson[_0xfcf5('0x17')]['http']({'port':0x232a});function respondWithRpcPromise(_0xf55d52,_0x41e6fd,_0x5dab1b,_0x3c37b5){return new BPromise(function(_0x1f3cb2,_0x56d60d){var _0x3bb868=_0x3c37b5||client;return _0x3bb868[_0xfcf5('0x18')](_0xf55d52,_0x5dab1b)[_0xfcf5('0x19')](function(_0x103440){logger[_0xfcf5('0x1a')]('ZendeskConfiguration,\x20%s,\x20%s',_0x41e6fd,_0xfcf5('0x1b'));logger[_0xfcf5('0x1c')](_0xfcf5('0x1d'),_0x41e6fd,_0xfcf5('0x1b'),JSON[_0xfcf5('0x1e')](_0x103440));if(_0x103440['error']){if(_0x103440[_0xfcf5('0x1f')]['code']===0x1f4){logger[_0xfcf5('0x1f')](_0xfcf5('0x20'),_0x41e6fd,_0x103440[_0xfcf5('0x1f')][_0xfcf5('0x21')]);return _0x56d60d(_0x103440[_0xfcf5('0x1f')][_0xfcf5('0x21')]);}logger['error'](_0xfcf5('0x20'),_0x41e6fd,_0x103440[_0xfcf5('0x1f')][_0xfcf5('0x21')]);return _0x1f3cb2(_0x103440[_0xfcf5('0x1f')]['message']);}else{logger[_0xfcf5('0x1a')](_0xfcf5('0x20'),_0x41e6fd,'request\x20sent');_0x1f3cb2(_0x103440[_0xfcf5('0x22')][_0xfcf5('0x21')]);}})[_0xfcf5('0x23')](function(_0x474eb9){logger[_0xfcf5('0x1f')]('ZendeskConfiguration,\x20%s,\x20%s',_0x41e6fd,_0x474eb9);_0x56d60d(_0x474eb9);});});}function respondWithStatusCode(_0x3c03d0,_0x3400b8){_0x3400b8=_0x3400b8||0xcc;return function(_0xac53c){if(_0xac53c){return _0x3c03d0['sendStatus'](_0x3400b8);}return _0x3c03d0[_0xfcf5('0x24')](_0x3400b8)[_0xfcf5('0x25')]();};}function respondWithResult(_0x248473,_0x4ff677){_0x4ff677=_0x4ff677||0xc8;return function(_0x156700){if(_0x156700){return _0x248473[_0xfcf5('0x24')](_0x4ff677)[_0xfcf5('0x26')](_0x156700);}};}function respondWithFilteredResult(_0x3b5208,_0x313d9d){return function(_0x57db44){if(_0x57db44){var _0x2f1578=_0x57db44[_0xfcf5('0x27')],_0x3ba717=_0x313d9d[_0xfcf5('0x28')],_0xb5f56e=_0x313d9d['offset']+_0x313d9d['limit'],_0x12c945;if(_0xb5f56e>=_0x2f1578){_0xb5f56e=_0x2f1578;_0x12c945=0xc8;}else{_0x12c945=0xce;}_0x3b5208[_0xfcf5('0x24')](_0x12c945);return _0x3b5208[_0xfcf5('0x29')](_0xfcf5('0x2a'),_0x3ba717+'-'+_0xb5f56e+'/'+_0x2f1578)['json'](_0x57db44);}return null;};}function patchUpdates(_0x27aca6){return function(_0x5d5971){try{jsonpatch[_0xfcf5('0x2b')](_0x5d5971,_0x27aca6,!![]);}catch(_0x351f6d){return BPromise[_0xfcf5('0x2c')](_0x351f6d);}return _0x5d5971[_0xfcf5('0x2d')]();};}function saveUpdates(_0x391172,_0x1ad43d){return function(_0x4dcc4f){if(_0x4dcc4f){return _0x4dcc4f[_0xfcf5('0x2e')](_0x391172)['then'](function(_0x3daa68){return _0x3daa68;});}return null;};}function removeEntity(_0xee020,_0x42f962){return function(_0x12d245){if(_0x12d245){return _0x12d245[_0xfcf5('0x2f')]()[_0xfcf5('0x19')](function(){_0xee020[_0xfcf5('0x24')](0xcc)['end']();});}};}function handleEntityNotFound(_0x235a74,_0x456950){return function(_0x58473f){if(!_0x58473f){_0x235a74[_0xfcf5('0x30')](0x194);}return _0x58473f;};}function handleError(_0x42b873,_0x93c453){_0x93c453=_0x93c453||0x1f4;return function(_0x4c9522){logger['error'](_0x4c9522[_0xfcf5('0x31')]);if(_0x4c9522[_0xfcf5('0x32')]){delete _0x4c9522[_0xfcf5('0x32')];}_0x42b873['status'](_0x93c453)[_0xfcf5('0x33')](_0x4c9522);};}exports[_0xfcf5('0x34')]=function(_0x30009c,_0x2c8097){var _0x4f2d7c={},_0x1ce525={},_0x475baa={'count':0x0,'rows':[]};var _0x44192c=_[_0xfcf5('0x35')](db['ZendeskConfiguration'][_0xfcf5('0x36')],function(_0x4e96f0){return{'name':_0x4e96f0['fieldName'],'type':_0x4e96f0[_0xfcf5('0x37')][_0xfcf5('0x38')]};});_0x1ce525[_0xfcf5('0x39')]=_[_0xfcf5('0x35')](_0x44192c,_0xfcf5('0x32'));_0x1ce525[_0xfcf5('0x3a')]=_[_0xfcf5('0x3b')](_0x30009c[_0xfcf5('0x3a')]);_0x1ce525[_0xfcf5('0x3c')]=_[_0xfcf5('0x3d')](_0x1ce525[_0xfcf5('0x39')],_0x1ce525[_0xfcf5('0x3a')]);_0x4f2d7c[_0xfcf5('0x3e')]=_['intersection'](_0x1ce525[_0xfcf5('0x39')],qs[_0xfcf5('0x3f')](_0x30009c['query'][_0xfcf5('0x3f')]));_0x4f2d7c['attributes']=_0x4f2d7c[_0xfcf5('0x3e')][_0xfcf5('0x40')]?_0x4f2d7c['attributes']:_0x1ce525[_0xfcf5('0x39')];if(!_0x30009c[_0xfcf5('0x3a')][_0xfcf5('0x41')](_0xfcf5('0x42'))){_0x4f2d7c[_0xfcf5('0x43')]=qs[_0xfcf5('0x43')](_0x30009c[_0xfcf5('0x3a')][_0xfcf5('0x43')]);_0x4f2d7c[_0xfcf5('0x28')]=qs[_0xfcf5('0x28')](_0x30009c[_0xfcf5('0x3a')][_0xfcf5('0x28')]);}_0x4f2d7c['order']=qs[_0xfcf5('0x44')](_0x30009c['query'][_0xfcf5('0x44')]);_0x4f2d7c['where']=qs[_0xfcf5('0x3c')](_[_0xfcf5('0x45')](_0x30009c['query'],_0x1ce525[_0xfcf5('0x3c')]),_0x44192c);if(_0x30009c[_0xfcf5('0x3a')][_0xfcf5('0x46')]){_0x4f2d7c[_0xfcf5('0x47')]=_[_0xfcf5('0x48')](_0x4f2d7c[_0xfcf5('0x47')],{'$or':_['map'](_0x44192c,function(_0xbf4f10){if(_0xbf4f10[_0xfcf5('0x37')]!==_0xfcf5('0x49')){var _0x419064={};_0x419064[_0xbf4f10[_0xfcf5('0x32')]]={'$like':'%'+_0x30009c[_0xfcf5('0x3a')][_0xfcf5('0x46')]+'%'};return _0x419064;}})});}_0x4f2d7c=_[_0xfcf5('0x48')]({},_0x4f2d7c,_0x30009c[_0xfcf5('0x4a')]);var _0x393c54={'where':_0x4f2d7c[_0xfcf5('0x47')]};return db['ZendeskConfiguration']['count'](_0x393c54)[_0xfcf5('0x19')](function(_0x962f06){_0x475baa[_0xfcf5('0x27')]=_0x962f06;if(_0x30009c[_0xfcf5('0x3a')][_0xfcf5('0x4b')]){_0x4f2d7c['include']=[{'all':!![]}];}return db[_0xfcf5('0x4c')][_0xfcf5('0x4d')](_0x4f2d7c);})[_0xfcf5('0x19')](function(_0x26c680){_0x475baa['rows']=_0x26c680;return _0x475baa;})[_0xfcf5('0x19')](respondWithFilteredResult(_0x2c8097,_0x4f2d7c))[_0xfcf5('0x23')](handleError(_0x2c8097,null));};exports['show']=function(_0x92b175,_0x1b56a6){var _0x2641ff={'raw':![],'where':{'id':_0x92b175[_0xfcf5('0x4e')]['id']}},_0x1b8518={};_0x1b8518[_0xfcf5('0x39')]=_[_0xfcf5('0x3b')](db[_0xfcf5('0x4c')][_0xfcf5('0x36')]);_0x1b8518[_0xfcf5('0x3a')]=_[_0xfcf5('0x3b')](_0x92b175[_0xfcf5('0x3a')]);_0x1b8518['filters']=_['intersection'](_0x1b8518[_0xfcf5('0x39')],_0x1b8518[_0xfcf5('0x3a')]);_0x2641ff[_0xfcf5('0x3e')]=_[_0xfcf5('0x3d')](_0x1b8518[_0xfcf5('0x39')],qs[_0xfcf5('0x3f')](_0x92b175[_0xfcf5('0x3a')][_0xfcf5('0x3f')]));_0x2641ff[_0xfcf5('0x3e')]=_0x2641ff[_0xfcf5('0x3e')][_0xfcf5('0x40')]?_0x2641ff[_0xfcf5('0x3e')]:_0x1b8518[_0xfcf5('0x39')];if(_0x92b175[_0xfcf5('0x3a')]['includeAll']){_0x2641ff[_0xfcf5('0x4f')]=[{'all':!![]}];}_0x2641ff=_['merge']({},_0x2641ff,_0x92b175[_0xfcf5('0x4a')]);return db[_0xfcf5('0x4c')][_0xfcf5('0x50')](_0x2641ff)['then'](handleEntityNotFound(_0x1b56a6,null))[_0xfcf5('0x19')](respondWithResult(_0x1b56a6,null))[_0xfcf5('0x23')](handleError(_0x1b56a6,null));};exports['create']=function(_0xed7784,_0x4542d1){return db[_0xfcf5('0x4c')][_0xfcf5('0x51')](_0xed7784['body'],{})['then'](respondWithResult(_0x4542d1,0xc9))['catch'](handleError(_0x4542d1,null));};exports[_0xfcf5('0x2e')]=function(_0x539ccd,_0x7262d6){if(_0x539ccd['body']['id']){delete _0x539ccd['body']['id'];}return db[_0xfcf5('0x4c')]['find']({'where':{'id':_0x539ccd['params']['id']}})[_0xfcf5('0x19')](handleEntityNotFound(_0x7262d6,null))['then'](saveUpdates(_0x539ccd[_0xfcf5('0x52')],null))['then'](respondWithResult(_0x7262d6,null))[_0xfcf5('0x23')](handleError(_0x7262d6,null));};exports['destroy']=function(_0x4e661f,_0x3d74a6){return db[_0xfcf5('0x4c')]['find']({'where':{'id':_0x4e661f['params']['id']}})[_0xfcf5('0x19')](handleEntityNotFound(_0x3d74a6,null))[_0xfcf5('0x19')](removeEntity(_0x3d74a6,null))[_0xfcf5('0x23')](handleError(_0x3d74a6,null));};exports[_0xfcf5('0x53')]=function(_0x5baa2b,_0x236b99,_0x55787a){var _0x52ebab={};var _0x2904ca={};var _0x248963;var _0x1c4260;return db['ZendeskConfiguration']['findOne']({'where':{'id':_0x5baa2b[_0xfcf5('0x4e')]['id']}})[_0xfcf5('0x19')](handleEntityNotFound(_0x236b99,null))[_0xfcf5('0x19')](function(_0x3ed213){if(_0x3ed213){_0x248963=_0x3ed213;_0x2904ca[_0xfcf5('0x39')]=_[_0xfcf5('0x3b')](db['ZendeskField']['rawAttributes']);_0x2904ca[_0xfcf5('0x3a')]=_['keys'](_0x5baa2b[_0xfcf5('0x3a')]);_0x2904ca[_0xfcf5('0x3c')]=_[_0xfcf5('0x3d')](_0x2904ca[_0xfcf5('0x39')],_0x2904ca[_0xfcf5('0x3a')]);_0x52ebab[_0xfcf5('0x3e')]=_[_0xfcf5('0x3d')](_0x2904ca[_0xfcf5('0x39')],qs[_0xfcf5('0x3f')](_0x5baa2b[_0xfcf5('0x3a')][_0xfcf5('0x3f')]));_0x52ebab[_0xfcf5('0x3e')]=_0x52ebab[_0xfcf5('0x3e')][_0xfcf5('0x40')]?_0x52ebab['attributes']:_0x2904ca[_0xfcf5('0x39')];_0x52ebab[_0xfcf5('0x54')]=qs[_0xfcf5('0x44')](_0x5baa2b[_0xfcf5('0x3a')][_0xfcf5('0x44')]);_0x52ebab[_0xfcf5('0x47')]=qs[_0xfcf5('0x3c')](_[_0xfcf5('0x45')](_0x5baa2b[_0xfcf5('0x3a')],_0x2904ca[_0xfcf5('0x3c')]));if(_0x5baa2b['query'][_0xfcf5('0x46')]){_0x52ebab[_0xfcf5('0x47')]=_[_0xfcf5('0x48')](_0x52ebab[_0xfcf5('0x47')],{'$or':_[_0xfcf5('0x35')](_0x52ebab['attributes'],function(_0x2e83d1){var _0x380cd5={};_0x380cd5[_0x2e83d1]={'$like':'%'+_0x5baa2b[_0xfcf5('0x3a')][_0xfcf5('0x46')]+'%'};return _0x380cd5;})});}_0x52ebab=_[_0xfcf5('0x48')]({},_0x52ebab,_0x5baa2b[_0xfcf5('0x4a')]);return _0x248963[_0xfcf5('0x53')](_0x52ebab);}})[_0xfcf5('0x19')](function(_0x585bc2){if(_0x585bc2){_0x1c4260=_0x585bc2[_0xfcf5('0x40')];if(!_0x5baa2b[_0xfcf5('0x3a')][_0xfcf5('0x41')]('nolimit')){_0x52ebab[_0xfcf5('0x43')]=qs[_0xfcf5('0x43')](_0x5baa2b[_0xfcf5('0x3a')][_0xfcf5('0x43')]);_0x52ebab[_0xfcf5('0x28')]=qs[_0xfcf5('0x28')](_0x5baa2b['query']['offset']);}return _0x248963[_0xfcf5('0x53')](_0x52ebab);}})['then'](function(_0xb343ef){if(_0xb343ef){return _0xb343ef?{'count':_0x1c4260,'rows':_0xb343ef}:null;}})[_0xfcf5('0x19')](respondWithResult(_0x236b99,null))[_0xfcf5('0x23')](handleError(_0x236b99,null));};exports[_0xfcf5('0x55')]=function(_0x330ebc,_0xc74f3f,_0x45bd45){var _0x1632bb={};var _0x2a5e9c={};var _0x4a01e1;var _0x2152c9;return db[_0xfcf5('0x4c')]['findOne']({'where':{'id':_0x330ebc[_0xfcf5('0x4e')]['id']}})[_0xfcf5('0x19')](handleEntityNotFound(_0xc74f3f,null))[_0xfcf5('0x19')](function(_0x20634c){if(_0x20634c){_0x4a01e1=_0x20634c;_0x2a5e9c[_0xfcf5('0x39')]=_[_0xfcf5('0x3b')](db[_0xfcf5('0x56')][_0xfcf5('0x36')]);_0x2a5e9c[_0xfcf5('0x3a')]=_[_0xfcf5('0x3b')](_0x330ebc[_0xfcf5('0x3a')]);_0x2a5e9c[_0xfcf5('0x3c')]=_[_0xfcf5('0x3d')](_0x2a5e9c[_0xfcf5('0x39')],_0x2a5e9c['query']);_0x1632bb[_0xfcf5('0x3e')]=_['intersection'](_0x2a5e9c['model'],qs[_0xfcf5('0x3f')](_0x330ebc[_0xfcf5('0x3a')][_0xfcf5('0x3f')]));_0x1632bb[_0xfcf5('0x3e')]=_0x1632bb[_0xfcf5('0x3e')][_0xfcf5('0x40')]?_0x1632bb[_0xfcf5('0x3e')]:_0x2a5e9c[_0xfcf5('0x39')];_0x1632bb[_0xfcf5('0x54')]=qs['sort'](_0x330ebc[_0xfcf5('0x3a')][_0xfcf5('0x44')]);_0x1632bb[_0xfcf5('0x47')]=qs['filters'](_[_0xfcf5('0x45')](_0x330ebc[_0xfcf5('0x3a')],_0x2a5e9c[_0xfcf5('0x3c')]));if(_0x330ebc[_0xfcf5('0x3a')][_0xfcf5('0x46')]){_0x1632bb[_0xfcf5('0x47')]=_['merge'](_0x1632bb[_0xfcf5('0x47')],{'$or':_['map'](_0x1632bb[_0xfcf5('0x3e')],function(_0xad11fc){var _0x1bb3e4={};_0x1bb3e4[_0xad11fc]={'$like':'%'+_0x330ebc['query']['filter']+'%'};return _0x1bb3e4;})});}_0x1632bb=_[_0xfcf5('0x48')]({},_0x1632bb,_0x330ebc[_0xfcf5('0x4a')]);return _0x4a01e1[_0xfcf5('0x55')](_0x1632bb);}})['then'](function(_0x3be4d2){if(_0x3be4d2){_0x2152c9=_0x3be4d2[_0xfcf5('0x40')];if(!_0x330ebc[_0xfcf5('0x3a')]['hasOwnProperty']('nolimit')){_0x1632bb[_0xfcf5('0x43')]=qs[_0xfcf5('0x43')](_0x330ebc['query']['limit']);_0x1632bb['offset']=qs['offset'](_0x330ebc['query'][_0xfcf5('0x28')]);}return _0x4a01e1['getSubjects'](_0x1632bb);}})[_0xfcf5('0x19')](function(_0xfb314d){if(_0xfb314d){return _0xfb314d?{'count':_0x2152c9,'rows':_0xfb314d}:null;}})['then'](respondWithResult(_0xc74f3f,null))['catch'](handleError(_0xc74f3f,null));};exports['getDescriptions']=function(_0xc6a63a,_0x1bf4c1,_0x1b4bcb){var _0x40c0a8={};var _0x7e2c8={};var _0x18c35f;var _0x5cdc8e;return db[_0xfcf5('0x4c')][_0xfcf5('0x57')]({'where':{'id':_0xc6a63a[_0xfcf5('0x4e')]['id']}})[_0xfcf5('0x19')](handleEntityNotFound(_0x1bf4c1,null))[_0xfcf5('0x19')](function(_0x4f72c5){if(_0x4f72c5){_0x18c35f=_0x4f72c5;_0x7e2c8['model']=_[_0xfcf5('0x3b')](db[_0xfcf5('0x56')][_0xfcf5('0x36')]);_0x7e2c8[_0xfcf5('0x3a')]=_[_0xfcf5('0x3b')](_0xc6a63a[_0xfcf5('0x3a')]);_0x7e2c8[_0xfcf5('0x3c')]=_[_0xfcf5('0x3d')](_0x7e2c8['model'],_0x7e2c8[_0xfcf5('0x3a')]);_0x40c0a8['attributes']=_[_0xfcf5('0x3d')](_0x7e2c8[_0xfcf5('0x39')],qs[_0xfcf5('0x3f')](_0xc6a63a[_0xfcf5('0x3a')][_0xfcf5('0x3f')]));_0x40c0a8['attributes']=_0x40c0a8[_0xfcf5('0x3e')][_0xfcf5('0x40')]?_0x40c0a8[_0xfcf5('0x3e')]:_0x7e2c8['model'];_0x40c0a8['order']=qs[_0xfcf5('0x44')](_0xc6a63a[_0xfcf5('0x3a')][_0xfcf5('0x44')]);_0x40c0a8[_0xfcf5('0x47')]=qs['filters'](_[_0xfcf5('0x45')](_0xc6a63a[_0xfcf5('0x3a')],_0x7e2c8['filters']));if(_0xc6a63a[_0xfcf5('0x3a')][_0xfcf5('0x46')]){_0x40c0a8[_0xfcf5('0x47')]=_[_0xfcf5('0x48')](_0x40c0a8['where'],{'$or':_[_0xfcf5('0x35')](_0x40c0a8['attributes'],function(_0x57e9ae){var _0xbd7318={};_0xbd7318[_0x57e9ae]={'$like':'%'+_0xc6a63a['query'][_0xfcf5('0x46')]+'%'};return _0xbd7318;})});}_0x40c0a8=_['merge']({},_0x40c0a8,_0xc6a63a[_0xfcf5('0x4a')]);return _0x18c35f['getDescriptions'](_0x40c0a8);}})[_0xfcf5('0x19')](function(_0x5d5f31){if(_0x5d5f31){_0x5cdc8e=_0x5d5f31['length'];if(!_0xc6a63a['query'][_0xfcf5('0x41')]('nolimit')){_0x40c0a8['limit']=qs[_0xfcf5('0x43')](_0xc6a63a[_0xfcf5('0x3a')][_0xfcf5('0x43')]);_0x40c0a8[_0xfcf5('0x28')]=qs[_0xfcf5('0x28')](_0xc6a63a[_0xfcf5('0x3a')][_0xfcf5('0x28')]);}return _0x18c35f[_0xfcf5('0x58')](_0x40c0a8);}})[_0xfcf5('0x19')](function(_0x94fd23){if(_0x94fd23){return _0x94fd23?{'count':_0x5cdc8e,'rows':_0x94fd23}:null;}})['then'](respondWithResult(_0x1bf4c1,null))[_0xfcf5('0x23')](handleError(_0x1bf4c1,null));};exports[_0xfcf5('0x59')]=function(_0x47290f,_0x4c64db,_0x1b111b){var _0x410f04={};var _0x5a39cb={};var _0x3525f1;var _0x48a1b7;return db[_0xfcf5('0x4c')]['findOne']({'where':{'id':_0x47290f['params']['id']}})[_0xfcf5('0x19')](handleEntityNotFound(_0x4c64db,null))[_0xfcf5('0x19')](function(_0x5d201b){if(_0x5d201b){_0x3525f1=_0x5d201b;_0x5a39cb[_0xfcf5('0x39')]=_[_0xfcf5('0x3b')](db[_0xfcf5('0x5a')][_0xfcf5('0x36')]);_0x5a39cb[_0xfcf5('0x3a')]=_[_0xfcf5('0x3b')](_0x47290f[_0xfcf5('0x3a')]);_0x5a39cb[_0xfcf5('0x3c')]=_['intersection'](_0x5a39cb[_0xfcf5('0x39')],_0x5a39cb['query']);_0x410f04['attributes']=_['intersection'](_0x5a39cb[_0xfcf5('0x39')],qs[_0xfcf5('0x3f')](_0x47290f[_0xfcf5('0x3a')][_0xfcf5('0x3f')]));_0x410f04[_0xfcf5('0x3e')]=_0x410f04[_0xfcf5('0x3e')][_0xfcf5('0x40')]?_0x410f04[_0xfcf5('0x3e')]:_0x5a39cb['model'];_0x410f04[_0xfcf5('0x54')]=qs[_0xfcf5('0x44')](_0x47290f[_0xfcf5('0x3a')]['sort']);_0x410f04[_0xfcf5('0x47')]=qs[_0xfcf5('0x3c')](_[_0xfcf5('0x45')](_0x47290f['query'],_0x5a39cb['filters']));if(_0x47290f[_0xfcf5('0x3a')][_0xfcf5('0x46')]){_0x410f04[_0xfcf5('0x47')]=_[_0xfcf5('0x48')](_0x410f04[_0xfcf5('0x47')],{'$or':_[_0xfcf5('0x35')](_0x410f04[_0xfcf5('0x3e')],function(_0x399a40){var _0x4d4633={};_0x4d4633[_0x399a40]={'$like':'%'+_0x47290f[_0xfcf5('0x3a')][_0xfcf5('0x46')]+'%'};return _0x4d4633;})});}_0x410f04=_['merge']({},_0x410f04,_0x47290f[_0xfcf5('0x4a')]);return _0x3525f1[_0xfcf5('0x59')](_0x410f04);}})[_0xfcf5('0x19')](function(_0x4c0212){if(_0x4c0212){_0x48a1b7=_0x4c0212[_0xfcf5('0x40')];if(!_0x47290f['query'][_0xfcf5('0x41')](_0xfcf5('0x42'))){_0x410f04[_0xfcf5('0x43')]=qs[_0xfcf5('0x43')](_0x47290f['query'][_0xfcf5('0x43')]);_0x410f04['offset']=qs[_0xfcf5('0x28')](_0x47290f[_0xfcf5('0x3a')]['offset']);}return _0x3525f1[_0xfcf5('0x59')](_0x410f04);}})[_0xfcf5('0x19')](function(_0x8da407){if(_0x8da407){return _0x8da407?{'count':_0x48a1b7,'rows':_0x8da407}:null;}})[_0xfcf5('0x19')](respondWithResult(_0x4c64db,null))['catch'](handleError(_0x4c64db,null));};exports[_0xfcf5('0x5b')]=function(_0x18b757,_0x40d8fc,_0x43fa80){if(_0x18b757[_0xfcf5('0x52')]['id']){delete _0x18b757[_0xfcf5('0x52')]['id'];}return db[_0xfcf5('0x4c')]['findOne']({'where':{'id':_0x18b757[_0xfcf5('0x4e')]['id']}})[_0xfcf5('0x19')](handleEntityNotFound(_0x40d8fc,null))[_0xfcf5('0x19')](function(_0x24e1ee){if(_0x24e1ee){return _0x24e1ee[_0xfcf5('0x5b')](_0x18b757['body'][_0xfcf5('0x5c')]||[]);}return null;})[_0xfcf5('0x19')](respondWithResult(_0x40d8fc,null))['catch'](handleError(_0x40d8fc,null));};