export type CreateApiV1ItemsSendToTenantArgs = {tenantId?: string | undefined, receiverAccountId?: number | undefined, accountId?: number | undefined, body: Array}; export type CreateApiV1ItemsSendToTenantOptions = {baseUrl: string, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send item(s) to another tenant * * POST /v1/Items/sendToTenant */ export const createApiV1ItemsSendToTenant = async (args: CreateApiV1ItemsSendToTenantArgs, options: CreateApiV1ItemsSendToTenantOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json-patch+json; x-api-version=1.0") if (args.tenantId != null) query.append("tenantId", String(args.tenantId)) if (args.receiverAccountId != null) query.append("receiverAccountId", String(args.receiverAccountId)) if (args.accountId != null) query.append("accountId", String(args.accountId)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/Items/sendToTenant${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 };