feat(medusa): Convert FulfillmentService to TypeScript (#1962)

This commit is contained in:
Philip Korsholm
2022-08-22 19:19:41 +02:00
committed by GitHub
parent 8cbebef403
commit c97ccd3fb5
7 changed files with 226 additions and 117 deletions
@@ -24,7 +24,9 @@ class BaseFulfillmentService extends BaseService {
* to create shipping options in Medusa that can be chosen between by the
* customer.
*/
getFulfillmentOptions() {}
getFulfillmentOptions() {
throw Error("getFulfillmentOptions must be overridden by the child class")
}
/**
* Called before a shipping method is set on a cart to ensure that the data
@@ -32,12 +34,13 @@ class BaseFulfillmentService extends BaseService {
* data about the shipment such as an id of a drop point. It is up to the
* fulfillment provider to enforce that the correct data is being sent
* through.
* @param {object} optionData - the data to validate
* @param {object} data - the data to validate
* @param {object} cart - the cart to which the shipping method will be applied
* @param {object | undefined} cart - the cart to which the shipping method will be applied
* @return {object} the data to populate `cart.shipping_methods.$.data` this
* is usually important for future actions like generating shipping labels
*/
validateFulfillmentData(data, cart) {
validateFulfillmentData(optionData, data, cart) {
throw Error("validateFulfillmentData must be overridden by the child class")
}
@@ -56,12 +59,16 @@ class BaseFulfillmentService extends BaseService {
/**
* Used to calculate a price for a given shipping option.
*/
calculatePrice(data, cart) {
calculatePrice(optionData, data, cart) {
throw Error("calculatePrice must be overridden by the child class")
}
createFulfillment() {
throw Error("createOrder must be overridden by the child class")
createFulfillment(data, items, order, fulfillment) {
throw Error("createFulfillment must be overridden by the child class")
}
cancelFulfillment(fulfillment) {
throw Error("cancelFulfillment must be overridden by the child class")
}
/**
@@ -94,6 +101,10 @@ class BaseFulfillmentService extends BaseService {
getShipmentDocuments(data) {
return []
}
retrieveDocuments(fulfillmentData, documentType) {
throw Error("retrieveDocuments must be overridden by the child class")
}
}
export default BaseFulfillmentService