export type EquipmentIdentifier = {type?: ('CONTAINER_ID' | 'RAIL_CAR_ID' | 'TRAILER_ID') | undefined, value?: string | undefined}; export type AssetTrackingSubscription = {equipmentIdentifier?: EquipmentIdentifier | undefined, expirationDateTime?: string | undefined, id?: string | undefined, webhookName?: string | undefined}; export type CreateApiApiV4AssetsTrackingArgs = {body: AssetTrackingSubscription}; export type CreateApiApiV4AssetsTrackingOptions = {baseUrl?: string | undefined, oAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Enroll an asset for tracking. * * POST /api/v4/assets/tracking */ export const createApiApiV4AssetsTracking = async (args: CreateApiApiV4AssetsTrackingArgs, options?: CreateApiApiV4AssetsTrackingOptions) => { const {baseUrl = "https://na12.api.project44.com", fetch: fetchFn = fetch, oAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (oAuth2 !== undefined) headers.set('authorization', `Bearer ${oAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v4/assets/tracking${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 };