EasyPost/easypost-node

Updating Shipment Parcel for new rate

Closed this issue · 1 comments

Good evening! I am using the easypost api for a project and after searching through the documentation I wanted to ask a question about specific functionality. For the EasyPost rates, I see that you have a method for retrieving the rates of a specific shipment like this:

const Easypost = require('@easypost/api');
const api = new Easypost('<YOUR_TEST/PRODUCTION_API_KEY>');

api.Shipment.retrieve('shp_...').then(s => {
  s.regenerateRates()
    .then(s => console.dir(s.rates, {
      depth: null,
    }));
});  

However, I wanted to ask is there a way to update the rates on a shipment after it has been created via editing the parcel weight? Something along the lines of this:

const Easypost = require('@easypost/api');
const api = new Easypost('<YOUR_TEST/PRODUCTION_API_KEY>');

api.Shipment.retrieve('shp_...').then(s => {
s.updateParcel({weight: NewWeight});
});  

Is there anything to what I typed out above? My goal is to be able to update a shipment and retrieve the new rates for that updated shipment, and to achieve this without having to create an entirely new shipment with the updated data. Is this possible with the API and if so how?

Thank you in advance! Michael

Please reach out to support@easypost.com for questions like this since it is not an issue on the repository.

EasyPost objects are designed to be immutable and can not be modified after creation. You can re-rate shipments as seen in https://github.com/EasyPost/easypost-node/blob/master/src/resources/shipment.js#L104
https://github.com/EasyPost/easypost-node/blob/master/test/resources/shipment.js#L207