Built motion from commit 43538d75.|2.5.35
[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 _0xe5b5=['params','include','find','create','body','update','findOne','order','pick','getFields','getSubjects','ZendeskField','nolimit','getDescriptions','getTags','Tag','setTags','ids','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','end','offset','undefined','count','limit','set','Content-Range','json','apply','reject','save','then','destroy','error','name','send','ZendeskConfiguration','rawAttributes','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','sort','where','filter','merge','VIRTUAL','options','includeAll','findAll','rows','catch','show'];(function(_0x3ef7de,_0x518ef8){var _0x37929b=function(_0xc3e9e6){while(--_0xc3e9e6){_0x3ef7de['push'](_0x3ef7de['shift']());}};_0x37929b(++_0x518ef8);}(_0xe5b5,0xc0));var _0x5e5b=function(_0x365be9,_0x3c88b9){_0x365be9=_0x365be9-0x0;var _0x185c12=_0xe5b5[_0x365be9];return _0x185c12;};'use strict';var emlformat=require(_0x5e5b('0x0'));var rimraf=require(_0x5e5b('0x1'));var zipdir=require(_0x5e5b('0x2'));var jsonpatch=require(_0x5e5b('0x3'));var rp=require('request-promise');var moment=require(_0x5e5b('0x4'));var BPromise=require(_0x5e5b('0x5'));var Mustache=require(_0x5e5b('0x6'));var util=require(_0x5e5b('0x7'));var path=require(_0x5e5b('0x8'));var sox=require(_0x5e5b('0x9'));var csv=require('to-csv');var ejs=require(_0x5e5b('0xa'));var fs=require('fs');var fs_extra=require(_0x5e5b('0xb'));var _=require(_0x5e5b('0xc'));var squel=require('squel');var crypto=require(_0x5e5b('0xd'));var jsforce=require(_0x5e5b('0xe'));var deskjs=require(_0x5e5b('0xf'));var toCsv=require(_0x5e5b('0x10'));var querystring=require(_0x5e5b('0x11'));var Papa=require('papaparse');var Redis=require(_0x5e5b('0x12'));var authService=require(_0x5e5b('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0x5e5b('0x14'));var hardwareService=require(_0x5e5b('0x15'));var logger=require(_0x5e5b('0x16'))(_0x5e5b('0x17'));var utils=require(_0x5e5b('0x18'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x5e5b('0x19'))['db'];function respondWithStatusCode(_0x363b78,_0x13004f){_0x13004f=_0x13004f||0xcc;return function(_0x178757){if(_0x178757){return _0x363b78[_0x5e5b('0x1a')](_0x13004f);}return _0x363b78[_0x5e5b('0x1b')](_0x13004f)[_0x5e5b('0x1c')]();};}function respondWithResult(_0x2fd920,_0x27982c){_0x27982c=_0x27982c||0xc8;return function(_0x4faa44){if(_0x4faa44){return _0x2fd920[_0x5e5b('0x1b')](_0x27982c)['json'](_0x4faa44);}};}function respondWithFilteredResult(_0x52316b,_0x430d88){return function(_0x223c62){if(_0x223c62){var _0x8a9447=typeof _0x430d88[_0x5e5b('0x1d')]===_0x5e5b('0x1e')&&typeof _0x430d88['limit']===_0x5e5b('0x1e');var _0x5429d2=_0x223c62[_0x5e5b('0x1f')];var _0xd79597=_0x8a9447?0x0:_0x430d88[_0x5e5b('0x1d')];var _0x2ea91f=_0x8a9447?_0x223c62[_0x5e5b('0x1f')]:_0x430d88[_0x5e5b('0x1d')]+_0x430d88[_0x5e5b('0x20')];var _0x57ef73;if(_0x2ea91f>=_0x5429d2){_0x2ea91f=_0x5429d2;_0x57ef73=0xc8;}else{_0x57ef73=0xce;}_0x52316b[_0x5e5b('0x1b')](_0x57ef73);return _0x52316b[_0x5e5b('0x21')](_0x5e5b('0x22'),_0xd79597+'-'+_0x2ea91f+'/'+_0x5429d2)[_0x5e5b('0x23')](_0x223c62);}return null;};}function patchUpdates(_0x5ab99e){return function(_0x4781bb){try{jsonpatch[_0x5e5b('0x24')](_0x4781bb,_0x5ab99e,!![]);}catch(_0x736681){return BPromise[_0x5e5b('0x25')](_0x736681);}return _0x4781bb[_0x5e5b('0x26')]();};}function saveUpdates(_0x28453a,_0x524b6b){return function(_0x43d368){if(_0x43d368){return _0x43d368['update'](_0x28453a)[_0x5e5b('0x27')](function(_0x3cc858){return _0x3cc858;});}return null;};}function removeEntity(_0x4e7d49,_0x2c8a2c){return function(_0x5177e8){if(_0x5177e8){return _0x5177e8[_0x5e5b('0x28')]()[_0x5e5b('0x27')](function(){_0x4e7d49[_0x5e5b('0x1b')](0xcc)[_0x5e5b('0x1c')]();});}};}function handleEntityNotFound(_0x58a0fc,_0x14341c){return function(_0x9dfcd5){if(!_0x9dfcd5){_0x58a0fc['sendStatus'](0x194);}return _0x9dfcd5;};}function handleError(_0x40e96b,_0x85bee){_0x85bee=_0x85bee||0x1f4;return function(_0x4b40ea){logger[_0x5e5b('0x29')](_0x4b40ea['stack']);if(_0x4b40ea[_0x5e5b('0x2a')]){delete _0x4b40ea[_0x5e5b('0x2a')];}_0x40e96b[_0x5e5b('0x1b')](_0x85bee)[_0x5e5b('0x2b')](_0x4b40ea);};}exports['index']=function(_0x424939,_0x506372){var _0x2bcabd={},_0x11af56={},_0x5468e={'count':0x0,'rows':[]};var _0x195835=_['map'](db[_0x5e5b('0x2c')][_0x5e5b('0x2d')],function(_0x4a37de){return{'name':_0x4a37de['fieldName'],'type':_0x4a37de[_0x5e5b('0x2e')][_0x5e5b('0x2f')]};});_0x11af56[_0x5e5b('0x30')]=_[_0x5e5b('0x31')](_0x195835,_0x5e5b('0x2a'));_0x11af56[_0x5e5b('0x32')]=_[_0x5e5b('0x33')](_0x424939[_0x5e5b('0x32')]);_0x11af56[_0x5e5b('0x34')]=_[_0x5e5b('0x35')](_0x11af56['model'],_0x11af56[_0x5e5b('0x32')]);_0x2bcabd[_0x5e5b('0x36')]=_['intersection'](_0x11af56[_0x5e5b('0x30')],qs[_0x5e5b('0x37')](_0x424939[_0x5e5b('0x32')][_0x5e5b('0x37')]));_0x2bcabd[_0x5e5b('0x36')]=_0x2bcabd[_0x5e5b('0x36')][_0x5e5b('0x38')]?_0x2bcabd[_0x5e5b('0x36')]:_0x11af56[_0x5e5b('0x30')];if(!_0x424939[_0x5e5b('0x32')][_0x5e5b('0x39')]('nolimit')){_0x2bcabd[_0x5e5b('0x20')]=qs[_0x5e5b('0x20')](_0x424939[_0x5e5b('0x32')][_0x5e5b('0x20')]);_0x2bcabd[_0x5e5b('0x1d')]=qs['offset'](_0x424939[_0x5e5b('0x32')][_0x5e5b('0x1d')]);}_0x2bcabd['order']=qs[_0x5e5b('0x3a')](_0x424939['query']['sort']);_0x2bcabd[_0x5e5b('0x3b')]=qs[_0x5e5b('0x34')](_['pick'](_0x424939[_0x5e5b('0x32')],_0x11af56[_0x5e5b('0x34')]),_0x195835);if(_0x424939[_0x5e5b('0x32')][_0x5e5b('0x3c')]){_0x2bcabd[_0x5e5b('0x3b')]=_[_0x5e5b('0x3d')](_0x2bcabd[_0x5e5b('0x3b')],{'$or':_[_0x5e5b('0x31')](_0x195835,function(_0x2b2cae){if(_0x2b2cae[_0x5e5b('0x2e')]!==_0x5e5b('0x3e')){var _0x41e2b3={};_0x41e2b3[_0x2b2cae[_0x5e5b('0x2a')]]={'$like':'%'+_0x424939[_0x5e5b('0x32')][_0x5e5b('0x3c')]+'%'};return _0x41e2b3;}})});}_0x2bcabd=_[_0x5e5b('0x3d')]({},_0x2bcabd,_0x424939[_0x5e5b('0x3f')]);var _0x5b7027={'where':_0x2bcabd[_0x5e5b('0x3b')]};return db[_0x5e5b('0x2c')][_0x5e5b('0x1f')](_0x5b7027)[_0x5e5b('0x27')](function(_0x169480){_0x5468e[_0x5e5b('0x1f')]=_0x169480;if(_0x424939[_0x5e5b('0x32')][_0x5e5b('0x40')]){_0x2bcabd['include']=[{'all':!![]}];}return db[_0x5e5b('0x2c')][_0x5e5b('0x41')](_0x2bcabd);})[_0x5e5b('0x27')](function(_0x451d9c){_0x5468e[_0x5e5b('0x42')]=_0x451d9c;return _0x5468e;})[_0x5e5b('0x27')](respondWithFilteredResult(_0x506372,_0x2bcabd))[_0x5e5b('0x43')](handleError(_0x506372,null));};exports[_0x5e5b('0x44')]=function(_0x567f46,_0x239293){var _0x561d13={'raw':![],'where':{'id':_0x567f46[_0x5e5b('0x45')]['id']}},_0x22e309={};_0x22e309['model']=_['keys'](db[_0x5e5b('0x2c')][_0x5e5b('0x2d')]);_0x22e309[_0x5e5b('0x32')]=_[_0x5e5b('0x33')](_0x567f46[_0x5e5b('0x32')]);_0x22e309[_0x5e5b('0x34')]=_[_0x5e5b('0x35')](_0x22e309[_0x5e5b('0x30')],_0x22e309[_0x5e5b('0x32')]);_0x561d13['attributes']=_[_0x5e5b('0x35')](_0x22e309['model'],qs[_0x5e5b('0x37')](_0x567f46[_0x5e5b('0x32')][_0x5e5b('0x37')]));_0x561d13[_0x5e5b('0x36')]=_0x561d13[_0x5e5b('0x36')]['length']?_0x561d13[_0x5e5b('0x36')]:_0x22e309['model'];if(_0x567f46['query'][_0x5e5b('0x40')]){_0x561d13[_0x5e5b('0x46')]=[{'all':!![]}];}_0x561d13=_['merge']({},_0x561d13,_0x567f46[_0x5e5b('0x3f')]);return db[_0x5e5b('0x2c')][_0x5e5b('0x47')](_0x561d13)['then'](handleEntityNotFound(_0x239293,null))[_0x5e5b('0x27')](respondWithResult(_0x239293,null))[_0x5e5b('0x43')](handleError(_0x239293,null));};exports[_0x5e5b('0x48')]=function(_0x4292c5,_0x30f519){return db['ZendeskConfiguration'][_0x5e5b('0x48')](_0x4292c5[_0x5e5b('0x49')],{})[_0x5e5b('0x27')](respondWithResult(_0x30f519,0xc9))['catch'](handleError(_0x30f519,null));};exports[_0x5e5b('0x4a')]=function(_0x16d1bc,_0x283c3d){if(_0x16d1bc['body']['id']){delete _0x16d1bc[_0x5e5b('0x49')]['id'];}return db[_0x5e5b('0x2c')][_0x5e5b('0x47')]({'where':{'id':_0x16d1bc['params']['id']}})[_0x5e5b('0x27')](handleEntityNotFound(_0x283c3d,null))[_0x5e5b('0x27')](saveUpdates(_0x16d1bc[_0x5e5b('0x49')],null))[_0x5e5b('0x27')](respondWithResult(_0x283c3d,null))['catch'](handleError(_0x283c3d,null));};exports[_0x5e5b('0x28')]=function(_0x31c55d,_0x286e12){return db[_0x5e5b('0x2c')][_0x5e5b('0x47')]({'where':{'id':_0x31c55d[_0x5e5b('0x45')]['id']}})['then'](handleEntityNotFound(_0x286e12,null))[_0x5e5b('0x27')](removeEntity(_0x286e12,null))[_0x5e5b('0x43')](handleError(_0x286e12,null));};exports['getFields']=function(_0x4fe4a4,_0x5de6f3,_0x1743a4){var _0xb094e0={};var _0x2b3a9d={};var _0x3706cc;var _0x2b99ce;return db[_0x5e5b('0x2c')][_0x5e5b('0x4b')]({'where':{'id':_0x4fe4a4[_0x5e5b('0x45')]['id']}})['then'](handleEntityNotFound(_0x5de6f3,null))[_0x5e5b('0x27')](function(_0x5be11c){if(_0x5be11c){_0x3706cc=_0x5be11c;_0x2b3a9d['model']=_['keys'](db['ZendeskField']['rawAttributes']);_0x2b3a9d[_0x5e5b('0x32')]=_[_0x5e5b('0x33')](_0x4fe4a4['query']);_0x2b3a9d[_0x5e5b('0x34')]=_[_0x5e5b('0x35')](_0x2b3a9d['model'],_0x2b3a9d[_0x5e5b('0x32')]);_0xb094e0['attributes']=_[_0x5e5b('0x35')](_0x2b3a9d[_0x5e5b('0x30')],qs[_0x5e5b('0x37')](_0x4fe4a4[_0x5e5b('0x32')][_0x5e5b('0x37')]));_0xb094e0['attributes']=_0xb094e0['attributes'][_0x5e5b('0x38')]?_0xb094e0['attributes']:_0x2b3a9d[_0x5e5b('0x30')];_0xb094e0[_0x5e5b('0x4c')]=qs[_0x5e5b('0x3a')](_0x4fe4a4[_0x5e5b('0x32')][_0x5e5b('0x3a')]);_0xb094e0[_0x5e5b('0x3b')]=qs[_0x5e5b('0x34')](_[_0x5e5b('0x4d')](_0x4fe4a4['query'],_0x2b3a9d['filters']));if(_0x4fe4a4[_0x5e5b('0x32')]['filter']){_0xb094e0['where']=_[_0x5e5b('0x3d')](_0xb094e0['where'],{'$or':_[_0x5e5b('0x31')](_0xb094e0[_0x5e5b('0x36')],function(_0x2d6b57){var _0x51bbce={};_0x51bbce[_0x2d6b57]={'$like':'%'+_0x4fe4a4[_0x5e5b('0x32')][_0x5e5b('0x3c')]+'%'};return _0x51bbce;})});}_0xb094e0=_['merge']({},_0xb094e0,_0x4fe4a4[_0x5e5b('0x3f')]);return _0x3706cc[_0x5e5b('0x4e')](_0xb094e0);}})[_0x5e5b('0x27')](function(_0x445838){if(_0x445838){_0x2b99ce=_0x445838[_0x5e5b('0x38')];if(!_0x4fe4a4[_0x5e5b('0x32')]['hasOwnProperty']('nolimit')){_0xb094e0[_0x5e5b('0x20')]=qs[_0x5e5b('0x20')](_0x4fe4a4[_0x5e5b('0x32')][_0x5e5b('0x20')]);_0xb094e0[_0x5e5b('0x1d')]=qs[_0x5e5b('0x1d')](_0x4fe4a4['query']['offset']);}return _0x3706cc[_0x5e5b('0x4e')](_0xb094e0);}})[_0x5e5b('0x27')](function(_0x4db9cd){if(_0x4db9cd){return _0x4db9cd?{'count':_0x2b99ce,'rows':_0x4db9cd}:null;}})[_0x5e5b('0x27')](respondWithResult(_0x5de6f3,null))['catch'](handleError(_0x5de6f3,null));};exports[_0x5e5b('0x4f')]=function(_0x17f2fc,_0x2a67e0,_0x7d8c6c){var _0x3954c1={};var _0x104ee5={};var _0x178526;var _0x1b85b3;return db[_0x5e5b('0x2c')][_0x5e5b('0x4b')]({'where':{'id':_0x17f2fc[_0x5e5b('0x45')]['id']}})[_0x5e5b('0x27')](handleEntityNotFound(_0x2a67e0,null))[_0x5e5b('0x27')](function(_0x2759f5){if(_0x2759f5){_0x178526=_0x2759f5;_0x104ee5[_0x5e5b('0x30')]=_['keys'](db[_0x5e5b('0x50')][_0x5e5b('0x2d')]);_0x104ee5[_0x5e5b('0x32')]=_[_0x5e5b('0x33')](_0x17f2fc[_0x5e5b('0x32')]);_0x104ee5[_0x5e5b('0x34')]=_['intersection'](_0x104ee5[_0x5e5b('0x30')],_0x104ee5['query']);_0x3954c1[_0x5e5b('0x36')]=_['intersection'](_0x104ee5[_0x5e5b('0x30')],qs[_0x5e5b('0x37')](_0x17f2fc['query'][_0x5e5b('0x37')]));_0x3954c1[_0x5e5b('0x36')]=_0x3954c1['attributes'][_0x5e5b('0x38')]?_0x3954c1[_0x5e5b('0x36')]:_0x104ee5[_0x5e5b('0x30')];_0x3954c1[_0x5e5b('0x4c')]=qs[_0x5e5b('0x3a')](_0x17f2fc[_0x5e5b('0x32')][_0x5e5b('0x3a')]);_0x3954c1[_0x5e5b('0x3b')]=qs[_0x5e5b('0x34')](_[_0x5e5b('0x4d')](_0x17f2fc[_0x5e5b('0x32')],_0x104ee5[_0x5e5b('0x34')]));if(_0x17f2fc['query'][_0x5e5b('0x3c')]){_0x3954c1[_0x5e5b('0x3b')]=_[_0x5e5b('0x3d')](_0x3954c1[_0x5e5b('0x3b')],{'$or':_['map'](_0x3954c1['attributes'],function(_0x7b4dc7){var _0x59040c={};_0x59040c[_0x7b4dc7]={'$like':'%'+_0x17f2fc['query']['filter']+'%'};return _0x59040c;})});}_0x3954c1=_['merge']({},_0x3954c1,_0x17f2fc['options']);return _0x178526[_0x5e5b('0x4f')](_0x3954c1);}})[_0x5e5b('0x27')](function(_0x3d2625){if(_0x3d2625){_0x1b85b3=_0x3d2625[_0x5e5b('0x38')];if(!_0x17f2fc['query'][_0x5e5b('0x39')](_0x5e5b('0x51'))){_0x3954c1[_0x5e5b('0x20')]=qs[_0x5e5b('0x20')](_0x17f2fc[_0x5e5b('0x32')][_0x5e5b('0x20')]);_0x3954c1[_0x5e5b('0x1d')]=qs[_0x5e5b('0x1d')](_0x17f2fc['query'][_0x5e5b('0x1d')]);}return _0x178526['getSubjects'](_0x3954c1);}})[_0x5e5b('0x27')](function(_0x4d4893){if(_0x4d4893){return _0x4d4893?{'count':_0x1b85b3,'rows':_0x4d4893}:null;}})[_0x5e5b('0x27')](respondWithResult(_0x2a67e0,null))[_0x5e5b('0x43')](handleError(_0x2a67e0,null));};exports['getDescriptions']=function(_0x4463d9,_0x5a5f92,_0x2df938){var _0x1130af={};var _0x308b3f={};var _0x44b566;var _0x1c53e5;return db[_0x5e5b('0x2c')]['findOne']({'where':{'id':_0x4463d9[_0x5e5b('0x45')]['id']}})[_0x5e5b('0x27')](handleEntityNotFound(_0x5a5f92,null))[_0x5e5b('0x27')](function(_0x55b9b0){if(_0x55b9b0){_0x44b566=_0x55b9b0;_0x308b3f[_0x5e5b('0x30')]=_[_0x5e5b('0x33')](db[_0x5e5b('0x50')][_0x5e5b('0x2d')]);_0x308b3f[_0x5e5b('0x32')]=_[_0x5e5b('0x33')](_0x4463d9[_0x5e5b('0x32')]);_0x308b3f[_0x5e5b('0x34')]=_[_0x5e5b('0x35')](_0x308b3f[_0x5e5b('0x30')],_0x308b3f[_0x5e5b('0x32')]);_0x1130af['attributes']=_[_0x5e5b('0x35')](_0x308b3f[_0x5e5b('0x30')],qs[_0x5e5b('0x37')](_0x4463d9['query'][_0x5e5b('0x37')]));_0x1130af[_0x5e5b('0x36')]=_0x1130af['attributes'][_0x5e5b('0x38')]?_0x1130af[_0x5e5b('0x36')]:_0x308b3f[_0x5e5b('0x30')];_0x1130af[_0x5e5b('0x4c')]=qs['sort'](_0x4463d9[_0x5e5b('0x32')][_0x5e5b('0x3a')]);_0x1130af['where']=qs[_0x5e5b('0x34')](_[_0x5e5b('0x4d')](_0x4463d9[_0x5e5b('0x32')],_0x308b3f[_0x5e5b('0x34')]));if(_0x4463d9[_0x5e5b('0x32')][_0x5e5b('0x3c')]){_0x1130af[_0x5e5b('0x3b')]=_[_0x5e5b('0x3d')](_0x1130af[_0x5e5b('0x3b')],{'$or':_[_0x5e5b('0x31')](_0x1130af[_0x5e5b('0x36')],function(_0x4a3d27){var _0x4f18b9={};_0x4f18b9[_0x4a3d27]={'$like':'%'+_0x4463d9[_0x5e5b('0x32')][_0x5e5b('0x3c')]+'%'};return _0x4f18b9;})});}_0x1130af=_[_0x5e5b('0x3d')]({},_0x1130af,_0x4463d9[_0x5e5b('0x3f')]);return _0x44b566['getDescriptions'](_0x1130af);}})[_0x5e5b('0x27')](function(_0x19b1c4){if(_0x19b1c4){_0x1c53e5=_0x19b1c4[_0x5e5b('0x38')];if(!_0x4463d9[_0x5e5b('0x32')][_0x5e5b('0x39')]('nolimit')){_0x1130af[_0x5e5b('0x20')]=qs[_0x5e5b('0x20')](_0x4463d9[_0x5e5b('0x32')]['limit']);_0x1130af[_0x5e5b('0x1d')]=qs[_0x5e5b('0x1d')](_0x4463d9['query'][_0x5e5b('0x1d')]);}return _0x44b566[_0x5e5b('0x52')](_0x1130af);}})[_0x5e5b('0x27')](function(_0x31440f){if(_0x31440f){return _0x31440f?{'count':_0x1c53e5,'rows':_0x31440f}:null;}})['then'](respondWithResult(_0x5a5f92,null))[_0x5e5b('0x43')](handleError(_0x5a5f92,null));};exports[_0x5e5b('0x53')]=function(_0x33175b,_0x47b3cd,_0x215e26){var _0x5511cf={};var _0x10d25f={};var _0x26a0b7;var _0x653b8b;return db[_0x5e5b('0x2c')][_0x5e5b('0x4b')]({'where':{'id':_0x33175b[_0x5e5b('0x45')]['id']}})[_0x5e5b('0x27')](handleEntityNotFound(_0x47b3cd,null))[_0x5e5b('0x27')](function(_0x45035d){if(_0x45035d){_0x26a0b7=_0x45035d;_0x10d25f['model']=_[_0x5e5b('0x33')](db[_0x5e5b('0x54')]['rawAttributes']);_0x10d25f[_0x5e5b('0x32')]=_[_0x5e5b('0x33')](_0x33175b[_0x5e5b('0x32')]);_0x10d25f[_0x5e5b('0x34')]=_[_0x5e5b('0x35')](_0x10d25f['model'],_0x10d25f[_0x5e5b('0x32')]);_0x5511cf[_0x5e5b('0x36')]=_[_0x5e5b('0x35')](_0x10d25f[_0x5e5b('0x30')],qs[_0x5e5b('0x37')](_0x33175b[_0x5e5b('0x32')][_0x5e5b('0x37')]));_0x5511cf[_0x5e5b('0x36')]=_0x5511cf[_0x5e5b('0x36')]['length']?_0x5511cf[_0x5e5b('0x36')]:_0x10d25f[_0x5e5b('0x30')];_0x5511cf['order']=qs['sort'](_0x33175b['query']['sort']);_0x5511cf['where']=qs[_0x5e5b('0x34')](_['pick'](_0x33175b[_0x5e5b('0x32')],_0x10d25f[_0x5e5b('0x34')]));if(_0x33175b[_0x5e5b('0x32')][_0x5e5b('0x3c')]){_0x5511cf['where']=_[_0x5e5b('0x3d')](_0x5511cf[_0x5e5b('0x3b')],{'$or':_[_0x5e5b('0x31')](_0x5511cf[_0x5e5b('0x36')],function(_0x23e358){var _0x2bc5d0={};_0x2bc5d0[_0x23e358]={'$like':'%'+_0x33175b[_0x5e5b('0x32')]['filter']+'%'};return _0x2bc5d0;})});}_0x5511cf=_[_0x5e5b('0x3d')]({},_0x5511cf,_0x33175b[_0x5e5b('0x3f')]);return _0x26a0b7[_0x5e5b('0x53')](_0x5511cf);}})[_0x5e5b('0x27')](function(_0x19f5bd){if(_0x19f5bd){_0x653b8b=_0x19f5bd[_0x5e5b('0x38')];if(!_0x33175b['query'][_0x5e5b('0x39')](_0x5e5b('0x51'))){_0x5511cf['limit']=qs['limit'](_0x33175b['query'][_0x5e5b('0x20')]);_0x5511cf[_0x5e5b('0x1d')]=qs['offset'](_0x33175b[_0x5e5b('0x32')][_0x5e5b('0x1d')]);}return _0x26a0b7[_0x5e5b('0x53')](_0x5511cf);}})[_0x5e5b('0x27')](function(_0x32c96a){if(_0x32c96a){return _0x32c96a?{'count':_0x653b8b,'rows':_0x32c96a}:null;}})['then'](respondWithResult(_0x47b3cd,null))[_0x5e5b('0x43')](handleError(_0x47b3cd,null));};exports[_0x5e5b('0x55')]=function(_0x47873a,_0x43e140,_0x5252bb){if(_0x47873a[_0x5e5b('0x49')]['id']){delete _0x47873a['body']['id'];}return db[_0x5e5b('0x2c')][_0x5e5b('0x4b')]({'where':{'id':_0x47873a['params']['id']}})['then'](handleEntityNotFound(_0x43e140,null))[_0x5e5b('0x27')](function(_0x2f5f97){if(_0x2f5f97){return _0x2f5f97[_0x5e5b('0x55')](_0x47873a[_0x5e5b('0x49')][_0x5e5b('0x56')]||[]);}return null;})[_0x5e5b('0x27')](respondWithResult(_0x43e140,null))[_0x5e5b('0x43')](handleError(_0x43e140,null));};