shipstation-node
Version:
Unofficial Node.js wrapper for the ShipStation API
67 lines (66 loc) • 2.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Rates = void 0;
const BaseResource_1 = require("../../BaseResource");
/**
* [Official Documentation](https://docs.shipstation.com/openapi/rates)
*
* Quickly compare rates using the Rates endpoint. You can see and compare rates for the carriers connected to your
* account (as long as they support sending rates).
*/
class Rates extends BaseResource_1.BaseResource {
constructor(shipstation) {
super(shipstation, 'rates');
}
/**
* [Official Documentation](https://docs.shipstation.com/openapi/rates/get_rate_by_id)
*
* Retrieve a previously queried rate by its ID
*
* @param rateId Rate ID [1-25] characters `^se(-[a-z0-9]+)+$`
* @example "se-28529731"
*
* @returns The rate specified by the ID
*/
async getById(rateId) {
return this.shipstation.request({
url: `${this.baseUrl}/${rateId}`,
method: 'GET'
});
}
/**
* [Official Documentation](https://docs.shipstation.com/openapi/rates/calculate_rates)
*
* It's not uncommon that you want to give your customer the choice between whether they want to ship the fastest,
* cheapest, or the most trusted route. Most companies don't solely ship things using a single shipping option; so we
* provide functionality to show you all your options!
*
* @param options The options for the request
*
* @returns
*/
async get(options) {
return this.shipstation.request({
url: this.baseUrl,
method: 'POST',
data: options
});
}
/**
* [Official Documentation](https://docs.shipstation.com/openapi/rates/estimate_rates)
*
* Get Rate Estimates
*
* @param options The options for the request
*
* @returns A list of rate estimates
*/
async estimate(options) {
return this.shipstation.request({
url: `${this.baseUrl}/estimate`,
method: 'POST',
data: options
});
}
}
exports.Rates = Rates;