pitney-bowes
Advanced tools
Comparing version 0.0.1 to 0.0.2
40
index.js
@@ -9,3 +9,4 @@ const cache = require('memory-cache'); | ||
api_secret: '', | ||
baseUrl: 'https://api-sandbox.pitneybowes.com/shippingservices' | ||
baseUrl: 'https://api-sandbox.pitneybowes.com/shippingservices', | ||
baseTestUrl: 'https://api-test.pitneybowes.com' | ||
}, args); | ||
@@ -50,3 +51,3 @@ | ||
this.tracking = function(args, callback) { | ||
this.getOAuthToken(function(err, token) { | ||
this.getOAuthToken(function(err, oAuthToken) { | ||
if (err) { | ||
@@ -58,3 +59,3 @@ return callback(err); | ||
auth: { | ||
bearer: token.access_token | ||
bearer: oAuthToken.access_token | ||
}, | ||
@@ -83,3 +84,3 @@ json: true, | ||
method: 'GET', | ||
url: 'https://api-test.pitneybowes.com/tlstest' | ||
url: `${options.baseTestUrl}/tlstest` | ||
}; | ||
@@ -93,3 +94,3 @@ | ||
if (res.statusCode !== 200) { | ||
return callback(createError(res.statusCode, res.body)); | ||
return callback(createError(res.statusCode)); | ||
} | ||
@@ -100,4 +101,33 @@ | ||
}; | ||
this.validateAddress = function(args, callback) { | ||
this.getOAuthToken(function(err, oAuthToken) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
const req = { | ||
auth: { | ||
bearer: oAuthToken.access_token | ||
}, | ||
json: args.address, | ||
method: 'POST', | ||
url: `${options.baseUrl}/v1/addresses/verify?minimalAddressValidation=${args.minimalAddressValidation || false}` | ||
}; | ||
request(req, function(err, res, body) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
if (res.statusCode !== 200) { | ||
return callback(createError(res.statusCode, body)); | ||
} | ||
callback(null, body); | ||
}); | ||
}); | ||
}; | ||
} | ||
module.exports = PitneyBowes; |
@@ -30,3 +30,3 @@ { | ||
}, | ||
"version": "0.0.1" | ||
"version": "0.0.2" | ||
} |
@@ -6,4 +6,6 @@ # pitney-bowes | ||
The Pitney Bowes Complete Shipping APIs let you integrate shipping services from multiple carriers, including USPS® and Newgistics®, into your services and applications. | ||
The Pitney Bowes Complete Shipping APIs let you integrate shipping services from multiple carriers, including USPS® and Newgistics®, into your services and applications. | ||
https://shipping.pitneybowes.com | ||
## Usage | ||
@@ -14,3 +16,3 @@ | ||
var pitneyBowes = new PitneyBowes({ | ||
const pitneyBowes = new PitneyBowes({ | ||
api_key: 'your_api_key', | ||
@@ -56,2 +58,28 @@ api_secret: 'your_api_secret', | ||
}); | ||
``` | ||
### pitneyBowes.validateAddress(args, callback) | ||
Address validation verifies and cleanses postal addresses within the United States to help ensure packages are rated accurately and shipments arrive at their final destinations on time. The Validate Address operation sends an address to be verified. The response indicates whether the address is valid and whether the validation check made changes to the address. | ||
**Example** | ||
```javascript | ||
const address = { | ||
addressLines: [ | ||
'1600 Pennsylvania Avenue NW' | ||
], | ||
cityTown: 'Washington', | ||
stateProvince: 'DC', | ||
postalCode: '20500 ', | ||
countryCode: 'US', | ||
company: 'Pitney Bowes Inc.', | ||
name: 'John Doe', | ||
phone: '203-000-0000', | ||
email: 'john.d@example.com' | ||
}; | ||
pitneyBowes.validateAddress({ address, minimalAddressValidation: false }, function(err, data) { | ||
console.log(data); | ||
}); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19446
5
126
82