shipstation-node
Version:
Unofficial Node.js wrapper for the ShipStation API
90 lines (89 loc) • 2.85 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PackageTypes = void 0;
const BaseResource_1 = require("../../BaseResource");
/**
* [Official Documentation](https://docs.shipstation.com/openapi/package_types)
*
* Create custom package types to use for your shipments, rather than the carriers' default package types.
*/
class PackageTypes extends BaseResource_1.BaseResource {
constructor(shipstation) {
super(shipstation, 'packages');
}
/**
* [Official Documentation](https://docs.shipstation.com/openapi/package_types/list_package_types)
*
* List the custom package types associated with the account
*
* @returns Package pickup details
*/
async list() {
return this.shipstation.request({
url: this.baseUrl,
method: 'GET'
});
}
/**
* [Official Documentation](https://docs.shipstation.com/openapi/package_types/create_package_type)
*
* Create a custom package type
*
* @param data Data for creating the package type
*
* @returns The newly created package type
*/
async create(data) {
return this.shipstation.request({
url: this.baseUrl,
method: 'POST',
data
});
}
/**
* [Official Documentation](https://docs.shipstation.com/openapi/package_types/get_package_type_by_id)
*
* Get Custom Package Type by ID
*
* @param packageId ID of the package type to get [1-25] characters `^se(-[a-z0-9]+)+$`
*
* @returns The package type with the given ID
*/
async getById(packageId) {
return this.shipstation.request({
url: `${this.baseUrl}/${packageId}`,
method: 'GET'
});
}
/**
* [Official Documentation](https://docs.shipstation.com/openapi/package_types/update_package_type)
*
* Update the custom package type object by ID
*
* @param packageId ID of the package type to update [1-25] characters `^se(-[a-z0-9]+)+$`
* @param data Data for updating the package type
*
* @returns The updated package type
*/
async update(packageId, data) {
return this.shipstation.request({
url: `${this.baseUrl}/${packageId}`,
method: 'PUT',
data
});
}
/**
* [Official Documentation](https://docs.shipstation.com/openapi/package_types/delete_package_typ)
*
* Delete a custom package using the ID
*
* @param packageId ID of the package type to delete [1-25] characters `^se(-[a-z0-9]+)+$`
*/
async delete(packageId) {
await this.shipstation.request({
url: `${this.baseUrl}/${packageId}`,
method: 'DELETE'
});
}
}
exports.PackageTypes = PackageTypes;