export type JTLDataContractsKeysFirmaKey = string; export type JTLWawiTaxesPublicApiDataTransferObjectsV2TaxDomainTaxDomainTaxReference = 0 | 1; export type JTLWawiTaxesPublicApiDataTransferObjectsV2TaxDomainTaxDomainSpecialTaxTreatment = 0 | 1 | 2 | 3; export type JTLDataContractsKeysSteuerklasseKey = string; export type GetApiV2TaxclassesTaxclasseswithtaxratesArgs = {'x-tenant-id': string, companyId?: JTLDataContractsKeysFirmaKey | undefined, departureCountryIso?: string | undefined, taxReference?: JTLWawiTaxesPublicApiDataTransferObjectsV2TaxDomainTaxDomainTaxReference | undefined, shipmentAddressVatId?: string | undefined, shipmentAddressCountryIso?: string | undefined, shipmentAddressState?: string | undefined, billingAddressVatId?: string | undefined, billingAddressCountryIso?: string | undefined, billingAddressState?: string | undefined, specialTaxTreatment?: JTLWawiTaxesPublicApiDataTransferObjectsV2TaxDomainTaxDomainSpecialTaxTreatment | undefined, taxClasses?: Array | undefined, 'x-runas'?: string | undefined, 'x-companyid'?: string | undefined}; export type GetApiV2TaxclassesTaxclasseswithtaxratesOptions = {baseUrl?: string | undefined, oauth2AuthorizationCode?: string | undefined, fetch?: typeof fetch | undefined}; /** * Returns a list of all tax classes and their calculated tax rates for the given parameters. * * GET /v2/taxclasses/taxclasseswithtaxrates * * Also accepts auth: oauth2-client-credentials */ export const getApiV2TaxclassesTaxclasseswithtaxrates = async (args: GetApiV2TaxclassesTaxclasseswithtaxratesArgs, options?: GetApiV2TaxclassesTaxclasseswithtaxratesOptions) => { 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'])) if (args.companyId != null) query.append("companyId", String(args.companyId)) if (args.departureCountryIso != null) query.append("departureCountryIso", String(args.departureCountryIso)) if (args.taxReference != null) query.append("taxReference", String(args.taxReference)) if (args.shipmentAddressVatId != null) query.append("shipmentAddressVatId", String(args.shipmentAddressVatId)) if (args.shipmentAddressCountryIso != null) query.append("shipmentAddressCountryIso", String(args.shipmentAddressCountryIso)) if (args.shipmentAddressState != null) query.append("shipmentAddressState", String(args.shipmentAddressState)) if (args.billingAddressVatId != null) query.append("billingAddressVatId", String(args.billingAddressVatId)) if (args.billingAddressCountryIso != null) query.append("billingAddressCountryIso", String(args.billingAddressCountryIso)) if (args.billingAddressState != null) query.append("billingAddressState", String(args.billingAddressState)) if (args.specialTaxTreatment != null) query.append("specialTaxTreatment", String(args.specialTaxTreatment)) for (const item of args.taxClasses ?? []) query.append("taxClasses", String(item)) 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/taxclasses/taxclasseswithtaxrates${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 };