Skip to content

Commit

Permalink
Merge branch 'master' into README-Draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenny committed Jul 8, 2019
2 parents 16d4011 + 57cc925 commit 561c0b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion carriers/pitneyBowes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const async = require('async');
const moment = require('moment-timezone');
const PitneyBowesClient = require('pitney-bowes');

// Remove these words from cities to turn cities like `DISTRIBUTION CENTER INDIANAPOLIS` into `INDIANAPOLIS`
const CITY_BLACKLIST = /DISTRIBUTION CENTER|INTERNATIONAL DISTRIBUTION CENTER|NETWORK DISTRIBUTION CENTER/ig;

// These tracking status codes indicate the shipment was delivered
const DELIVERED_TRACKING_STATUS_CODES = ['01'];

Expand Down Expand Up @@ -29,10 +32,19 @@ function PitneyBowes(options) {
return callback(null, results);
}

data.scanDetailsList = data.scanDetailsList.filter(scanDetail => {
// Remove scan details without cities
if (!scanDetail.eventCity) {
return false;
}

return true;
});

// Set address and location of each scan detail
data.scanDetailsList.forEach(scanDetail => {
scanDetail.address = {
city: scanDetail.eventCity,
city: scanDetail.eventCity.replace(CITY_BLACKLIST, '').trim(),
country: scanDetail.country,
state: scanDetail.eventStateOrProvince,
zip: scanDetail.postalCode
Expand Down
2 changes: 1 addition & 1 deletion carriers/usps.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const checkDigit = require('../util/checkDigit');
const geography = require('../util/geography');

// Remove these words from cities to turn cities like `DISTRIBUTION CENTER INDIANAPOLIS` into `INDIANAPOLIS`
const CITY_BLACKLIST = /DISTRIBUTION CENTER|NETWORK DISTRIBUTION CENTER/ig;
const CITY_BLACKLIST = /DISTRIBUTION CENTER|INTERNATIONAL DISTRIBUTION CENTER|NETWORK DISTRIBUTION CENTER/ig;

// These tracking status codes indicate the shipment was delivered: https://about.usps.com/publications/pub97/pub97_appi.htm
const DELIVERED_TRACKING_STATUS_CODES = ['01'];
Expand Down

0 comments on commit 561c0b1

Please sign in to comment.