a6f312c09282020d507b9dabb4c2d1d98b129276
[motion2.git] / server / api / intZohoAccount / intZohoAccount.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 _0xf035=['length','pick','nolimit','addConfiguration','findOne','AccountId','Subjects','getSubjects','channel','ZohoField','Descriptions','zone','https://accounts.zoho.com','https://accounts.zoho.com.au','clientId','clientSecret','access_token','Unable\x20to\x20retrieve\x20the\x20access\x20token','getFields','host','refreshToken','serverUrl','slice','substring','lastIndexOf','Refresh\x20Token\x20not\x20available\x20for\x20the\x20account','GET','format','https://www.zohoapis.%s/crm/v2/settings/fields','Calls','Zoho-oauthtoken\x20','response','Owner','Subject','Description','Call_Duration','Call_Result','Call_Type','remove','api_name','system_mandatory','push','display_label','picklist','pick_list_values','statusCode','getFields,\x20%s,\x20%s,\x20%s','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../components/integrations/configuration','jayson/promise','test','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','end','status','json','count','offset','limit','set','Content-Range','apply','reject','save','destroy','then','sendStatus','name','send','map','fieldName','type','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','filter','VIRTUAL','merge','options','ZohoAccount','includeAll','include','findAll','rows','show','params','find','create','body','getConfigurations','ZohoConfiguration'];(function(_0x2210bd,_0x28df46){var _0x2834be=function(_0x446126){while(--_0x446126){_0x2210bd['push'](_0x2210bd['shift']());}};_0x2834be(++_0x28df46);}(_0xf035,0xb3));var _0x5f03=function(_0x41d340,_0x154c63){_0x41d340=_0x41d340-0x0;var _0x210137=_0xf035[_0x41d340];return _0x210137;};'use strict';var pdf=require(_0x5f03('0x0'));var emlformat=require(_0x5f03('0x1'));var rimraf=require(_0x5f03('0x2'));var zipdir=require(_0x5f03('0x3'));var jsonpatch=require(_0x5f03('0x4'));var rp=require(_0x5f03('0x5'));var moment=require('moment');var BPromise=require(_0x5f03('0x6'));var Mustache=require('mustache');var util=require(_0x5f03('0x7'));var path=require(_0x5f03('0x8'));var sox=require('sox');var csv=require(_0x5f03('0x9'));var ejs=require(_0x5f03('0xa'));var fs=require('fs');var _=require(_0x5f03('0xb'));var squel=require(_0x5f03('0xc'));var crypto=require(_0x5f03('0xd'));var jsforce=require(_0x5f03('0xe'));var deskjs=require(_0x5f03('0xf'));var toCsv=require(_0x5f03('0x9'));var querystring=require('querystring');var Papa=require(_0x5f03('0x10'));var Redis=require(_0x5f03('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x5f03('0x12'));var as=require(_0x5f03('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x5f03('0x14'));var utils=require(_0x5f03('0x15'));var config=require(_0x5f03('0x16'));var db=require('../../mysqldb')['db'];var integrations=require(_0x5f03('0x17'));var jayson=require(_0x5f03('0x18'));var client=jayson['client']['http']({'port':0x232a});function checkPasswordPattern(_0x549230,_0x57369b,_0x3bca2e){if(_0x3bca2e){var _0x21b1e8=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x21b1e8[_0x5f03('0x19')](_0x57369b)){return _0x549230;}else{throw new db['Sequelize'][(_0x5f03('0x1a'))](_0x5f03('0x1b'));}}else{return _0x549230;}}function respondWithRpcPromise(_0x4b35a5,_0x162b75,_0x509b68,_0xccd80){return new BPromise(function(_0x189b1b,_0x4008c5){var _0x303766=_0xccd80||client;return _0x303766['request'](_0x4b35a5,_0x509b68)['then'](function(_0xc028c1){logger[_0x5f03('0x1c')](_0x5f03('0x1d'),_0x162b75,_0x5f03('0x1e'));logger[_0x5f03('0x1f')]('ZohoAccount,\x20%s,\x20%s,\x20%s',_0x162b75,_0x5f03('0x1e'),JSON[_0x5f03('0x20')](_0xc028c1));if(_0xc028c1[_0x5f03('0x21')]){if(_0xc028c1[_0x5f03('0x21')][_0x5f03('0x22')]===0x1f4){logger[_0x5f03('0x21')](_0x5f03('0x1d'),_0x162b75,_0xc028c1[_0x5f03('0x21')][_0x5f03('0x23')]);return _0x4008c5(_0xc028c1[_0x5f03('0x21')]['message']);}logger['error'](_0x5f03('0x1d'),_0x162b75,_0xc028c1[_0x5f03('0x21')][_0x5f03('0x23')]);return _0x189b1b(_0xc028c1[_0x5f03('0x21')][_0x5f03('0x23')]);}else{logger['info'](_0x5f03('0x1d'),_0x162b75,_0x5f03('0x1e'));_0x189b1b(_0xc028c1[_0x5f03('0x24')]['message']);}})[_0x5f03('0x25')](function(_0x16a1ff){logger['error'](_0x5f03('0x1d'),_0x162b75,_0x16a1ff);_0x4008c5(_0x16a1ff);});});}function respondWithStatusCode(_0x4fb08c,_0xad965c){_0xad965c=_0xad965c||0xcc;return function(_0x58ea8b){if(_0x58ea8b){return _0x4fb08c['sendStatus'](_0xad965c);}return _0x4fb08c['status'](_0xad965c)[_0x5f03('0x26')]();};}function respondWithResult(_0x2f3ceb,_0x3d09fd){_0x3d09fd=_0x3d09fd||0xc8;return function(_0x25d68e){if(_0x25d68e){return _0x2f3ceb[_0x5f03('0x27')](_0x3d09fd)[_0x5f03('0x28')](_0x25d68e);}};}function respondWithFilteredResult(_0x39af2c,_0x25e294){return function(_0x5d900d){if(_0x5d900d){var _0x4ca12b=_0x5d900d[_0x5f03('0x29')],_0x544be2=_0x25e294[_0x5f03('0x2a')],_0x35df06=_0x25e294['offset']+_0x25e294[_0x5f03('0x2b')],_0x279c15;if(_0x35df06>=_0x4ca12b){_0x35df06=_0x4ca12b;_0x279c15=0xc8;}else{_0x279c15=0xce;}_0x39af2c[_0x5f03('0x27')](_0x279c15);return _0x39af2c[_0x5f03('0x2c')](_0x5f03('0x2d'),_0x544be2+'-'+_0x35df06+'/'+_0x4ca12b)['json'](_0x5d900d);}return null;};}function patchUpdates(_0x5ea3a9){return function(_0x814aaf){try{jsonpatch[_0x5f03('0x2e')](_0x814aaf,_0x5ea3a9,!![]);}catch(_0x2f00b4){return BPromise[_0x5f03('0x2f')](_0x2f00b4);}return _0x814aaf[_0x5f03('0x30')]();};}function saveUpdates(_0x530754,_0x5a1be8){return function(_0x4e28e5){if(_0x4e28e5){return _0x4e28e5['update'](_0x530754)['then'](function(_0x427c40){return _0x427c40;});}return null;};}function removeEntity(_0x10f033,_0x48609b){return function(_0xfd8bdc){if(_0xfd8bdc){return _0xfd8bdc[_0x5f03('0x31')]()[_0x5f03('0x32')](function(){_0x10f033['status'](0xcc)[_0x5f03('0x26')]();});}};}function handleEntityNotFound(_0x3d8b3a,_0x569750){return function(_0x107298){if(!_0x107298){_0x3d8b3a[_0x5f03('0x33')](0x194);}return _0x107298;};}function handleError(_0xfa3171,_0x3a190a){_0x3a190a=_0x3a190a||0x1f4;return function(_0x593da8){logger[_0x5f03('0x21')](_0x593da8['stack']);if(_0x593da8[_0x5f03('0x34')]){delete _0x593da8['name'];}_0xfa3171[_0x5f03('0x27')](_0x3a190a)[_0x5f03('0x35')](_0x593da8);};}exports['index']=function(_0xa51e3,_0x5f3623){var _0x556175={},_0x4ff437={},_0x406a3d={'count':0x0,'rows':[]};var _0x66b14=_[_0x5f03('0x36')](db['ZohoAccount']['rawAttributes'],function(_0x32e506){return{'name':_0x32e506[_0x5f03('0x37')],'type':_0x32e506[_0x5f03('0x38')][_0x5f03('0x39')]};});_0x4ff437[_0x5f03('0x3a')]=_['map'](_0x66b14,_0x5f03('0x34'));_0x4ff437[_0x5f03('0x3b')]=_[_0x5f03('0x3c')](_0xa51e3['query']);_0x4ff437['filters']=_[_0x5f03('0x3d')](_0x4ff437[_0x5f03('0x3a')],_0x4ff437[_0x5f03('0x3b')]);_0x556175[_0x5f03('0x3e')]=_[_0x5f03('0x3d')](_0x4ff437['model'],qs[_0x5f03('0x3f')](_0xa51e3['query'][_0x5f03('0x3f')]));_0x556175[_0x5f03('0x3e')]=_0x556175[_0x5f03('0x3e')]['length']?_0x556175['attributes']:_0x4ff437[_0x5f03('0x3a')];if(!_0xa51e3['query'][_0x5f03('0x40')]('nolimit')){_0x556175[_0x5f03('0x2b')]=qs['limit'](_0xa51e3[_0x5f03('0x3b')][_0x5f03('0x2b')]);_0x556175[_0x5f03('0x2a')]=qs[_0x5f03('0x2a')](_0xa51e3[_0x5f03('0x3b')][_0x5f03('0x2a')]);}_0x556175[_0x5f03('0x41')]=qs[_0x5f03('0x42')](_0xa51e3[_0x5f03('0x3b')]['sort']);_0x556175[_0x5f03('0x43')]=qs[_0x5f03('0x44')](_['pick'](_0xa51e3[_0x5f03('0x3b')],_0x4ff437['filters']),_0x66b14);if(_0xa51e3[_0x5f03('0x3b')][_0x5f03('0x45')]){_0x556175[_0x5f03('0x43')]=_['merge'](_0x556175[_0x5f03('0x43')],{'$or':_[_0x5f03('0x36')](_0x66b14,function(_0x241f87){if(_0x241f87[_0x5f03('0x38')]!==_0x5f03('0x46')){var _0x266e76={};_0x266e76[_0x241f87[_0x5f03('0x34')]]={'$like':'%'+_0xa51e3[_0x5f03('0x3b')][_0x5f03('0x45')]+'%'};return _0x266e76;}})});}_0x556175=_[_0x5f03('0x47')]({},_0x556175,_0xa51e3[_0x5f03('0x48')]);var _0x5e9338={'where':_0x556175['where']};return db[_0x5f03('0x49')][_0x5f03('0x29')](_0x5e9338)[_0x5f03('0x32')](function(_0x457e66){_0x406a3d[_0x5f03('0x29')]=_0x457e66;if(_0xa51e3[_0x5f03('0x3b')][_0x5f03('0x4a')]){_0x556175[_0x5f03('0x4b')]=[{'all':!![]}];}return db[_0x5f03('0x49')][_0x5f03('0x4c')](_0x556175);})[_0x5f03('0x32')](function(_0x43bd3a){_0x406a3d[_0x5f03('0x4d')]=_0x43bd3a;return _0x406a3d;})['then'](respondWithFilteredResult(_0x5f3623,_0x556175))['catch'](handleError(_0x5f3623,null));};exports[_0x5f03('0x4e')]=function(_0x2311a8,_0x3f38e9){var _0x482312={'raw':![],'where':{'id':_0x2311a8[_0x5f03('0x4f')]['id']}},_0x5b5395={};_0x5b5395[_0x5f03('0x3a')]=_[_0x5f03('0x3c')](db[_0x5f03('0x49')]['rawAttributes']);_0x5b5395[_0x5f03('0x3b')]=_[_0x5f03('0x3c')](_0x2311a8[_0x5f03('0x3b')]);_0x5b5395[_0x5f03('0x44')]=_[_0x5f03('0x3d')](_0x5b5395[_0x5f03('0x3a')],_0x5b5395[_0x5f03('0x3b')]);_0x482312[_0x5f03('0x3e')]=_['intersection'](_0x5b5395[_0x5f03('0x3a')],qs[_0x5f03('0x3f')](_0x2311a8[_0x5f03('0x3b')][_0x5f03('0x3f')]));_0x482312[_0x5f03('0x3e')]=_0x482312[_0x5f03('0x3e')]['length']?_0x482312[_0x5f03('0x3e')]:_0x5b5395['model'];if(_0x2311a8[_0x5f03('0x3b')][_0x5f03('0x4a')]){_0x482312['include']=[{'all':!![]}];}_0x482312=_[_0x5f03('0x47')]({},_0x482312,_0x2311a8[_0x5f03('0x48')]);return db[_0x5f03('0x49')][_0x5f03('0x50')](_0x482312)[_0x5f03('0x32')](handleEntityNotFound(_0x3f38e9,null))[_0x5f03('0x32')](respondWithResult(_0x3f38e9,null))[_0x5f03('0x25')](handleError(_0x3f38e9,null));};exports[_0x5f03('0x51')]=function(_0x3edbbd,_0x1df7a5){return db[_0x5f03('0x49')][_0x5f03('0x51')](_0x3edbbd[_0x5f03('0x52')],{})['then'](respondWithResult(_0x1df7a5,0xc9))[_0x5f03('0x25')](handleError(_0x1df7a5,null));};exports['update']=function(_0xd3e415,_0x497bbd){if(_0xd3e415[_0x5f03('0x52')]['id']){delete _0xd3e415[_0x5f03('0x52')]['id'];}return db[_0x5f03('0x49')][_0x5f03('0x50')]({'where':{'id':_0xd3e415[_0x5f03('0x4f')]['id']}})[_0x5f03('0x32')](handleEntityNotFound(_0x497bbd,null))[_0x5f03('0x32')](saveUpdates(_0xd3e415[_0x5f03('0x52')],null))[_0x5f03('0x32')](respondWithResult(_0x497bbd,null))['catch'](handleError(_0x497bbd,null));};exports[_0x5f03('0x31')]=function(_0x27b7f2,_0x295240){return db[_0x5f03('0x49')]['find']({'where':{'id':_0x27b7f2[_0x5f03('0x4f')]['id']}})[_0x5f03('0x32')](handleEntityNotFound(_0x295240,null))['then'](removeEntity(_0x295240,null))[_0x5f03('0x25')](handleError(_0x295240,null));};exports[_0x5f03('0x53')]=function(_0x1d8e3d,_0x210ba3,_0x3b42f3){var _0x3e122a={};var _0x5885d6={};var _0x53859b;var _0x1eda12;return db[_0x5f03('0x49')]['findOne']({'where':{'id':_0x1d8e3d['params']['id']}})['then'](handleEntityNotFound(_0x210ba3,null))[_0x5f03('0x32')](function(_0x31b8c9){if(_0x31b8c9){_0x53859b=_0x31b8c9;_0x5885d6[_0x5f03('0x3a')]=_[_0x5f03('0x3c')](db[_0x5f03('0x54')]['rawAttributes']);_0x5885d6[_0x5f03('0x3b')]=_[_0x5f03('0x3c')](_0x1d8e3d[_0x5f03('0x3b')]);_0x5885d6[_0x5f03('0x44')]=_['intersection'](_0x5885d6['model'],_0x5885d6[_0x5f03('0x3b')]);_0x3e122a[_0x5f03('0x3e')]=_[_0x5f03('0x3d')](_0x5885d6['model'],qs[_0x5f03('0x3f')](_0x1d8e3d[_0x5f03('0x3b')][_0x5f03('0x3f')]));_0x3e122a[_0x5f03('0x3e')]=_0x3e122a[_0x5f03('0x3e')][_0x5f03('0x55')]?_0x3e122a[_0x5f03('0x3e')]:_0x5885d6[_0x5f03('0x3a')];_0x3e122a[_0x5f03('0x41')]=qs['sort'](_0x1d8e3d[_0x5f03('0x3b')][_0x5f03('0x42')]);_0x3e122a[_0x5f03('0x43')]=qs[_0x5f03('0x44')](_[_0x5f03('0x56')](_0x1d8e3d[_0x5f03('0x3b')],_0x5885d6[_0x5f03('0x44')]));if(_0x1d8e3d[_0x5f03('0x3b')][_0x5f03('0x45')]){_0x3e122a[_0x5f03('0x43')]=_[_0x5f03('0x47')](_0x3e122a['where'],{'$or':_[_0x5f03('0x36')](_0x3e122a[_0x5f03('0x3e')],function(_0x8ac21){var _0x16d69b={};_0x16d69b[_0x8ac21]={'$like':'%'+_0x1d8e3d[_0x5f03('0x3b')][_0x5f03('0x45')]+'%'};return _0x16d69b;})});}_0x3e122a=_[_0x5f03('0x47')]({},_0x3e122a,_0x1d8e3d['options']);return _0x53859b[_0x5f03('0x53')](_0x3e122a);}})[_0x5f03('0x32')](function(_0x3f1c0e){if(_0x3f1c0e){_0x1eda12=_0x3f1c0e[_0x5f03('0x55')];if(!_0x1d8e3d[_0x5f03('0x3b')][_0x5f03('0x40')](_0x5f03('0x57'))){_0x3e122a[_0x5f03('0x2b')]=qs['limit'](_0x1d8e3d[_0x5f03('0x3b')]['limit']);_0x3e122a[_0x5f03('0x2a')]=qs[_0x5f03('0x2a')](_0x1d8e3d[_0x5f03('0x3b')][_0x5f03('0x2a')]);}return _0x53859b[_0x5f03('0x53')](_0x3e122a);}})['then'](function(_0x5279ae){if(_0x5279ae){return _0x5279ae?{'count':_0x1eda12,'rows':_0x5279ae}:null;}})[_0x5f03('0x32')](respondWithResult(_0x210ba3,null))[_0x5f03('0x25')](handleError(_0x210ba3,null));};exports[_0x5f03('0x58')]=function(_0xbcf9d,_0x1f9803,_0x5b78be){if(_0xbcf9d[_0x5f03('0x52')]['id']){delete _0xbcf9d[_0x5f03('0x52')]['id'];}return db[_0x5f03('0x49')][_0x5f03('0x59')]({'where':{'id':_0xbcf9d[_0x5f03('0x4f')]['id']}})[_0x5f03('0x32')](handleEntityNotFound(_0x1f9803,null))[_0x5f03('0x32')](function(_0xa9d771){if(_0xa9d771){_0xbcf9d['body'][_0x5f03('0x5a')]=_0xa9d771['id'];_0xbcf9d[_0x5f03('0x52')][_0x5f03('0x5b')]=integrations[_0x5f03('0x5c')](_0xbcf9d[_0x5f03('0x52')]['channel'],_0xbcf9d['body'][_0x5f03('0x38')]);_0xbcf9d[_0x5f03('0x52')]['Descriptions']=integrations['getDescriptions'](_0xbcf9d[_0x5f03('0x52')][_0x5f03('0x5d')],_0xbcf9d[_0x5f03('0x52')][_0x5f03('0x38')]);return db[_0x5f03('0x54')][_0x5f03('0x51')](_0xbcf9d['body'],{'include':[{'model':db['ZohoField'],'as':_0x5f03('0x5b')},{'model':db[_0x5f03('0x5e')],'as':_0x5f03('0x5f')}]});}return null;})[_0x5f03('0x32')](respondWithResult(_0x1f9803,null))[_0x5f03('0x25')](handleError(_0x1f9803,null));};function getAccessToken(_0x180865){return new Promise(function(_0x3070f3,_0x39310e){var _0x4aec83;switch(_0x180865[_0x5f03('0x60')]){case'US':_0x4aec83=_0x5f03('0x61');break;case'AU':_0x4aec83=_0x5f03('0x62');break;case'EU':_0x4aec83='https://accounts.zoho.eu';break;case'IN':_0x4aec83='https://accounts.zoho.in';break;case'CN':_0x4aec83='https://accounts.zoho.com.cn';break;default:_0x4aec83='https://accounts.zoho.eu';break;}var _0x273eb5={'method':'POST','uri':_0x4aec83+'/oauth/v2/token','qs':{'refresh_token':_0x180865['refreshToken'],'client_id':_0x180865[_0x5f03('0x63')],'client_secret':_0x180865[_0x5f03('0x64')],'grant_type':'refresh_token'},'json':!![]};return rp(_0x273eb5)[_0x5f03('0x32')](function(_0x1963f7){if(_0x1963f7[_0x5f03('0x65')]){_0x3070f3(_0x1963f7[_0x5f03('0x65')]);}else{_0x39310e(_0x5f03('0x66'));}})[_0x5f03('0x25')](function(_0xc69cff){_0x39310e(_0xc69cff);});});}exports[_0x5f03('0x67')]=function(_0x1670b0,_0x39f35b,_0x3aa085){var _0x361a92,_0x3bef3b,_0x53643f,_0x73a0b0,_0x511e60;return db[_0x5f03('0x49')][_0x5f03('0x59')]({'where':{'id':_0x1670b0['params']['id']},'attributes':['id',_0x5f03('0x68'),_0x5f03('0x60'),'clientId',_0x5f03('0x64'),'serverUrl',_0x5f03('0x22'),_0x5f03('0x69')]})['then'](handleEntityNotFound(_0x39f35b,null))['then'](function(_0x41bd1d){_0x511e60=_0x41bd1d;_0x361a92=_0x511e60[_0x5f03('0x68')];_0x3bef3b=_0x361a92==='zoho.eu'?'eu':'com';_0x53643f=_0x511e60[_0x5f03('0x6a')];var _0xc03fc7=_0x53643f[_0x5f03('0x6b')](-0x1);if(_0xc03fc7==='/'||_0xc03fc7==='\x5c'||_0xc03fc7===':'){_0x53643f=_0x53643f[_0x5f03('0x6c')](0x0,_0x53643f[_0x5f03('0x6d')](_0xc03fc7));}if(!_0x511e60[_0x5f03('0x69')]){throw new Error(_0x5f03('0x6e'));}return getAccessToken(_0x511e60);})[_0x5f03('0x32')](function(_0x1ab661){if(_0x1ab661){return rp({'method':_0x5f03('0x6f'),'uri':util[_0x5f03('0x70')](_0x5f03('0x71'),_0x3bef3b),'qs':{'module':_0x5f03('0x72')},'headers':{'Authorization':_0x5f03('0x73')+_0x1ab661},'json':!![]});}})[_0x5f03('0x32')](function(_0x2f0cba){if(_0x2f0cba){if(_0x2f0cba[_0x5f03('0x74')]&&_0x2f0cba[_0x5f03('0x74')][_0x5f03('0x21')]){throw new Error(_0x2f0cba[_0x5f03('0x74')][_0x5f03('0x21')][_0x5f03('0x23')]);}var _0x344422=[];var _0xa9c529=[];var _0x415ad0=[_0x5f03('0x75'),_0x5f03('0x76'),_0x5f03('0x77'),'WhoId',_0x5f03('0x78'),_0x5f03('0x79'),'Call_Start_Time',_0x5f03('0x7a')];_0xa9c529=_[_0x5f03('0x7b')](_0x2f0cba[_0x5f03('0x3f')],function(_0x2f3c40){return _0x415ad0['includes'](_0x2f3c40[_0x5f03('0x7c')]);});for(var _0x4b9c73=0x0;_0x4b9c73<_0xa9c529[_0x5f03('0x55')];_0x4b9c73++){if(_0xa9c529[_0x4b9c73][_0x5f03('0x7d')]===![]){_0x344422[_0x5f03('0x7e')]({'id':_0xa9c529[_0x4b9c73]['id'],'name':_0xa9c529[_0x4b9c73][_0x5f03('0x7f')],'custom':_0xa9c529[_0x4b9c73]['custom_field'],'options':_0xa9c529[_0x4b9c73]['data_type']===_0x5f03('0x80')&&_0xa9c529[_0x4b9c73]['pick_list_values'][_0x5f03('0x55')]>-0x1?_[_0x5f03('0x36')](_0xa9c529[_0x4b9c73][_0x5f03('0x81')],function(_0x2dc0cb){return{'name':_0x2dc0cb,'value':_0x2dc0cb};}):[]});}}return{'count':_0x344422[_0x5f03('0x55')],'rows':_0x344422};}else{return{'count':0x0,'rows':[]};}})[_0x5f03('0x32')](respondWithResult(_0x39f35b,null))['catch'](function(_0xeaf21d){var _0x3ca4ab=_0x1670b0['query'][_0x5f03('0x19')]?0x1f4:_0xeaf21d[_0x5f03('0x82')]||0x1f4;logger[_0x5f03('0x21')](_0x5f03('0x83'),_0x5f03('0x67'),_0x3ca4ab,JSON[_0x5f03('0x20')](_0xeaf21d));delete _0xeaf21d['name'];if(_0x3ca4ab===0x191){_0x3ca4ab=0x190;}_0x39f35b[_0x5f03('0x27')](_0x3ca4ab)[_0x5f03('0x35')](_0x1670b0[_0x5f03('0x3b')][_0x5f03('0x19')]?{'message':'Wrong\x20credentials','statusCode':_0xeaf21d[_0x5f03('0x82')]}:_0xeaf21d);});};