Skip to content

Commit

Permalink
Merge bee9945 into b41d1be
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmwhitehead committed Jul 2, 2019
2 parents b41d1be + bee9945 commit 3b538d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions carriers/pitneyBowes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ const async = require('async');
const moment = require('moment-timezone');
const PitneyBowesClient = require('pitney-bowes');

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

// These tracking status codes indicate the shipment was shipped (shows movement beyond a shipping label being created)
const SHIPPED_TRACKING_STATUS_CODES = ['07', '80', '81', '82', 'AD', 'OF'];

const geography = require('../util/geography');

function PitneyBowes(options) {
Expand Down Expand Up @@ -62,6 +68,14 @@ function PitneyBowes(options) {
description: scanDetail.scanDescription
};

if (DELIVERED_TRACKING_STATUS_CODES.includes(scanDetail.scanType)) {
results.deliveredAt = new Date(event.date);
}

if (SHIPPED_TRACKING_STATUS_CODES.includes(scanDetail.scanType)) {
results.shippedAt = new Date(event.date);
}

// Use the city and state from the parsed address (for scenarios where the city includes the state like "New York, NY")
if (address) {
if (address.city) {
Expand Down
4 changes: 3 additions & 1 deletion test/carriers/pitneyBowes.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ describe('Newgistics', function() {
date: new Date('2019-06-25T13:09:00.000Z'),
description: 'Picked Up by Shipping Partner, USPS Awaiting Item'
}
]
],
deliveredAt: new Date('2019-06-30T18:03:00.000Z'),
shippedAt: new Date('2019-06-28T21:43:00.000Z')
};

assert.deepStrictEqual(actual, expected);
Expand Down

0 comments on commit 3b538d6

Please sign in to comment.