Skip to content

Commit

Permalink
Remove logs
Browse files Browse the repository at this point in the history
  • Loading branch information
SushilMallRC committed Sep 20, 2024
1 parent dfab2df commit 15eb9b3
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/adapters/netsuite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ async function getOauthInfo({ hostname }) {

async function getUserInfo({ authHeader, additionalInfo, query }) {
try {
console.log({ message: "Going to find employee informaton", entityId: maskLastThreeDigits(query?.entity) });
const url = `https://${query.hostname.split(".")[0]}.suitetalk.api.netsuite.com/services/rest/record/v1/employee/${query.entity}`;
const employeResponse = await axios.get(url,
{
headers: { 'Authorization': authHeader }
});
const id = query.entity;
console.log({ message: "Employee Details fetched", id: maskLastThreeDigits(id) });
const name = employeResponse.data.firstName + ' ' + employeResponse.data.lastName;
const timezoneName = employeResponse.data.time_zone ?? '';
const timezoneOffset = employeResponse.data.time_zone_offset ?? null;
Expand Down Expand Up @@ -61,7 +59,7 @@ async function getUserInfo({ authHeader, additionalInfo, query }) {
const errorMessage = isForbiddenError
? "Permission violation: Make Sure You have 'Lists -> Employee Record & Lists -> Employee' permission to authorize. Please contact your administrator."
: "Error in getting NetSuite User Info.";
console.log({ message: "Error in getting employee informaton", error });
console.log({ message: "Error in getting employee information", error });
return {
successful: false,
returnMessage: {
Expand Down Expand Up @@ -99,7 +97,6 @@ async function findContact({ user, authHeader, phoneNumber, overridingFormat })
try {
const phoneNumberObj = parsePhoneNumber(phoneNumber.replace(' ', '+'));
const phoneNumberWithoutCountryCode = phoneNumberObj.number.significant;
console.log({ message: "Finding contact", phoneNumber: maskLastThreeDigits(phoneNumberWithoutCountryCode) });
const matchedContactInfo = [];
if (phoneNumberWithoutCountryCode !== 'undefined' && phoneNumberWithoutCountryCode !== null && phoneNumberWithoutCountryCode !== '') {
const contactQuery = `SELECT * FROM contact WHERE REGEXP_REPLACE(phone, '[^0-9]', '') LIKE '%${phoneNumberWithoutCountryCode}%' OR REGEXP_REPLACE(homePhone, '[^0-9]', '') LIKE '%${phoneNumberWithoutCountryCode}%' OR REGEXP_REPLACE(mobilePhone, '[^0-9]', '') LIKE '%${phoneNumberWithoutCountryCode}%' OR REGEXP_REPLACE(officePhone, '[^0-9]', '') LIKE '%${phoneNumberWithoutCountryCode}%'`;
Expand Down Expand Up @@ -168,7 +165,6 @@ async function findContact({ user, authHeader, phoneNumber, overridingFormat })
matchedContactInfo,
};
} catch (error) {
console.log({ message: "Error in finding contact", error });
const isForbiddenError = isNetSuiteForbiddenError(error);
const errorMessage = isForbiddenError
? "Permission violation: Make Sure You have 'Reports -> SuiteAnalytics Workbook, Lists -> Contacts & Lists -> Customer' permission to fetch details. Please contact your administrator."
Expand Down Expand Up @@ -256,7 +252,6 @@ async function createCallLog({ user, contactInfo, authHeader, callLog, note, add
}
};
} catch (error) {
console.log({ message: "Error in creating call log", error });
const isForbiddenError = isNetSuiteForbiddenError(error);
const errorMessage = isForbiddenError
? "Permission violation: Make Sure You have 'Lists -> Phone Calls, Lists -> Contacts & Lists -> Customers' permission to CallLog. Please contact your administrator."
Expand Down Expand Up @@ -292,7 +287,6 @@ async function getCallLog({ user, callLogId, authHeader }) {
}
}
} catch (error) {
console.log({ message: "Error in getting call log", error });
const isForbiddenError = isNetSuiteForbiddenError(error);
const errorMessage = isForbiddenError
? "Permission violation: Make Sure You have 'Lists -> Phone Calls, Lists -> Contacts & Lists -> Customers' permission to CallLog. Please contact your administrator."
Expand Down Expand Up @@ -350,7 +344,6 @@ async function updateCallLog({ user, existingCallLog, authHeader, recordingLink,
}
};
} catch (error) {
console.log({ message: "Error in updating call log", error });
const isForbiddenError = isNetSuiteForbiddenError(error);
const errorMessage = isForbiddenError
? "Permission violation: Make Sure You have 'Lists -> Phone Calls, Lists -> Contacts & Lists -> Customers' permission to CallLog. Please contact your administrator."
Expand Down Expand Up @@ -443,7 +436,6 @@ async function createMessageLog({ user, contactInfo, authHeader, message, additi
}
};
} catch (error) {
console.log({ message: "Error in creating message log", error });
const isForbiddenError = isNetSuiteForbiddenError(error);
const errorMessage = isForbiddenError
? "Permission violation: Make Sure You have 'Lists -> Phone Calls, Lists -> Contacts & Lists -> Customers' permission to Message Log. Please contact your administrator."
Expand Down Expand Up @@ -494,7 +486,6 @@ async function updateMessageLog({ user, contactInfo, existingMessageLog, message
}
};
} catch (error) {
console.log({ message: "Error in updating message log", error });
const isForbiddenError = isNetSuiteForbiddenError(error);
const errorMessage = isForbiddenError
? "Permission violation: Make Sure You have 'Lists -> Phone Calls, Lists -> Contacts & Lists -> Customers' permission to MessageLog. Please contact your administrator."
Expand Down Expand Up @@ -622,7 +613,6 @@ async function createContact({ user, authHeader, phoneNumber, newContactName, ne
}
}
} catch (error) {
console.log({ message: "Error in creating contact", error });
const isForbiddenError = isNetSuiteForbiddenError(error);
const errorMessage = isForbiddenError
? "Permission violation: Make Sure You have 'Lists -> Contacts & Lists -> Customers' permission to Create Contact/Customer. Please contact your administrator."
Expand Down Expand Up @@ -676,14 +666,6 @@ function isNetSuiteForbiddenError(error) {
}
}

function maskLastThreeDigits(number) {
try {
let numberStr = number.toString();
return numberStr.slice(0, -3) + '***';
} catch (err) {
return number;
}
}

exports.getAuthType = getAuthType;
exports.getOauthInfo = getOauthInfo;
Expand Down

0 comments on commit 15eb9b3

Please sign in to comment.