export type JTLDataContractsKeysArtikelKey = string; export type JTLDataContractsKeysKundeKey = string; export type GetApiV2SalesorderItempricedetailsArgs = {'x-tenant-id': string, itemIds?: Array | undefined, customerId?: JTLDataContractsKeysKundeKey | undefined, IsExisting?: boolean | undefined, currencyFactor?: number | undefined, 'x-runas'?: string | undefined, 'x-companyid'?: string | undefined}; export type GetApiV2SalesorderItempricedetailsOptions = {baseUrl?: string | undefined, oauth2AuthorizationCode?: string | undefined, fetch?: typeof fetch | undefined}; /** * Returns a list of price details for the requested items. * * GET /v2/salesorder/itempricedetails * * Also accepts auth: oauth2-client-credentials */ export const getApiV2SalesorderItempricedetails = async (args: GetApiV2SalesorderItempricedetailsArgs, options?: GetApiV2SalesorderItempricedetailsOptions) => { const {baseUrl = "https://scx-sbx.api.jtl-software.com", fetch: fetchFn = fetch, oauth2AuthorizationCode} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['x-tenant-id'] != null) headers.set("x-tenant-id", String(args['x-tenant-id'])) for (const item of args.itemIds ?? []) query.append("itemIds", String(item)) if (args.customerId != null) query.append("customerId", String(args.customerId)) if (args.IsExisting != null) query.append("IsExisting", String(args.IsExisting)) if (args.currencyFactor != null) query.append("currencyFactor", String(args.currencyFactor)) if (args['x-runas'] != null) headers.set("x-runas", String(args['x-runas'])) if (args['x-companyid'] != null) headers.set("x-companyid", String(args['x-companyid'])) if (oauth2AuthorizationCode !== undefined) headers.set('authorization', `Bearer ${oauth2AuthorizationCode}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/salesorder/itempricedetails${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };