46487949ca4233c20a0fd72ec095024f021a313e
[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 _0x917f=['body','find','getFields','findOne','ZendeskField','hasOwnProperty','getSubjects','nolimit','getDescriptions','getTags','Tag','pick','setTags','ids','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','limit','undefined','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','stack','name','ZendeskConfiguration','rawAttributes','fieldName','type','key','map','query','keys','filters','model','attributes','length','order','sort','where','filter','merge','VIRTUAL','options','includeAll','include','findAll','catch','show','params','intersection','fields','create'];(function(_0x575577,_0x58b846){var _0x44a130=function(_0x5ef4c8){while(--_0x5ef4c8){_0x575577['push'](_0x575577['shift']());}};_0x44a130(++_0x58b846);}(_0x917f,0x110));var _0xf917=function(_0x4812d1,_0x1f3625){_0x4812d1=_0x4812d1-0x0;var _0x44bba3=_0x917f[_0x4812d1];return _0x44bba3;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xf917('0x0'));var jsonpatch=require(_0xf917('0x1'));var rp=require(_0xf917('0x2'));var moment=require('moment');var BPromise=require(_0xf917('0x3'));var Mustache=require(_0xf917('0x4'));var util=require('util');var path=require(_0xf917('0x5'));var sox=require(_0xf917('0x6'));var csv=require(_0xf917('0x7'));var ejs=require(_0xf917('0x8'));var fs=require('fs');var fs_extra=require(_0xf917('0x9'));var _=require(_0xf917('0xa'));var squel=require(_0xf917('0xb'));var crypto=require(_0xf917('0xc'));var jsforce=require(_0xf917('0xd'));var deskjs=require(_0xf917('0xe'));var toCsv=require('to-csv');var querystring=require(_0xf917('0xf'));var Papa=require(_0xf917('0x10'));var Redis=require(_0xf917('0x11'));var authService=require(_0xf917('0x12'));var qs=require(_0xf917('0x13'));var as=require(_0xf917('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf917('0x15'))(_0xf917('0x16'));var utils=require('../../config/utils');var config=require(_0xf917('0x17'));var licenseUtil=require(_0xf917('0x18'));var db=require(_0xf917('0x19'))['db'];function respondWithStatusCode(_0x13b74b,_0x3b7d5c){_0x3b7d5c=_0x3b7d5c||0xcc;return function(_0x6f1ca1){if(_0x6f1ca1){return _0x13b74b[_0xf917('0x1a')](_0x3b7d5c);}return _0x13b74b[_0xf917('0x1b')](_0x3b7d5c)[_0xf917('0x1c')]();};}function respondWithResult(_0x2d03ea,_0x2a3573){_0x2a3573=_0x2a3573||0xc8;return function(_0x387d9d){if(_0x387d9d){return _0x2d03ea[_0xf917('0x1b')](_0x2a3573)[_0xf917('0x1d')](_0x387d9d);}};}function respondWithFilteredResult(_0x9ae125,_0x3b197e){return function(_0x5586cc){if(_0x5586cc){var _0x439fa5=typeof _0x3b197e['offset']==='undefined'&&typeof _0x3b197e[_0xf917('0x1e')]===_0xf917('0x1f');var _0x14aadb=_0x5586cc[_0xf917('0x20')];var _0x543f7f=_0x439fa5?0x0:_0x3b197e[_0xf917('0x21')];var _0x57e5c7=_0x439fa5?_0x5586cc['count']:_0x3b197e[_0xf917('0x21')]+_0x3b197e['limit'];var _0x31613a;if(_0x57e5c7>=_0x14aadb){_0x57e5c7=_0x14aadb;_0x31613a=0xc8;}else{_0x31613a=0xce;}_0x9ae125['status'](_0x31613a);return _0x9ae125[_0xf917('0x22')](_0xf917('0x23'),_0x543f7f+'-'+_0x57e5c7+'/'+_0x14aadb)[_0xf917('0x1d')](_0x5586cc);}return null;};}function patchUpdates(_0x5bc0d8){return function(_0x5b5301){try{jsonpatch[_0xf917('0x24')](_0x5b5301,_0x5bc0d8,!![]);}catch(_0x17f5cd){return BPromise[_0xf917('0x25')](_0x17f5cd);}return _0x5b5301[_0xf917('0x26')]();};}function saveUpdates(_0x3b44f0,_0x32af6a){return function(_0x4751dd){if(_0x4751dd){return _0x4751dd[_0xf917('0x27')](_0x3b44f0)[_0xf917('0x28')](function(_0x19334d){return _0x19334d;});}return null;};}function removeEntity(_0x8cdeeb,_0x49eea6){return function(_0x46698e){if(_0x46698e){return _0x46698e[_0xf917('0x29')]()[_0xf917('0x28')](function(){_0x8cdeeb[_0xf917('0x1b')](0xcc)[_0xf917('0x1c')]();});}};}function handleEntityNotFound(_0x5e557f,_0x1fc0fb){return function(_0x27becb){if(!_0x27becb){_0x5e557f[_0xf917('0x1a')](0x194);}return _0x27becb;};}function handleError(_0x1c2108,_0xc582db){_0xc582db=_0xc582db||0x1f4;return function(_0x3bf471){logger['error'](_0x3bf471[_0xf917('0x2a')]);if(_0x3bf471[_0xf917('0x2b')]){delete _0x3bf471['name'];}_0x1c2108[_0xf917('0x1b')](_0xc582db)['send'](_0x3bf471);};}exports['index']=function(_0x57cc4b,_0x3353c4){var _0x2d2f32={},_0x2db5d5={},_0x19183b={'count':0x0,'rows':[]};var _0x27605d=_['map'](db[_0xf917('0x2c')][_0xf917('0x2d')],function(_0x38e4e5){return{'name':_0x38e4e5[_0xf917('0x2e')],'type':_0x38e4e5[_0xf917('0x2f')][_0xf917('0x30')]};});_0x2db5d5['model']=_[_0xf917('0x31')](_0x27605d,'name');_0x2db5d5[_0xf917('0x32')]=_[_0xf917('0x33')](_0x57cc4b['query']);_0x2db5d5[_0xf917('0x34')]=_['intersection'](_0x2db5d5[_0xf917('0x35')],_0x2db5d5['query']);_0x2d2f32['attributes']=_['intersection'](_0x2db5d5[_0xf917('0x35')],qs['fields'](_0x57cc4b['query']['fields']));_0x2d2f32[_0xf917('0x36')]=_0x2d2f32[_0xf917('0x36')][_0xf917('0x37')]?_0x2d2f32[_0xf917('0x36')]:_0x2db5d5[_0xf917('0x35')];if(!_0x57cc4b[_0xf917('0x32')]['hasOwnProperty']('nolimit')){_0x2d2f32[_0xf917('0x1e')]=qs[_0xf917('0x1e')](_0x57cc4b['query'][_0xf917('0x1e')]);_0x2d2f32[_0xf917('0x21')]=qs[_0xf917('0x21')](_0x57cc4b[_0xf917('0x32')][_0xf917('0x21')]);}_0x2d2f32[_0xf917('0x38')]=qs[_0xf917('0x39')](_0x57cc4b['query'][_0xf917('0x39')]);_0x2d2f32[_0xf917('0x3a')]=qs[_0xf917('0x34')](_['pick'](_0x57cc4b[_0xf917('0x32')],_0x2db5d5[_0xf917('0x34')]),_0x27605d);if(_0x57cc4b[_0xf917('0x32')][_0xf917('0x3b')]){_0x2d2f32[_0xf917('0x3a')]=_[_0xf917('0x3c')](_0x2d2f32[_0xf917('0x3a')],{'$or':_[_0xf917('0x31')](_0x27605d,function(_0x330fa5){if(_0x330fa5[_0xf917('0x2f')]!==_0xf917('0x3d')){var _0x233f6c={};_0x233f6c[_0x330fa5[_0xf917('0x2b')]]={'$like':'%'+_0x57cc4b[_0xf917('0x32')][_0xf917('0x3b')]+'%'};return _0x233f6c;}})});}_0x2d2f32=_[_0xf917('0x3c')]({},_0x2d2f32,_0x57cc4b[_0xf917('0x3e')]);var _0x3ac58e={'where':_0x2d2f32[_0xf917('0x3a')]};return db[_0xf917('0x2c')]['count'](_0x3ac58e)['then'](function(_0x244a7f){_0x19183b[_0xf917('0x20')]=_0x244a7f;if(_0x57cc4b[_0xf917('0x32')][_0xf917('0x3f')]){_0x2d2f32[_0xf917('0x40')]=[{'all':!![]}];}return db[_0xf917('0x2c')][_0xf917('0x41')](_0x2d2f32);})[_0xf917('0x28')](function(_0x6426e){_0x19183b['rows']=_0x6426e;return _0x19183b;})[_0xf917('0x28')](respondWithFilteredResult(_0x3353c4,_0x2d2f32))[_0xf917('0x42')](handleError(_0x3353c4,null));};exports[_0xf917('0x43')]=function(_0x11a1f8,_0x2c162){var _0x593f22={'raw':![],'where':{'id':_0x11a1f8[_0xf917('0x44')]['id']}},_0x43572b={};_0x43572b[_0xf917('0x35')]=_[_0xf917('0x33')](db[_0xf917('0x2c')][_0xf917('0x2d')]);_0x43572b[_0xf917('0x32')]=_[_0xf917('0x33')](_0x11a1f8[_0xf917('0x32')]);_0x43572b[_0xf917('0x34')]=_[_0xf917('0x45')](_0x43572b[_0xf917('0x35')],_0x43572b[_0xf917('0x32')]);_0x593f22[_0xf917('0x36')]=_[_0xf917('0x45')](_0x43572b[_0xf917('0x35')],qs[_0xf917('0x46')](_0x11a1f8[_0xf917('0x32')][_0xf917('0x46')]));_0x593f22[_0xf917('0x36')]=_0x593f22[_0xf917('0x36')][_0xf917('0x37')]?_0x593f22[_0xf917('0x36')]:_0x43572b[_0xf917('0x35')];if(_0x11a1f8[_0xf917('0x32')][_0xf917('0x3f')]){_0x593f22['include']=[{'all':!![]}];}_0x593f22=_[_0xf917('0x3c')]({},_0x593f22,_0x11a1f8[_0xf917('0x3e')]);return db[_0xf917('0x2c')]['find'](_0x593f22)['then'](handleEntityNotFound(_0x2c162,null))[_0xf917('0x28')](respondWithResult(_0x2c162,null))[_0xf917('0x42')](handleError(_0x2c162,null));};exports['create']=function(_0xca5b8d,_0x42711e){return db[_0xf917('0x2c')][_0xf917('0x47')](_0xca5b8d[_0xf917('0x48')],{})[_0xf917('0x28')](respondWithResult(_0x42711e,0xc9))[_0xf917('0x42')](handleError(_0x42711e,null));};exports[_0xf917('0x27')]=function(_0x38d296,_0x49c696){if(_0x38d296[_0xf917('0x48')]['id']){delete _0x38d296[_0xf917('0x48')]['id'];}return db[_0xf917('0x2c')]['find']({'where':{'id':_0x38d296['params']['id']}})[_0xf917('0x28')](handleEntityNotFound(_0x49c696,null))[_0xf917('0x28')](saveUpdates(_0x38d296[_0xf917('0x48')],null))['then'](respondWithResult(_0x49c696,null))[_0xf917('0x42')](handleError(_0x49c696,null));};exports['destroy']=function(_0x4c179a,_0x4a6c83){return db[_0xf917('0x2c')][_0xf917('0x49')]({'where':{'id':_0x4c179a['params']['id']}})[_0xf917('0x28')](handleEntityNotFound(_0x4a6c83,null))[_0xf917('0x28')](removeEntity(_0x4a6c83,null))[_0xf917('0x42')](handleError(_0x4a6c83,null));};exports[_0xf917('0x4a')]=function(_0x43bce5,_0x1a44c3,_0x38c0fd){var _0x26cfb4={};var _0x13f0ce={};var _0x5021ec;var _0x40001c;return db['ZendeskConfiguration'][_0xf917('0x4b')]({'where':{'id':_0x43bce5[_0xf917('0x44')]['id']}})[_0xf917('0x28')](handleEntityNotFound(_0x1a44c3,null))['then'](function(_0x359999){if(_0x359999){_0x5021ec=_0x359999;_0x13f0ce[_0xf917('0x35')]=_[_0xf917('0x33')](db[_0xf917('0x4c')][_0xf917('0x2d')]);_0x13f0ce[_0xf917('0x32')]=_['keys'](_0x43bce5[_0xf917('0x32')]);_0x13f0ce[_0xf917('0x34')]=_[_0xf917('0x45')](_0x13f0ce[_0xf917('0x35')],_0x13f0ce[_0xf917('0x32')]);_0x26cfb4[_0xf917('0x36')]=_[_0xf917('0x45')](_0x13f0ce['model'],qs[_0xf917('0x46')](_0x43bce5[_0xf917('0x32')][_0xf917('0x46')]));_0x26cfb4[_0xf917('0x36')]=_0x26cfb4[_0xf917('0x36')][_0xf917('0x37')]?_0x26cfb4[_0xf917('0x36')]:_0x13f0ce['model'];_0x26cfb4[_0xf917('0x38')]=qs[_0xf917('0x39')](_0x43bce5[_0xf917('0x32')]['sort']);_0x26cfb4[_0xf917('0x3a')]=qs[_0xf917('0x34')](_['pick'](_0x43bce5[_0xf917('0x32')],_0x13f0ce[_0xf917('0x34')]));if(_0x43bce5[_0xf917('0x32')][_0xf917('0x3b')]){_0x26cfb4[_0xf917('0x3a')]=_[_0xf917('0x3c')](_0x26cfb4[_0xf917('0x3a')],{'$or':_[_0xf917('0x31')](_0x26cfb4['attributes'],function(_0x3a96ac){var _0x1c586a={};_0x1c586a[_0x3a96ac]={'$like':'%'+_0x43bce5[_0xf917('0x32')]['filter']+'%'};return _0x1c586a;})});}_0x26cfb4=_['merge']({},_0x26cfb4,_0x43bce5['options']);return _0x5021ec[_0xf917('0x4a')](_0x26cfb4);}})['then'](function(_0x8673b){if(_0x8673b){_0x40001c=_0x8673b[_0xf917('0x37')];if(!_0x43bce5[_0xf917('0x32')][_0xf917('0x4d')]('nolimit')){_0x26cfb4[_0xf917('0x1e')]=qs['limit'](_0x43bce5[_0xf917('0x32')]['limit']);_0x26cfb4['offset']=qs[_0xf917('0x21')](_0x43bce5['query']['offset']);}return _0x5021ec[_0xf917('0x4a')](_0x26cfb4);}})['then'](function(_0xedce8b){if(_0xedce8b){return _0xedce8b?{'count':_0x40001c,'rows':_0xedce8b}:null;}})[_0xf917('0x28')](respondWithResult(_0x1a44c3,null))[_0xf917('0x42')](handleError(_0x1a44c3,null));};exports[_0xf917('0x4e')]=function(_0x1edfc9,_0x488923,_0x4664f6){var _0x37c788={};var _0x395955={};var _0x5b06a3;var _0x48f311;return db['ZendeskConfiguration'][_0xf917('0x4b')]({'where':{'id':_0x1edfc9['params']['id']}})[_0xf917('0x28')](handleEntityNotFound(_0x488923,null))[_0xf917('0x28')](function(_0x15114e){if(_0x15114e){_0x5b06a3=_0x15114e;_0x395955[_0xf917('0x35')]=_[_0xf917('0x33')](db[_0xf917('0x4c')]['rawAttributes']);_0x395955['query']=_[_0xf917('0x33')](_0x1edfc9[_0xf917('0x32')]);_0x395955[_0xf917('0x34')]=_[_0xf917('0x45')](_0x395955[_0xf917('0x35')],_0x395955[_0xf917('0x32')]);_0x37c788[_0xf917('0x36')]=_['intersection'](_0x395955[_0xf917('0x35')],qs[_0xf917('0x46')](_0x1edfc9[_0xf917('0x32')]['fields']));_0x37c788[_0xf917('0x36')]=_0x37c788[_0xf917('0x36')]['length']?_0x37c788['attributes']:_0x395955['model'];_0x37c788['order']=qs[_0xf917('0x39')](_0x1edfc9['query'][_0xf917('0x39')]);_0x37c788[_0xf917('0x3a')]=qs['filters'](_['pick'](_0x1edfc9[_0xf917('0x32')],_0x395955[_0xf917('0x34')]));if(_0x1edfc9[_0xf917('0x32')][_0xf917('0x3b')]){_0x37c788[_0xf917('0x3a')]=_[_0xf917('0x3c')](_0x37c788[_0xf917('0x3a')],{'$or':_[_0xf917('0x31')](_0x37c788[_0xf917('0x36')],function(_0x29cb9d){var _0x235058={};_0x235058[_0x29cb9d]={'$like':'%'+_0x1edfc9[_0xf917('0x32')][_0xf917('0x3b')]+'%'};return _0x235058;})});}_0x37c788=_[_0xf917('0x3c')]({},_0x37c788,_0x1edfc9['options']);return _0x5b06a3['getSubjects'](_0x37c788);}})[_0xf917('0x28')](function(_0x47067a){if(_0x47067a){_0x48f311=_0x47067a[_0xf917('0x37')];if(!_0x1edfc9[_0xf917('0x32')][_0xf917('0x4d')](_0xf917('0x4f'))){_0x37c788[_0xf917('0x1e')]=qs[_0xf917('0x1e')](_0x1edfc9[_0xf917('0x32')]['limit']);_0x37c788['offset']=qs[_0xf917('0x21')](_0x1edfc9[_0xf917('0x32')][_0xf917('0x21')]);}return _0x5b06a3[_0xf917('0x4e')](_0x37c788);}})[_0xf917('0x28')](function(_0x3eaa9f){if(_0x3eaa9f){return _0x3eaa9f?{'count':_0x48f311,'rows':_0x3eaa9f}:null;}})[_0xf917('0x28')](respondWithResult(_0x488923,null))[_0xf917('0x42')](handleError(_0x488923,null));};exports[_0xf917('0x50')]=function(_0x3c9ea4,_0x187409,_0x17f7f3){var _0x54abb3={};var _0x4ac055={};var _0x4d2973;var _0x5d2130;return db['ZendeskConfiguration'][_0xf917('0x4b')]({'where':{'id':_0x3c9ea4[_0xf917('0x44')]['id']}})[_0xf917('0x28')](handleEntityNotFound(_0x187409,null))['then'](function(_0xb2fc8d){if(_0xb2fc8d){_0x4d2973=_0xb2fc8d;_0x4ac055[_0xf917('0x35')]=_['keys'](db[_0xf917('0x4c')]['rawAttributes']);_0x4ac055[_0xf917('0x32')]=_[_0xf917('0x33')](_0x3c9ea4[_0xf917('0x32')]);_0x4ac055[_0xf917('0x34')]=_[_0xf917('0x45')](_0x4ac055['model'],_0x4ac055[_0xf917('0x32')]);_0x54abb3[_0xf917('0x36')]=_[_0xf917('0x45')](_0x4ac055[_0xf917('0x35')],qs[_0xf917('0x46')](_0x3c9ea4[_0xf917('0x32')]['fields']));_0x54abb3[_0xf917('0x36')]=_0x54abb3[_0xf917('0x36')][_0xf917('0x37')]?_0x54abb3[_0xf917('0x36')]:_0x4ac055[_0xf917('0x35')];_0x54abb3['order']=qs[_0xf917('0x39')](_0x3c9ea4[_0xf917('0x32')]['sort']);_0x54abb3[_0xf917('0x3a')]=qs[_0xf917('0x34')](_['pick'](_0x3c9ea4[_0xf917('0x32')],_0x4ac055[_0xf917('0x34')]));if(_0x3c9ea4[_0xf917('0x32')][_0xf917('0x3b')]){_0x54abb3['where']=_[_0xf917('0x3c')](_0x54abb3['where'],{'$or':_['map'](_0x54abb3[_0xf917('0x36')],function(_0x371d21){var _0x1ee604={};_0x1ee604[_0x371d21]={'$like':'%'+_0x3c9ea4[_0xf917('0x32')]['filter']+'%'};return _0x1ee604;})});}_0x54abb3=_[_0xf917('0x3c')]({},_0x54abb3,_0x3c9ea4[_0xf917('0x3e')]);return _0x4d2973[_0xf917('0x50')](_0x54abb3);}})[_0xf917('0x28')](function(_0x133fa8){if(_0x133fa8){_0x5d2130=_0x133fa8[_0xf917('0x37')];if(!_0x3c9ea4['query'][_0xf917('0x4d')](_0xf917('0x4f'))){_0x54abb3[_0xf917('0x1e')]=qs[_0xf917('0x1e')](_0x3c9ea4['query'][_0xf917('0x1e')]);_0x54abb3['offset']=qs['offset'](_0x3c9ea4[_0xf917('0x32')][_0xf917('0x21')]);}return _0x4d2973[_0xf917('0x50')](_0x54abb3);}})[_0xf917('0x28')](function(_0x4ec15b){if(_0x4ec15b){return _0x4ec15b?{'count':_0x5d2130,'rows':_0x4ec15b}:null;}})[_0xf917('0x28')](respondWithResult(_0x187409,null))[_0xf917('0x42')](handleError(_0x187409,null));};exports[_0xf917('0x51')]=function(_0x253cba,_0x5b7964,_0x4d2aff){var _0x3524ca={};var _0x22505a={};var _0xf1cefe;var _0x15060b;return db[_0xf917('0x2c')]['findOne']({'where':{'id':_0x253cba[_0xf917('0x44')]['id']}})[_0xf917('0x28')](handleEntityNotFound(_0x5b7964,null))[_0xf917('0x28')](function(_0x2503c9){if(_0x2503c9){_0xf1cefe=_0x2503c9;_0x22505a[_0xf917('0x35')]=_['keys'](db[_0xf917('0x52')][_0xf917('0x2d')]);_0x22505a[_0xf917('0x32')]=_['keys'](_0x253cba['query']);_0x22505a['filters']=_[_0xf917('0x45')](_0x22505a[_0xf917('0x35')],_0x22505a[_0xf917('0x32')]);_0x3524ca['attributes']=_[_0xf917('0x45')](_0x22505a[_0xf917('0x35')],qs[_0xf917('0x46')](_0x253cba[_0xf917('0x32')][_0xf917('0x46')]));_0x3524ca['attributes']=_0x3524ca[_0xf917('0x36')]['length']?_0x3524ca[_0xf917('0x36')]:_0x22505a[_0xf917('0x35')];_0x3524ca[_0xf917('0x38')]=qs[_0xf917('0x39')](_0x253cba[_0xf917('0x32')][_0xf917('0x39')]);_0x3524ca['where']=qs['filters'](_[_0xf917('0x53')](_0x253cba['query'],_0x22505a['filters']));if(_0x253cba[_0xf917('0x32')][_0xf917('0x3b')]){_0x3524ca[_0xf917('0x3a')]=_[_0xf917('0x3c')](_0x3524ca[_0xf917('0x3a')],{'$or':_['map'](_0x3524ca[_0xf917('0x36')],function(_0x47af54){var _0x4b7468={};_0x4b7468[_0x47af54]={'$like':'%'+_0x253cba['query'][_0xf917('0x3b')]+'%'};return _0x4b7468;})});}_0x3524ca=_[_0xf917('0x3c')]({},_0x3524ca,_0x253cba['options']);return _0xf1cefe[_0xf917('0x51')](_0x3524ca);}})['then'](function(_0x3f507e){if(_0x3f507e){_0x15060b=_0x3f507e[_0xf917('0x37')];if(!_0x253cba[_0xf917('0x32')][_0xf917('0x4d')](_0xf917('0x4f'))){_0x3524ca['limit']=qs[_0xf917('0x1e')](_0x253cba[_0xf917('0x32')]['limit']);_0x3524ca[_0xf917('0x21')]=qs['offset'](_0x253cba['query'][_0xf917('0x21')]);}return _0xf1cefe[_0xf917('0x51')](_0x3524ca);}})['then'](function(_0x456ec6){if(_0x456ec6){return _0x456ec6?{'count':_0x15060b,'rows':_0x456ec6}:null;}})[_0xf917('0x28')](respondWithResult(_0x5b7964,null))[_0xf917('0x42')](handleError(_0x5b7964,null));};exports[_0xf917('0x54')]=function(_0x4ae32c,_0x3e294a,_0x4171b4){if(_0x4ae32c[_0xf917('0x48')]['id']){delete _0x4ae32c['body']['id'];}return db[_0xf917('0x2c')][_0xf917('0x4b')]({'where':{'id':_0x4ae32c[_0xf917('0x44')]['id']}})[_0xf917('0x28')](handleEntityNotFound(_0x3e294a,null))['then'](function(_0x3e2bb0){if(_0x3e2bb0){return _0x3e2bb0[_0xf917('0x54')](_0x4ae32c[_0xf917('0x48')][_0xf917('0x55')]||[]);}return null;})[_0xf917('0x28')](respondWithResult(_0x3e294a,null))[_0xf917('0x42')](handleError(_0x3e294a,null));};