export type JTLDataContractsKeysKundeKey = string; export type JTLDataContractsKeysFirmaKey = string; export type JTLDataContractsKeysKundenGruppeKey = string; export type JTLDataContractsKeysKundenKategorieKey = string; export type JTLDataContractsKeysZahlungsartKey = string; export type JTLDataContractsKeysAdresseKey = string; export type JTLWawiCustomersPublicApiDataTransferObjectsV2CustomerDomainCustomerAddressType = 0 | 1 | 2; export type JTLWawiCustomersPublicApiDataTransferObjectsV2CustomerDomainUpdateUpdateCustomerAddress = {customerAddressId?: JTLDataContractsKeysAdresseKey | undefined, addressType?: JTLWawiCustomersPublicApiDataTransferObjectsV2CustomerDomainCustomerAddressType | undefined, street?: string | undefined, additionalAddressLine?: string | undefined, city?: string | undefined, postalCode?: string | undefined, state?: string | undefined, countryIso?: string | undefined, emailAddress?: string | undefined, phoneNumber?: string | undefined, mobilePhoneNumber?: string | undefined, faxNumber?: string | undefined, vatId?: string | undefined, salutation?: string | undefined, title?: string | undefined, firstName?: string | undefined, lastName?: string | undefined, companyName?: string | undefined, additionalCompanyLine?: string | undefined, isDefaultAddress?: boolean | undefined}; export type JTLWawiCustomersPublicApiDataTransferObjectsV2CustomerDomainUpdateUpdateCustomerPaymentSettings = {creditLimit?: number | undefined, paymentDueDateInDays?: number | undefined, discount?: number | undefined, isDunningBlocked?: boolean | undefined}; export type JTLWawiCustomersPublicApiDataTransferObjectsV2CustomerDomainUpdateCustomerCommandRequest = {customerId?: JTLDataContractsKeysKundeKey | undefined, companyId?: JTLDataContractsKeysFirmaKey | undefined, customerGroupId?: JTLDataContractsKeysKundenGruppeKey | undefined, customerCategoryId?: JTLDataContractsKeysKundenKategorieKey | undefined, paymentMethodId?: JTLDataContractsKeysZahlungsartKey | undefined, accountsReceivableNumber?: number | undefined, birthday?: string | undefined, commercialRegisterNumber?: string | undefined, customerNumber?: string | undefined, ebayName?: string | undefined, homepage?: string | undefined, initialContact?: string | undefined, isCashRegisterBased?: boolean | undefined, isLocked?: boolean | undefined, languageIso?: string | undefined, taxIdentificationNumber?: string | undefined, addresses?: Array | undefined, paymentSettings?: JTLWawiCustomersPublicApiDataTransferObjectsV2CustomerDomainUpdateUpdateCustomerPaymentSettings | undefined, createdDate?: string | undefined}; export type PatchApiV2CustomerUpdateArgs = {'x-tenant-id': string, 'x-runas'?: string | undefined, 'x-companyid'?: string | undefined, body: JTLWawiCustomersPublicApiDataTransferObjectsV2CustomerDomainUpdateCustomerCommandRequest}; export type PatchApiV2CustomerUpdateOptions = {baseUrl?: string | undefined, oauth2AuthorizationCode?: string | undefined, fetch?: typeof fetch | undefined}; /** * Updates a customer * * PATCH /v2/customer/update * * Also accepts auth: oauth2-client-credentials */ export const patchApiV2CustomerUpdate = async (args: PatchApiV2CustomerUpdateArgs, options?: PatchApiV2CustomerUpdateOptions) => { const {baseUrl = "https://scx-sbx.api.jtl-software.com", fetch: fetchFn = fetch, oauth2AuthorizationCode} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['x-tenant-id'] != null) headers.set("x-tenant-id", String(args['x-tenant-id'])) 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/customer/update${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 (await res.json()) as unknown };