export type Channel = string; export type SellerId = string; export type OfferId = number; export type ParentOfferId = number | null; export type ChannelOfferId = string; export type QuantityPrice = {amount: string, currency: string, quantity?: (string | null) | undefined}; export type PriceContainer = {id: string, quantityPriceList: Array}; export type ChannelAttribute = {attributeId: string, value: string, group?: (string | null) | undefined}; export type SKU = string; export type Variation = {offerId: OfferId, sku: SKU, gtin?: string | undefined, variationDimensionList: Array, quantity: string, priceList: Array, taxPercent?: string | undefined, pictureList?: Array | undefined, title?: string | undefined, subTitle?: string | undefined, description?: string | undefined, channelAttributeList?: Array | undefined}; export type Price = {amount: string, currency: string}; export type ProductAttribute = {name: string, value: string}; export type Product = {sku: SKU, title?: string | undefined, subTitle?: string | undefined, description?: string | undefined, gtin?: string | undefined, mpn?: string | undefined, isbn?: string | undefined, brand?: string | undefined, srp?: Price | undefined, productAttributeList?: Array | undefined}; export type Offer = {salesChannelOfferList: Array<{channel: Channel, sellerId: SellerId, offerId: OfferId, parentOfferId?: ParentOfferId | undefined, channelOfferId?: ChannelOfferId | undefined, channelCategoryId?: string | undefined, quantity?: string | undefined, taxPercent?: string | undefined, priceList: Array, title?: string | undefined, subTitle?: string | undefined, description?: string | undefined, mainPicture?: string | undefined, pictureList?: Array | undefined, channelAttributeList?: Array | undefined, variationList?: Array | undefined}>, product: Product}; export type ProductOfferList = {offerList: Array}; export type CreateApiV1SellerOfferArgs = {body: ProductOfferList}; export type CreateApiV1SellerOfferOptions = {baseUrl?: string | undefined, SellerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Offer * * * POST /v1/seller/offer */ export const createApiV1SellerOffer = async (args: CreateApiV1SellerOfferArgs, options?: CreateApiV1SellerOfferOptions) => { const {baseUrl = "https://scx-sbx.api.jtl-software.com", fetch: fetchFn = fetch, SellerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (SellerAuth !== undefined) headers.set('authorization', `Bearer ${SellerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/seller/offer${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };