Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / api / intServicenowAccount / intServicenowAccount.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 _0x648f=['hold_reason','knowledge','close_code','notify','incident_state','severity','parent','caused_by','upon_reject','sys_updated_on','approval_history','number','resolved_by','opened_by','user_input','sys_created_on','sys_domain','calendar_stc','cmdb_ci','delivery_plan','impact','active','business_service','sys_domain_path','rfc','expected_start','group_list','work_end','reopened_time','resolved_at','approval_set','work_notes','short_description','correlation_display','delivery_task','work_start','assignment_group','business_stc','description','calendar_duration','close_notes','follow_up','parent_incident','sys_id','contact_type','reopened_by','urgency','problem_id','company','reassignment_count','activity_due','assigned_to','comments','sla_due','approval','comments_and_work_notes','due_date','sys_mod_count','reopen_count','sys_tags','escalation','correlation_id','location','category','username','password','remoteUri','serverUrl','slice','substring','lastIndexOf','format','%s/api/now/doc/table/schema/','GET','incident?sysparm_display_value=all','result','incident\x20table\x20objects','assign','remove','forEach','label','push','all','log','TCL:\x20_object','includes','internalType','concat','ServiceNow\x20error:\x20','test','statusCode','stack','Wrong\x20credentials','boolean','True','true','False','false','sys_choice?sysparm_query=name=incident^element=','inactive','value','rimraf','request-promise','moment','bluebird','path','sox','ejs','fs-extra','lodash','squel','crypto','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','../../components/integrations/configuration','sendStatus','end','status','json','limit','undefined','count','offset','Content-Range','apply','reject','save','update','then','destroy','error','name','send','map','fieldName','key','query','keys','filters','intersection','model','fields','attributes','hasOwnProperty','nolimit','order','sort','filter','where','merge','VIRTUAL','ServicenowAccount','includeAll','include','findAll','rows','catch','show','params','rawAttributes','options','find','create','body','getConfigurations','findOne','ServicenowConfiguration','length','addConfiguration','AccountId','Subjects','getSubjects','channel','type','Descriptions','getDescriptions','ServicenowField','getFields','made_sla'];(function(_0x8c43de,_0x90ff31){var _0xa6591b=function(_0x469716){while(--_0x469716){_0x8c43de['push'](_0x8c43de['shift']());}};_0xa6591b(++_0x90ff31);}(_0x648f,0x121));var _0xf648=function(_0x154b59,_0x486801){_0x154b59=_0x154b59-0x0;var _0x496428=_0x648f[_0x154b59];return _0x496428;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xf648('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xf648('0x1'));var moment=require(_0xf648('0x2'));var BPromise=require(_0xf648('0x3'));var Mustache=require('mustache');var util=require('util');var path=require(_0xf648('0x4'));var sox=require(_0xf648('0x5'));var csv=require('to-csv');var ejs=require(_0xf648('0x6'));var fs=require('fs');var fs_extra=require(_0xf648('0x7'));var _=require(_0xf648('0x8'));var squel=require(_0xf648('0x9'));var crypto=require(_0xf648('0xa'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xf648('0xb'));var querystring=require(_0xf648('0xc'));var Papa=require(_0xf648('0xd'));var Redis=require('ioredis');var authService=require(_0xf648('0xe'));var qs=require(_0xf648('0xf'));var as=require(_0xf648('0x10'));var hardwareService=require(_0xf648('0x11'));var logger=require(_0xf648('0x12'))('api');var utils=require(_0xf648('0x13'));var config=require(_0xf648('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0xf648('0x15'))['db'];var integrations=require(_0xf648('0x16'));function respondWithStatusCode(_0x855de1,_0x1f62e4){_0x1f62e4=_0x1f62e4||0xcc;return function(_0x3c14c5){if(_0x3c14c5){return _0x855de1[_0xf648('0x17')](_0x1f62e4);}return _0x855de1['status'](_0x1f62e4)[_0xf648('0x18')]();};}function respondWithResult(_0x17ebb8,_0x11ad3b){_0x11ad3b=_0x11ad3b||0xc8;return function(_0x4e42b0){if(_0x4e42b0){return _0x17ebb8[_0xf648('0x19')](_0x11ad3b)[_0xf648('0x1a')](_0x4e42b0);}};}function respondWithFilteredResult(_0x598ef3,_0x4f4ff3){return function(_0x208458){if(_0x208458){var _0x2ed837=typeof _0x4f4ff3['offset']==='undefined'&&typeof _0x4f4ff3[_0xf648('0x1b')]===_0xf648('0x1c');var _0x3f8ec3=_0x208458[_0xf648('0x1d')];var _0x2dad21=_0x2ed837?0x0:_0x4f4ff3[_0xf648('0x1e')];var _0x56fcb4=_0x2ed837?_0x208458[_0xf648('0x1d')]:_0x4f4ff3[_0xf648('0x1e')]+_0x4f4ff3[_0xf648('0x1b')];var _0x3a1998;if(_0x56fcb4>=_0x3f8ec3){_0x56fcb4=_0x3f8ec3;_0x3a1998=0xc8;}else{_0x3a1998=0xce;}_0x598ef3[_0xf648('0x19')](_0x3a1998);return _0x598ef3['set'](_0xf648('0x1f'),_0x2dad21+'-'+_0x56fcb4+'/'+_0x3f8ec3)[_0xf648('0x1a')](_0x208458);}return null;};}function patchUpdates(_0x52235f){return function(_0x237fa1){try{jsonpatch[_0xf648('0x20')](_0x237fa1,_0x52235f,!![]);}catch(_0x4a59c5){return BPromise[_0xf648('0x21')](_0x4a59c5);}return _0x237fa1[_0xf648('0x22')]();};}function saveUpdates(_0x111cb7,_0x5983a3){return function(_0x56ac11){if(_0x56ac11){return _0x56ac11[_0xf648('0x23')](_0x111cb7)[_0xf648('0x24')](function(_0x3d1103){return _0x3d1103;});}return null;};}function removeEntity(_0x3e5945,_0x419fbb){return function(_0x57b222){if(_0x57b222){return _0x57b222[_0xf648('0x25')]()[_0xf648('0x24')](function(){_0x3e5945['status'](0xcc)[_0xf648('0x18')]();});}};}function handleEntityNotFound(_0x213ac8,_0x4f973b){return function(_0x516400){if(!_0x516400){_0x213ac8[_0xf648('0x17')](0x194);}return _0x516400;};}function handleError(_0x497e9f,_0x450c93){_0x450c93=_0x450c93||0x1f4;return function(_0x37b3a0){logger[_0xf648('0x26')](_0x37b3a0['stack']);if(_0x37b3a0[_0xf648('0x27')]){delete _0x37b3a0['name'];}_0x497e9f[_0xf648('0x19')](_0x450c93)[_0xf648('0x28')](_0x37b3a0);};}exports['index']=function(_0xd1ebdb,_0x878a45){var _0x1a6481={},_0x1c8034={},_0x3daa2e={'count':0x0,'rows':[]};var _0x1b9898=_[_0xf648('0x29')](db['ServicenowAccount']['rawAttributes'],function(_0x13cb4e){return{'name':_0x13cb4e[_0xf648('0x2a')],'type':_0x13cb4e['type'][_0xf648('0x2b')]};});_0x1c8034['model']=_[_0xf648('0x29')](_0x1b9898,_0xf648('0x27'));_0x1c8034[_0xf648('0x2c')]=_[_0xf648('0x2d')](_0xd1ebdb[_0xf648('0x2c')]);_0x1c8034[_0xf648('0x2e')]=_[_0xf648('0x2f')](_0x1c8034[_0xf648('0x30')],_0x1c8034[_0xf648('0x2c')]);_0x1a6481['attributes']=_[_0xf648('0x2f')](_0x1c8034['model'],qs[_0xf648('0x31')](_0xd1ebdb[_0xf648('0x2c')][_0xf648('0x31')]));_0x1a6481['attributes']=_0x1a6481[_0xf648('0x32')]['length']?_0x1a6481[_0xf648('0x32')]:_0x1c8034[_0xf648('0x30')];if(!_0xd1ebdb[_0xf648('0x2c')][_0xf648('0x33')](_0xf648('0x34'))){_0x1a6481[_0xf648('0x1b')]=qs[_0xf648('0x1b')](_0xd1ebdb[_0xf648('0x2c')][_0xf648('0x1b')]);_0x1a6481['offset']=qs[_0xf648('0x1e')](_0xd1ebdb[_0xf648('0x2c')]['offset']);}_0x1a6481[_0xf648('0x35')]=qs[_0xf648('0x36')](_0xd1ebdb['query'][_0xf648('0x36')]);_0x1a6481['where']=qs[_0xf648('0x2e')](_['pick'](_0xd1ebdb[_0xf648('0x2c')],_0x1c8034[_0xf648('0x2e')]),_0x1b9898);if(_0xd1ebdb[_0xf648('0x2c')][_0xf648('0x37')]){_0x1a6481[_0xf648('0x38')]=_[_0xf648('0x39')](_0x1a6481['where'],{'$or':_['map'](_0x1b9898,function(_0xefb477){if(_0xefb477['type']!==_0xf648('0x3a')){var _0x4cd249={};_0x4cd249[_0xefb477['name']]={'$like':'%'+_0xd1ebdb[_0xf648('0x2c')]['filter']+'%'};return _0x4cd249;}})});}_0x1a6481=_[_0xf648('0x39')]({},_0x1a6481,_0xd1ebdb['options']);var _0x4949cc={'where':_0x1a6481[_0xf648('0x38')]};return db[_0xf648('0x3b')][_0xf648('0x1d')](_0x4949cc)['then'](function(_0xfdc222){_0x3daa2e[_0xf648('0x1d')]=_0xfdc222;if(_0xd1ebdb['query'][_0xf648('0x3c')]){_0x1a6481[_0xf648('0x3d')]=[{'all':!![]}];}return db[_0xf648('0x3b')][_0xf648('0x3e')](_0x1a6481);})['then'](function(_0x11143b){_0x3daa2e[_0xf648('0x3f')]=_0x11143b;return _0x3daa2e;})['then'](respondWithFilteredResult(_0x878a45,_0x1a6481))[_0xf648('0x40')](handleError(_0x878a45,null));};exports[_0xf648('0x41')]=function(_0xd9cdb3,_0x4f3958){var _0x20661b={'raw':![],'where':{'id':_0xd9cdb3[_0xf648('0x42')]['id']}},_0x514050={};_0x514050['model']=_[_0xf648('0x2d')](db['ServicenowAccount'][_0xf648('0x43')]);_0x514050[_0xf648('0x2c')]=_[_0xf648('0x2d')](_0xd9cdb3[_0xf648('0x2c')]);_0x514050[_0xf648('0x2e')]=_[_0xf648('0x2f')](_0x514050['model'],_0x514050[_0xf648('0x2c')]);_0x20661b[_0xf648('0x32')]=_['intersection'](_0x514050[_0xf648('0x30')],qs[_0xf648('0x31')](_0xd9cdb3['query'][_0xf648('0x31')]));_0x20661b['attributes']=_0x20661b[_0xf648('0x32')]['length']?_0x20661b['attributes']:_0x514050[_0xf648('0x30')];if(_0xd9cdb3[_0xf648('0x2c')][_0xf648('0x3c')]){_0x20661b['include']=[{'all':!![]}];}_0x20661b=_[_0xf648('0x39')]({},_0x20661b,_0xd9cdb3[_0xf648('0x44')]);return db['ServicenowAccount'][_0xf648('0x45')](_0x20661b)[_0xf648('0x24')](handleEntityNotFound(_0x4f3958,null))[_0xf648('0x24')](respondWithResult(_0x4f3958,null))['catch'](handleError(_0x4f3958,null));};exports[_0xf648('0x46')]=function(_0x2c92cb,_0x6c87d3){return db[_0xf648('0x3b')][_0xf648('0x46')](_0x2c92cb['body'],{})[_0xf648('0x24')](respondWithResult(_0x6c87d3,0xc9))['catch'](handleError(_0x6c87d3,null));};exports[_0xf648('0x23')]=function(_0x412b70,_0x1b2c33){if(_0x412b70[_0xf648('0x47')]['id']){delete _0x412b70[_0xf648('0x47')]['id'];}return db[_0xf648('0x3b')][_0xf648('0x45')]({'where':{'id':_0x412b70[_0xf648('0x42')]['id']}})['then'](handleEntityNotFound(_0x1b2c33,null))['then'](saveUpdates(_0x412b70[_0xf648('0x47')],null))[_0xf648('0x24')](respondWithResult(_0x1b2c33,null))[_0xf648('0x40')](handleError(_0x1b2c33,null));};exports[_0xf648('0x25')]=function(_0x3d2877,_0x5c35bf){return db[_0xf648('0x3b')][_0xf648('0x45')]({'where':{'id':_0x3d2877[_0xf648('0x42')]['id']}})[_0xf648('0x24')](handleEntityNotFound(_0x5c35bf,null))['then'](removeEntity(_0x5c35bf,null))['catch'](handleError(_0x5c35bf,null));};exports[_0xf648('0x48')]=function(_0x3e297f,_0x3285ff,_0x5e417a){var _0x1eef17={};var _0x368019={};var _0x13e376;var _0x2c9d2f;return db[_0xf648('0x3b')][_0xf648('0x49')]({'where':{'id':_0x3e297f[_0xf648('0x42')]['id']}})[_0xf648('0x24')](handleEntityNotFound(_0x3285ff,null))[_0xf648('0x24')](function(_0x2128d2){if(_0x2128d2){_0x13e376=_0x2128d2;_0x368019['model']=_[_0xf648('0x2d')](db[_0xf648('0x4a')][_0xf648('0x43')]);_0x368019[_0xf648('0x2c')]=_[_0xf648('0x2d')](_0x3e297f[_0xf648('0x2c')]);_0x368019[_0xf648('0x2e')]=_[_0xf648('0x2f')](_0x368019[_0xf648('0x30')],_0x368019[_0xf648('0x2c')]);_0x1eef17['attributes']=_['intersection'](_0x368019[_0xf648('0x30')],qs[_0xf648('0x31')](_0x3e297f['query']['fields']));_0x1eef17[_0xf648('0x32')]=_0x1eef17[_0xf648('0x32')][_0xf648('0x4b')]?_0x1eef17[_0xf648('0x32')]:_0x368019[_0xf648('0x30')];_0x1eef17[_0xf648('0x35')]=qs[_0xf648('0x36')](_0x3e297f[_0xf648('0x2c')][_0xf648('0x36')]);_0x1eef17['where']=qs['filters'](_['pick'](_0x3e297f[_0xf648('0x2c')],_0x368019['filters']));if(_0x3e297f[_0xf648('0x2c')][_0xf648('0x37')]){_0x1eef17[_0xf648('0x38')]=_[_0xf648('0x39')](_0x1eef17[_0xf648('0x38')],{'$or':_[_0xf648('0x29')](_0x1eef17[_0xf648('0x32')],function(_0x5c9ae5){var _0x41f928={};_0x41f928[_0x5c9ae5]={'$like':'%'+_0x3e297f[_0xf648('0x2c')][_0xf648('0x37')]+'%'};return _0x41f928;})});}_0x1eef17=_['merge']({},_0x1eef17,_0x3e297f[_0xf648('0x44')]);return _0x13e376[_0xf648('0x48')](_0x1eef17);}})[_0xf648('0x24')](function(_0x534497){if(_0x534497){_0x2c9d2f=_0x534497[_0xf648('0x4b')];if(!_0x3e297f[_0xf648('0x2c')]['hasOwnProperty'](_0xf648('0x34'))){_0x1eef17[_0xf648('0x1b')]=qs['limit'](_0x3e297f[_0xf648('0x2c')][_0xf648('0x1b')]);_0x1eef17[_0xf648('0x1e')]=qs[_0xf648('0x1e')](_0x3e297f[_0xf648('0x2c')][_0xf648('0x1e')]);}return _0x13e376[_0xf648('0x48')](_0x1eef17);}})[_0xf648('0x24')](function(_0x11745d){if(_0x11745d){return _0x11745d?{'count':_0x2c9d2f,'rows':_0x11745d}:null;}})['then'](respondWithResult(_0x3285ff,null))[_0xf648('0x40')](handleError(_0x3285ff,null));};exports[_0xf648('0x4c')]=function(_0x24973a,_0x28dfe2,_0x55c9a8){if(_0x24973a[_0xf648('0x47')]['id']){delete _0x24973a[_0xf648('0x47')]['id'];}return db[_0xf648('0x3b')]['findOne']({'where':{'id':_0x24973a[_0xf648('0x42')]['id']}})[_0xf648('0x24')](handleEntityNotFound(_0x28dfe2,null))[_0xf648('0x24')](function(_0x1aeaf2){if(_0x1aeaf2){_0x24973a[_0xf648('0x47')][_0xf648('0x4d')]=_0x1aeaf2['id'];_0x24973a[_0xf648('0x47')][_0xf648('0x4e')]=integrations[_0xf648('0x4f')](_0x24973a[_0xf648('0x47')][_0xf648('0x50')],_0x24973a[_0xf648('0x47')][_0xf648('0x51')]);_0x24973a['body'][_0xf648('0x52')]=integrations[_0xf648('0x53')](_0x24973a[_0xf648('0x47')][_0xf648('0x50')],_0x24973a[_0xf648('0x47')][_0xf648('0x51')]);return db[_0xf648('0x4a')][_0xf648('0x46')](_0x24973a[_0xf648('0x47')],{'include':[{'model':db[_0xf648('0x54')],'as':_0xf648('0x4e')},{'model':db[_0xf648('0x54')],'as':_0xf648('0x52')}]});}return null;})[_0xf648('0x24')](respondWithResult(_0x28dfe2,null))[_0xf648('0x40')](handleError(_0x28dfe2,null));};exports[_0xf648('0x55')]=function(_0x191226,_0x13692b,_0x28b082){var _0x520620=[_0xf648('0x56'),_0xf648('0x57'),_0xf648('0x58'),'subcategory',_0xf648('0x59'),_0xf648('0x5a'),_0xf648('0x5b'),_0xf648('0x5c'),'category'];var _0x27c82e=[_0xf648('0x5d'),_0xf648('0x56'),_0xf648('0x5e'),'watch_list',_0xf648('0x5f'),_0xf648('0x60'),'child_incidents',_0xf648('0x57'),_0xf648('0x61'),_0xf648('0x62'),_0xf648('0x63'),'sys_updated_by',_0xf648('0x64'),_0xf648('0x65'),_0xf648('0x66'),_0xf648('0x67'),'state','sys_created_by','knowledge',_0xf648('0x35'),_0xf648('0x68'),'closed_at',_0xf648('0x69'),_0xf648('0x6a'),_0xf648('0x6b'),_0xf648('0x6c'),'work_notes_list',_0xf648('0x6d'),'priority',_0xf648('0x6e'),_0xf648('0x6f'),'time_worked',_0xf648('0x70'),'opened_at','business_duration',_0xf648('0x71'),_0xf648('0x72'),_0xf648('0x73'),_0xf648('0x74'),'caller_id',_0xf648('0x75'),'subcategory',_0xf648('0x76'),_0xf648('0x77'),_0xf648('0x59'),_0xf648('0x78'),_0xf648('0x79'),_0xf648('0x7a'),_0xf648('0x7b'),_0xf648('0x7c'),'additional_assignee_list',_0xf648('0x7d'),_0xf648('0x7e'),_0xf648('0x5a'),'sys_class_name',_0xf648('0x7f'),'closed_by',_0xf648('0x80'),_0xf648('0x81'),_0xf648('0x82'),_0xf648('0x83'),_0xf648('0x84'),_0xf648('0x5b'),_0xf648('0x85'),_0xf648('0x86'),_0xf648('0x87'),_0xf648('0x88'),_0xf648('0x89'),_0xf648('0x8a'),'severity',_0xf648('0x8b'),_0xf648('0x8c'),_0xf648('0x8d'),_0xf648('0x8e'),_0xf648('0x8f'),_0xf648('0x90'),_0xf648('0x91'),_0xf648('0x92'),_0xf648('0x93'),'upon_approval',_0xf648('0x94'),_0xf648('0x95'),_0xf648('0x96')];var _0x1a1568='';var _0xd22f7d='';var _0x458c35=[];var _0x5de2cf='';var _0x329c95='';var _0x547871=[];var _0x4f77b4='';var _0x97a4c7='';var _0x1fdab7={};var _0x37f6c2='';return db[_0xf648('0x3b')]['findOne']({'where':{'id':_0x191226[_0xf648('0x42')]['id']},'attributes':['id',_0xf648('0x97'),_0xf648('0x98'),'email',_0xf648('0x99'),_0xf648('0x9a')]})[_0xf648('0x24')](handleEntityNotFound(_0x13692b,null))[_0xf648('0x24')](function(_0x1f3a46){if(_0x1f3a46){_0x37f6c2=_0x1f3a46['remoteUri'];var _0x1f4977=_0x37f6c2[_0xf648('0x9b')](-0x1);if(_0x1f4977==='/'){_0x37f6c2=_0x37f6c2[_0xf648('0x9c')](0x0,_0x37f6c2[_0xf648('0x9d')](_0x1f4977));}_0x97a4c7=util[_0xf648('0x9e')](_0xf648('0x9f'),_0x37f6c2);_0x4f77b4=util[_0xf648('0x9e')]('%s/api/now/table/',_0x37f6c2);_0x1fdab7={'user':_0x1f3a46['username'],'pass':_0x1f3a46[_0xf648('0x98')]};var _0x1ab38b={'method':_0xf648('0xa0'),'uri':_0x97a4c7+_0xf648('0xa1'),'auth':_0x1fdab7,'json':!![]};return rp(_0x1ab38b);}})[_0xf648('0x24')](function(_0x26df5d){if(_0x26df5d[_0xf648('0xa2')][_0xf648('0x4b')]>0x0){_0x1a1568=_0x26df5d[_0xf648('0xa2')];}console['log'](_0xf648('0xa3'),_0x1a1568);_0x547871=[];_0xd22f7d=Object[_0xf648('0xa4')]([],_0x1a1568);_[_0xf648('0xa5')](_0xd22f7d,function(_0x5372ce){return!_0x520620['includes'](_0x5372ce['name']);});_0xd22f7d[_0xf648('0xa6')](function(_0x506ef2){var _0x56baac=createFieldObject(_0x4f77b4,_0x1fdab7,_0x506ef2['internalType'],_0x506ef2[_0xf648('0x27')],_0x506ef2[_0xf648('0xa7')],![]);_0x547871[_0xf648('0xa8')](_0x56baac);});return Promise[_0xf648('0xa9')](_0x547871);})[_0xf648('0x24')](function(_0xfd3a39){_0x458c35=_0xfd3a39;_0x5de2cf=Object[_0xf648('0xa4')]([],_0x1a1568);console[_0xf648('0xaa')](_0xf648('0xab'),_0x1a1568);_[_0xf648('0xa5')](_0x5de2cf,function(_0x2d1f48){return _0x27c82e[_0xf648('0xac')](_0x2d1f48[_0xf648('0x27')]);});console[_0xf648('0xaa')]('TCL:\x20exports.getEntityFields\x20->\x20_objectsCustom',_0x5de2cf);_0x547871=[];_0x5de2cf[_0xf648('0xa6')](function(_0x20b331){var _0xc21b=createFieldObject(_0x4f77b4,_0x1fdab7,_0x20b331[_0xf648('0xad')],_0x20b331[_0xf648('0x27')],_0x20b331[_0xf648('0xa7')],!![]);_0x547871[_0xf648('0xa8')](_0xc21b);});return Promise[_0xf648('0xa9')](_0x547871);})[_0xf648('0x24')](function(_0x3751ca){_0x329c95=_0x3751ca;var _0x493d57=_0x458c35[_0xf648('0xae')](_0x329c95);return{'count':_0x493d57[_0xf648('0x4b')],'rows':_0x493d57};})['then'](respondWithResult(_0x13692b,null))[_0xf648('0x40')](function(_0x2795ee){console['log'](_0xf648('0xaf')+_0x2795ee);var _0x43fe7f=_0x191226[_0xf648('0x2c')][_0xf648('0xb0')]?0x1f4:_0x2795ee[_0xf648('0xb1')]||0x1f4;logger[_0xf648('0x26')](_0x2795ee[_0xf648('0xb2')]);delete _0x2795ee[_0xf648('0x27')];if(_0x43fe7f===0x191){_0x43fe7f=0x190;}_0x13692b[_0xf648('0x19')](_0x43fe7f)[_0xf648('0x28')](_0x191226[_0xf648('0x2c')][_0xf648('0xb0')]?{'message':_0xf648('0xb3'),'statusCode':_0x2795ee[_0xf648('0xb1')]}:_0x2795ee);});};function createFieldObject(_0x326a2e,_0x2e5927,_0x3055a2,_0x3853f0,_0x24f02b,_0x377a53){return new Promise(function(_0x14314e,_0x73dee4){var _0x305299={'id':_0x3853f0,'name':_0x24f02b,'custom':_0x377a53};if(_0x3055a2===_0xf648('0xb4')){_0x305299['options']=[{'name':_0xf648('0xb5'),'value':_0xf648('0xb6')},{'name':_0xf648('0xb7'),'value':_0xf648('0xb8')}];_0x14314e(_0x305299);}else{var _0x2ad2a0={'method':'GET','uri':_0x326a2e+_0xf648('0xb9')+_0x3853f0,'auth':_0x2e5927,'json':!![]};return rp(_0x2ad2a0)['then'](function(_0x56ade7){var _0x1acd14=[];if(_0x56ade7[_0xf648('0xa2')][_0xf648('0x4b')]>0x0){_0x56ade7[_0xf648('0xa2')]['forEach'](function(_0x1b6dcc){if(_0x1b6dcc[_0xf648('0xba')]===_0xf648('0xb8')){var _0x4bc1eb={'name':_0x1b6dcc[_0xf648('0xa7')],'value':_0x1b6dcc[_0xf648('0xbb')]};_0x1acd14[_0xf648('0xa8')](_0x4bc1eb);}});}_0x305299[_0xf648('0x44')]=_0x1acd14;if(_0x305299[_0xf648('0x44')][_0xf648('0x4b')]>0x0){_0x14314e(_0x305299);}else{if(_0x377a53==![]){_0x14314e();}else{_0x14314e(_0x305299);}}});}});}