snake_cased noNotification and other minor changes

This commit is contained in:
--list
2021-07-05 09:49:58 +02:00
parent 243fbe7e79
commit fa3cde07ac
22 changed files with 100 additions and 93 deletions
@@ -155,7 +155,7 @@ export default async (req, res) => {
draftOrder = await draftOrderService.retrieve(draftOrder.id, {
relations: defaultRelations,
select: defaultFields,
}) //
})
res.status(200).json({ draft_order: draftOrder })
} catch (err) {
@@ -92,7 +92,12 @@ export default async (req, res) => {
)
}
await draftOrderService.update(draftOrder.id, value)
if ("no_notification_order" in value) {
await draftOrderService.update(draftOrder.id, {
no_notification_order: value.no_notification_order,
})
delete value.no_notification_order
}
await cartService.update(draftOrder.cart_id, value)
@@ -65,7 +65,7 @@ export default (app, container, config) => {
returnRoutes(route)
variantRoutes(route)
draftOrderRoutes(route)
collectionRoutes(route)
collectionRoutes(route)
notificationRoutes(route)
returnReasonRoutes(route)
@@ -43,7 +43,7 @@ describe("POST /admin/orders/:id/fulfillment", () => {
quantity: 1,
},
],
{"metadata": undefined, "noNotification": undefined}
{ metadata: undefined, no_notification: undefined }
)
})
@@ -52,6 +52,5 @@ describe("POST /admin/orders/:id/fulfillment", () => {
expect(subject.body.order.id).toEqual(IdMap.getId("test-order"))
expect(subject.body.order.fulfillment_status).toEqual("fulfilled")
})
})
})
@@ -110,8 +110,7 @@ import { defaultRelations, defaultFields } from "./"
* $ref: "#/components/schemas/order"
*/
export default async (req, res) => {
const { id } = req.params
const { id } = req.params
const schema = Validator.object().keys({
type: Validator.string()
.valid("replace", "refund")
@@ -165,8 +164,7 @@ export default async (req, res) => {
const { value, error } = schema.validate(req.body)
if (error) {
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
}
}
const idempotencyKeyService = req.scope.resolve("idempotencyKeyService")
const headerKey = req.get("Idempotency-Key") || ""
@@ -65,8 +65,8 @@ export default async (req, res) => {
const orderService = req.scope.resolve("orderService")
await orderService.createFulfillment(id, value.items, {
metadata: value.metadata,
noNotification: value.no_notification
metadata: value.metadata,
no_notification: value.no_notification,
})
const order = await orderService.retrieve(id, {
@@ -59,7 +59,7 @@ export default async (req, res) => {
id,
value.fulfillment_id,
value.tracking_numbers.map(n => ({ tracking_number: n })),
{ noNotification: value.no_notification }
{ no_notification: value.no_notification }
)
const order = await orderService.retrieve(id, {
@@ -61,7 +61,7 @@ export default async (req, res) => {
swap_id,
value.fulfillment_id,
value.tracking_numbers.map(n => ({ tracking_number: n })),
{noNotification: value.no_notification},
{ no_notification: value.no_notification }
)
const order = await orderService.retrieve(id, {
@@ -68,7 +68,7 @@ export default async (req, res) => {
.items({
item_id: Validator.string().required(),
quantity: Validator.number().required(),
})
})
.required(),
return_shipping: Validator.object()
.keys({
@@ -82,7 +82,7 @@ export default async (req, res) => {
variant_id: Validator.string().required(),
quantity: Validator.number().required(),
}),
no_notification: Validator.boolean().optional()
no_notification: Validator.boolean().optional(),
})
const { value, error } = schema.validate(req.body)
@@ -138,7 +138,10 @@ export default async (req, res) => {
value.return_items,
value.additional_items,
value.return_shipping,
{ idempotency_key: idempotencyKey.idempotency_key, noNotification: value.no_notification }
{
idempotency_key: idempotencyKey.idempotency_key,
no_notification: value.no_notification,
}
)
await swapService.withTransaction(manager).createCart(swap.id)
@@ -51,12 +51,10 @@ export default async (req, res) => {
const entityManager = req.scope.resolve("manager")
await entityManager.transaction(async manager => {
await claimService
.withTransaction(manager)
.createFulfillment(claim_id, {
metadata: value.metadata,
noNotification: value.no_notification,
})
await claimService.withTransaction(manager).createFulfillment(claim_id, {
metadata: value.metadata,
no_notification: value.no_notification,
})
})
const order = await orderService.retrieve(id, {
@@ -51,12 +51,10 @@ export default async (req, res) => {
const entityManager = req.scope.resolve("manager")
await entityManager.transaction(async manager => {
await swapService
.withTransaction(manager)
.createFulfillment(swap_id, {
metadata: value.metadata,
noNotification: value.no_notification,
})
await swapService.withTransaction(manager).createFulfillment(swap_id, {
metadata: value.metadata,
no_notification: value.no_notification,
})
const order = await orderService.withTransaction(manager).retrieve(id, {
select: defaultFields,
@@ -67,7 +67,7 @@ export default async (req, res) => {
value.amount,
value.reason,
value.note,
{ noNotification: value.no_notification }
{ no_notification: value.no_notification }
)
const order = await orderService.retrieve(id, {
@@ -31,7 +31,6 @@ import { MedusaError, Validator } from "medusa-core-utils"
* option_id:
* type: string
* description: The id of the Shipping Option to create the Shipping Method from.
*
* tags:
* - Return
* responses:
@@ -59,7 +58,7 @@ export default async (req, res) => {
.keys({
option_id: Validator.string().optional(),
})
.optional()
.optional(),
})
const { value, error } = schema.validate(req.body)
@@ -132,7 +131,7 @@ export default async (req, res) => {
.withTransaction(manager)
.emit("order.return_requested", {
id: value.order_id,
return_id: createdReturn.id
return_id: createdReturn.id,
})
return {