Adds dynamic coupon codes and segment plugin

This commit is contained in:
Sebastian Rindom
2020-07-17 14:06:55 +02:00
parent ec6a538877
commit 3710f7f80a
41 changed files with 11784 additions and 109 deletions
@@ -0,0 +1,21 @@
import { MedusaError, Validator } from "medusa-core-utils"
export default async (req, res) => {
const { discount_id, code } = req.params
const { value, error } = schema.validate(req.body)
if (error) {
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
}
try {
const discountService = req.scope.resolve("discountService")
await discountService.deleteDynamicCode(discount_id, code)
const data = await discountService.retrieve(dicsount_id)
res.status(200).json({ discount: data })
} catch (err) {
throw err
}
}