feat(medusa-js): Add Collection batch (remove, add) endpoints (#1958)
This commit is contained in:
1 parent
11fab121f4
commit
a88bf3c76e
2 files changed
+37
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa-js": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add batch endpoints (remove, add) for Collections to medusa-js
|
||||||
@@ -5,6 +5,8 @@ import {
|
|||||||
AdminCollectionsDeleteRes,
|
AdminCollectionsDeleteRes,
|
||||||
AdminCollectionsListRes,
|
AdminCollectionsListRes,
|
||||||
AdminGetCollectionsParams,
|
AdminGetCollectionsParams,
|
||||||
|
AdminPostProductsToCollectionReq,
|
||||||
|
AdminDeleteProductsFromCollectionReq,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import qs from "qs"
|
import qs from "qs"
|
||||||
import { ResponsePromise } from "../../typings"
|
import { ResponsePromise } from "../../typings"
|
||||||
@@ -88,6 +90,36 @@ class AdminCollectionsResource extends BaseResource {
|
|||||||
|
|
||||||
return this.client.request("GET", path, undefined, {}, customHeaders)
|
return this.client.request("GET", path, undefined, {}, customHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Updates products associated with a Product Collection
|
||||||
|
* @param id the id of the Collection
|
||||||
|
* @param payload - an object which contains an array of Product IDs to add to the Product Collection
|
||||||
|
* @param customHeaders
|
||||||
|
*/
|
||||||
|
addProducts(
|
||||||
|
id: string,
|
||||||
|
payload: AdminPostProductsToCollectionReq,
|
||||||
|
customHeaders: Record<string, any> = {}
|
||||||
|
): ResponsePromise<AdminCollectionsRes> {
|
||||||
|
const path = `/admin/collections/${id}/products/batch`
|
||||||
|
return this.client.request("POST", path, payload, {}, customHeaders)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Removes products associated with a Product Collection
|
||||||
|
* @param id - the id of the Collection
|
||||||
|
* @param payload - an object which contains an array of Product IDs to add to the Product Collection
|
||||||
|
* @param customHeaders
|
||||||
|
*/
|
||||||
|
removeProducts(
|
||||||
|
id: string,
|
||||||
|
payload: AdminDeleteProductsFromCollectionReq,
|
||||||
|
customHeaders: Record<string, any> = {}
|
||||||
|
): ResponsePromise<AdminCollectionsDeleteRes> {
|
||||||
|
const path = `/admin/collections/${id}/products/batch`
|
||||||
|
return this.client.request("DELETE", path, payload, {}, customHeaders)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AdminCollectionsResource
|
export default AdminCollectionsResource
|
||||||
Reference in new issue
Block a user