feat: Add support for product imports (#8298)
* feat: Add support for product imports * fix: Add product import template to import UI
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
AdminBatchProductVariantInventoryItemRequest,
|
||||
AdminBatchProductVariantInventoryItemResponse,
|
||||
HttpTypes,
|
||||
SelectParams,
|
||||
} from "@medusajs/types"
|
||||
import { HttpTypes, SelectParams } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
@@ -13,6 +8,45 @@ export class Product {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async import(
|
||||
body: HttpTypes.AdminImportProductRequest,
|
||||
query?: {},
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
const form = new FormData()
|
||||
form.append("file", body.file)
|
||||
|
||||
return await this.client.fetch<HttpTypes.AdminImportProductResponse>(
|
||||
`/admin/products/import`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
...headers,
|
||||
// Let the browser determine the content type.
|
||||
"content-type": null,
|
||||
},
|
||||
body: form,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async confirmImport(
|
||||
transactionId: string,
|
||||
query?: {},
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<{}>(
|
||||
`/admin/products/import/${transactionId}/confirm`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: {},
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async export(
|
||||
body: HttpTypes.AdminExportProductRequest,
|
||||
query?: HttpTypes.AdminProductListParams,
|
||||
|
||||
Reference in New Issue
Block a user