export type CreateApiApiCatalogPvtStockkeepingunitSkuIdEanEanArgs = {'Content-Type': string, Accept: string, skuId: number, ean: string}; export type CreateApiApiCatalogPvtStockkeepingunitSkuIdEanEanOptions = {baseUrl?: string | undefined, appKey?: string | undefined, appToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create SKU EAN * * POST /api/catalog/pvt/stockkeepingunit/{skuId}/ean/{ean} * * Also accepts auth: VtexIdclientAutCookie */ export const createApiApiCatalogPvtStockkeepingunitSkuIdEanEan = async (args: CreateApiApiCatalogPvtStockkeepingunitSkuIdEanEanArgs, options?: CreateApiApiCatalogPvtStockkeepingunitSkuIdEanEanOptions) => { const {baseUrl = "https://apiexamples.vtexcommercestable.com.br", fetch: fetchFn = fetch, appKey, appToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (args.Accept != null) headers.set("Accept", String(args.Accept)) if (appKey !== undefined) headers.set("X-VTEX-API-AppKey", appKey) if (appToken !== undefined) headers.set("X-VTEX-API-AppToken", appToken) const url = `${baseUrl.replace(/\/+$/, '')}/api/catalog/pvt/stockkeepingunit/${encodeURIComponent(String(args.skuId))}/ean/${encodeURIComponent(String(args.ean))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };