Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ups support #8

Merged
merged 47 commits into from Jul 19, 2019
Merged

Ups support #8

merged 47 commits into from Jul 19, 2019

Conversation

ajsalagundi1
Copy link

No description provided.

@jknguyen22 jknguyen22 mentioned this pull request Jul 8, 2019
carriers/ups.js Outdated
function filter(res) {
const packageInfo = res.body.TrackResponse.Shipment.Package;
var activitiesList = [];
if(packageInfo === undefined){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if( should be if ( (needs a space)
I'm wondering if the ESLint rules for this project are missing/incorrect. There are a few lines (like this one) that should be throwing ESLint errors per our current style.
@freshlogic space-after-if and no-space-after-function seem to be missing (I made those names up), right?

carriers/ups.js Outdated
} else {
packageInfo.forEach((package) => {
activitiesList.push(getActivities(package));
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing ;

carriers/ups.js Outdated
return callback(null, results);
}

if (res && res.body && res.body.Fault && res.body.Fault.detail && res.body.Fault.detail.Errors && res.body.Fault.detail.Errors.ErrorDetail && res.body.Fault.detail.Errors.ErrorDetail.PrimaryErrorCode && res.body.Fault.detail.Errors.ErrorDetail.PrimaryErrorCode.Description) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of one at the moment, but I wish there was a better way to do this that didn't involve so many expressions in the conditional. We do this sort of stuff often, but it's usually not so deep.
Not sure we need to change it, but I couldn't not say anything?

carriers/ups.js Outdated
activitiesList.forEach(activities => {
locations = Array.from(new Set(activities.map(activity => activity.location)));
getResults(locations, callback, results, activities);
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;

if (checkDigit(trackingNumber, [3, 1, 7], 10)) { return [true, true]; }
return [false, false];


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run auto-format on this? (extra lines and 1-line if on line 6 will probably get auto-fixed)

Copy link
Member

@freshlogic freshlogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs updated README

carriers/ups.js Outdated
activity.location = geography.addressToString(activity.address);
} else {
activity.address = {
city: '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use empty string to represent null or undefined: https://coding.abel.nu/2013/01/on-null-or-why-empty-strings-are-not-same-as-null/

carriers/ups.js Outdated
activitiesList.forEach(activity => {
if (activity.ActivityLocation != undefined) {
activity.address = {
city: activity.ActivityLocation.Address === undefined ? (activity.ActivityLocation.City === undefined ? '' : activity.ActivityLocation.City) : (activity.ActivityLocation.Address.City === undefined ? '' : activity.ActivityLocation.Address.City),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very similar to the code on line 67 but doesn't look quite identical. This is usually the sign of a subtle bug. What is this code trying to accomplish?

carriers/ups.js Outdated
const firstChar = `${(trackingNumber.charCodeAt(0) - 63) % 10}`;
const remaining = trackingNumber.slice(1);
trackingNumber = `${firstChar}${remaining}`;
if (checkDigit(trackingNumber, [3, 1, 7], 10)) { return [true, true]; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return [true, true]?

@@ -94,6 +94,8 @@ function USPS(options) {

const trackDetailList = data.TrackResponse.TrackInfo[0].TrackDetail;

//console.log(data.TrackResponse.TrackInfo[0].TrackDetail);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console.logs (even if they're comments)

@@ -4,7 +4,7 @@
"async": "~3.1.0",
"moment-timezone": "~0.5.25",
"node-geocoder": "~3.23.0",
"petty-cache": "~2.4.1",
"petty-cache": "^2.4.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change ~ to ^?

@freshlogic freshlogic merged commit d87d52d into master Jul 19, 2019
@freshlogic freshlogic deleted the ups-support branch July 19, 2019 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants