feat(medusa, medusa-js, medusa-react): Add endpoint to retrieve product tags from the storefront (#3051)

This commit is contained in:
Kasper Fabricius Kristensen
2023-01-18 10:47:15 +01:00
committed by GitHub
parent ab580066ae
commit 150696de99
15 changed files with 491 additions and 21 deletions
+3
View File
@@ -11,6 +11,7 @@ import OrderEditsResource from "./resources/order-edits"
import OrdersResource from "./resources/orders"
import PaymentCollectionsResource from "./resources/payment-collections"
import PaymentMethodsResource from "./resources/payment-methods"
import ProductTagsResource from "./resources/product-tags"
import ProductTypesResource from "./resources/product-types"
import ProductsResource from "./resources/products"
import RegionsResource from "./resources/regions"
@@ -40,6 +41,7 @@ class Medusa {
public giftCards: GiftCardsResource
public paymentMethods: PaymentMethodsResource
public paymentCollections: PaymentCollectionsResource
public productTags: ProductTagsResource
constructor(config: Config) {
this.client = new Client(config)
@@ -63,6 +65,7 @@ class Medusa {
this.giftCards = new GiftCardsResource(this.client)
this.paymentMethods = new PaymentMethodsResource(this.client)
this.paymentCollections = new PaymentCollectionsResource(this.client)
this.productTags = new ProductTagsResource(this.client)
}
/**
@@ -0,0 +1,31 @@
import {
StoreGetProductTagsParams,
StoreProductTagsListRes,
} from "@medusajs/medusa"
import qs from "qs"
import { ResponsePromise } from "../typings"
import BaseResource from "./base"
class ProductTagsResource extends BaseResource {
/**
* @description Retrieves a list of product tags
* @param {StoreGetProductTagsParams} query is optional. Can contain a limit and offset for the returned list
* @param customHeaders
* @return {ResponsePromise<StoreProductTagsListRes>}
*/
list(
query?: StoreGetProductTagsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<StoreProductTagsListRes> {
let path = `/store/product-tags`
if (query) {
const queryString = qs.stringify(query)
path += `?${queryString}`
}
return this.client.request("GET", path, undefined, {}, customHeaders)
}
}
export default ProductTagsResource