feat: Admin Shipping Profiles API (#7019)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
CreateShippingProfileDTO,
|
||||
IFulfillmentModuleService,
|
||||
} from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type StepInput = CreateShippingProfileDTO[]
|
||||
|
||||
export const createShippingProfilesStepId = "create-shipping-profiles"
|
||||
export const createShippingProfilesStep = createStep(
|
||||
createShippingProfilesStepId,
|
||||
async (input: StepInput, { container }) => {
|
||||
const service = container.resolve<IFulfillmentModuleService>(
|
||||
ModuleRegistrationName.FULFILLMENT
|
||||
)
|
||||
|
||||
const createdShippingProfiles = await service.createShippingProfiles(input)
|
||||
|
||||
return new StepResponse(
|
||||
createdShippingProfiles,
|
||||
createdShippingProfiles.map((created) => created.id)
|
||||
)
|
||||
},
|
||||
async (createdShippingProfiles, { container }) => {
|
||||
if (!createdShippingProfiles?.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const service = container.resolve<IFulfillmentModuleService>(
|
||||
ModuleRegistrationName.FULFILLMENT
|
||||
)
|
||||
|
||||
await service.deleteShippingProfiles(createdShippingProfiles)
|
||||
}
|
||||
)
|
||||
@@ -4,4 +4,5 @@ export * from "./create-fulfillment-set"
|
||||
export * from "./create-service-zones"
|
||||
export * from "./upsert-shipping-options"
|
||||
export * from "./delete-service-zones"
|
||||
export * from "./create-shipping-profiles"
|
||||
export * from "./remove-rules-from-fulfillment-shipping-option"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { FulfillmentWorkflow } from "@medusajs/types"
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { createShippingProfilesStep } from "../steps"
|
||||
|
||||
export const createShippingProfilesWorkflowId =
|
||||
"create-shipping-profiles-workflow"
|
||||
export const createShippingProfilesWorkflow = createWorkflow(
|
||||
createShippingProfilesWorkflowId,
|
||||
(
|
||||
input: WorkflowData<FulfillmentWorkflow.CreateShippingProfilesWorkflowInput>
|
||||
): WorkflowData => {
|
||||
const shippingProfiles = createShippingProfilesStep(input.data)
|
||||
|
||||
return shippingProfiles
|
||||
}
|
||||
)
|
||||
@@ -1,7 +1,8 @@
|
||||
export * from "./add-rules-to-fulfillment-shipping-option"
|
||||
export * from "./create-service-zones"
|
||||
export * from "./create-shipping-options"
|
||||
export * from "./update-shipping-options"
|
||||
export * from "./create-shipping-profiles"
|
||||
export * from "./delete-service-zones"
|
||||
export * from "./remove-rules-from-fulfillment-shipping-option"
|
||||
export * from "./update-service-zones"
|
||||
export * from "./update-shipping-options"
|
||||
|
||||
Reference in New Issue
Block a user