fix: complete cart return type (#902)
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
StoreCartsRes,
|
StoreCartsRes,
|
||||||
StoreOrdersRes,
|
StoreCompleteCartRes,
|
||||||
StorePostCartReq,
|
StorePostCartReq,
|
||||||
StorePostCartsCartPaymentSessionReq,
|
StorePostCartsCartPaymentSessionReq,
|
||||||
StorePostCartsCartPaymentSessionUpdateReq,
|
StorePostCartsCartPaymentSessionUpdateReq,
|
||||||
StorePostCartsCartReq,
|
StorePostCartsCartReq,
|
||||||
StorePostCartsCartShippingMethodReq,
|
StorePostCartsCartShippingMethodReq,
|
||||||
StoreSwapsRes,
|
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import { ResponsePromise } from "../typings"
|
import { ResponsePromise } from "../typings"
|
||||||
import BaseResource from "./base"
|
import BaseResource from "./base"
|
||||||
@@ -36,11 +35,9 @@ class CartsResource extends BaseResource {
|
|||||||
* The completion of a cart can be performed idempotently with a provided header Idempotency-Key.
|
* The completion of a cart can be performed idempotently with a provided header Idempotency-Key.
|
||||||
* If not provuided, we will generate one for the request.
|
* If not provuided, we will generate one for the request.
|
||||||
* @param {string} cart_id is required
|
* @param {string} cart_id is required
|
||||||
* @return {ResponsePromise<StoreCartsRes | StoreSwapsRes | StoreOrdersRes>}
|
* @return {ResponsePromise<StoreCompleteCartRes>}
|
||||||
*/
|
*/
|
||||||
complete(
|
complete(cart_id: string): ResponsePromise<StoreCompleteCartRes> {
|
||||||
cart_id: string
|
|
||||||
): ResponsePromise<StoreCartsRes | StoreSwapsRes | StoreOrdersRes> {
|
|
||||||
const path = `/store/carts/${cart_id}/complete`
|
const path = `/store/carts/${cart_id}/complete`
|
||||||
return this.client.request("POST", path)
|
return this.client.request("POST", path)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { Router } from "express"
|
import { Router } from "express"
|
||||||
import "reflect-metadata"
|
import "reflect-metadata"
|
||||||
import { Cart } from "../../../../models/cart"
|
import { Cart, Order, Swap } from "../../../../"
|
||||||
import { DeleteResponse } from "../../../../types/common"
|
import { DeleteResponse } from "../../../../types/common"
|
||||||
import middlewares from "../../../middlewares"
|
import middlewares from "../../../middlewares"
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
export default (app, container) => {
|
export default (app, container) => {
|
||||||
@@ -127,6 +126,17 @@ export type StoreCartsRes = {
|
|||||||
cart: Omit<Cart, "refundable_amount" | "refunded_total">
|
cart: Omit<Cart, "refundable_amount" | "refunded_total">
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type StoreCompleteCartRes = {
|
||||||
|
type: "cart"
|
||||||
|
data: Cart
|
||||||
|
} | {
|
||||||
|
type: "order"
|
||||||
|
data: Order
|
||||||
|
} | {
|
||||||
|
type: "swap"
|
||||||
|
data: Swap
|
||||||
|
}
|
||||||
|
|
||||||
export type StoreCartsDeleteRes = DeleteResponse
|
export type StoreCartsDeleteRes = DeleteResponse
|
||||||
|
|
||||||
export * from "./add-shipping-method"
|
export * from "./add-shipping-method"
|
||||||
|
|||||||
Reference in New Issue
Block a user