@easypost/api
Advanced tools
Comparing version 3.11.2 to 4.0.0
## CHANGELOG | ||
## 4.0.0 2021-10-06 | ||
* JSON encodes POST bodies instead of form encoding them by default | ||
* Adds support for `tax_identifiers` | ||
* The `regenerateRates` method now makes a post request to re-rate a shipment. The new `retrieveRates` will simply retrieve the rates of a shipment without re-rating | ||
* Ran `npm audit fix` to bump patch versions of dependencies | ||
## 3.11.2 2021-06-11 | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@easypost/api", | ||
"description": "EasyPost Node Client Library", | ||
"version": "3.11.2", | ||
"version": "4.0.0", | ||
"author": "Easypost Engineering <support@easypost.com>", | ||
@@ -40,7 +40,7 @@ "homepage": "https://easypost.com", | ||
"@babel/core": "^7.7.5", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.7.4", | ||
"@babel/plugin-proposal-optional-chaining": "^7.7.4", | ||
"@babel/plugin-proposal-class-properties": "^7.7.4", | ||
"@babel/plugin-proposal-export-default-from": "^7.7.4", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.7.4", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.7.4", | ||
"@babel/plugin-proposal-optional-chaining": "^7.7.4", | ||
"@babel/plugin-syntax-export-extensions": "^7.0.0-beta.32", | ||
@@ -74,3 +74,3 @@ "@babel/plugin-transform-react-constant-elements": "^7.7.4", | ||
"sinon-chai": "^3.3.0", | ||
"vows": "^0.8.2", | ||
"vows": "^0.8.3", | ||
"webpack": "^4.39.3", | ||
@@ -77,0 +77,0 @@ "webpack-cli": "^3.3.10", |
@@ -42,36 +42,58 @@ # EasyPost Node Client Library | ||
```javascript | ||
const apiKey = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'; | ||
const EasyPost = require('@easypost/api'); | ||
const api = new EasyPost(apiKey); | ||
const api = new EasyPost('API_KEY'); | ||
// set addresses | ||
const toAddress = new api.Address({ | ||
name: 'Dr. Steve Brule', | ||
street1: '179 N Harbor Dr', | ||
city: 'Redondo Beach', | ||
state: 'CA', | ||
zip: '90277', | ||
country: 'US', | ||
phone: '310-808-5243' | ||
}); | ||
const shipment = new api.Shipment({ | ||
to_address: { | ||
name: 'Dr. Steve Brule', | ||
street1: '179 N Harbor Dr', | ||
city: 'Redondo Beach', | ||
state: 'CA', | ||
zip: '90277', | ||
country: 'US', | ||
phone: '4155559999', | ||
}, | ||
from_address: { | ||
street1: '417 MONTGOMERY ST', | ||
street2: 'FLOOR 5', | ||
city: 'SAN FRANCISCO', | ||
state: 'CA', | ||
zip: '94104', | ||
country: 'US', | ||
company: 'EasyPost', | ||
phone: '415-123-4567', | ||
}, | ||
parcel: { | ||
length: 8, | ||
width: 5, | ||
height: 5, | ||
weight: 5 | ||
}, | ||
customs_info: { | ||
eel_pfc: 'NOEEI 30.37(a)', | ||
customs_certify: true, | ||
customs_signer: 'Steve Brule', | ||
contents_type: 'merchandise', | ||
contents_explanation: '', | ||
restriction_type: 'none', | ||
restriction_comments: '', | ||
non_delivery_option: 'abandon', | ||
declaration: 'Here is a bunch of information...', | ||
const fromAddress = new api.Address({ | ||
name: 'EasyPost', | ||
street1: '118 2nd Street', | ||
street2: '4th Floor', | ||
city: 'San Francisco', | ||
state: 'CA', | ||
zip: '94105', | ||
phone: '415-123-4567' | ||
customs_items: [ | ||
new api.CustomsItem({ | ||
'description': 'Sweet shirts 1', | ||
'quantity': 2, | ||
'weight': 11, | ||
'value': 23, | ||
'hs_tariff_number': '654321', | ||
'origin_country': 'US', | ||
'code': '123' | ||
}), | ||
] | ||
} | ||
}); | ||
/* es5 with promises: */ | ||
fromAddress.save().then(addr => { | ||
console.log(addr.id); | ||
}); | ||
/* es2017 with async/await: */ | ||
await fromAddress.save(); | ||
console.log(fromAddress.id); | ||
shipment.save().then(s => s.buy(shipment.lowestRate()).then(console.log).catch(console.log)) | ||
``` | ||
@@ -78,0 +100,0 @@ |
@@ -44,4 +44,5 @@ import os from 'os'; | ||
export const DEFAULT_HEADERS = { | ||
Accept: 'application/json', | ||
'Accept-Encoding': 'gzip,deflate,sdch,br', | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
'Content-Type': 'application/json', | ||
'User-Agent': `EasyPost/v2 NodejsClient/${pkg.version}`, | ||
@@ -178,4 +179,2 @@ [EASYPOST_UA_HEADER]: JSON.stringify(UA_INFO), | ||
let req = this.agent[method](this.buildPath(path)) | ||
.accept('json') | ||
.set('Content-Type', 'application/json') | ||
.set(API.buildHeaders(headers)); | ||
@@ -182,0 +181,0 @@ |
@@ -46,2 +46,3 @@ import T from 'proptypes'; | ||
batch_message: T.string, | ||
tax_identifiers: T.arrayOf(T.object), | ||
}; | ||
@@ -106,3 +107,3 @@ | ||
async regenerateRates() { | ||
async retrieveRates() { | ||
this.verifyParameters({ | ||
@@ -115,2 +116,10 @@ this: ['id'], | ||
async regenerateRates() { | ||
this.verifyParameters({ | ||
this: ['id'], | ||
}); | ||
return this.rpc('rerate', undefined, undefined, 'post'); | ||
} | ||
async getSmartrates() { | ||
@@ -117,0 +126,0 @@ this.verifyParameters({ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
916847
72
9645
219