export type StravaWebhookUpdatesDto = {title?: string | undefined, type?: ('AlpineSki' | 'BackcountrySki' | 'Canoeing' | 'Crossfit' | 'EBikeRide' | 'Elliptical' | 'Golf' | 'Handcycle' | 'Hike' | 'IceSkate' | 'InlineSkate' | 'Kayaking' | 'Kitesurf' | 'NordicSki' | 'Ride' | 'RockClimbing' | 'RollerSki' | 'Rowing' | 'Run' | 'Sail' | 'Skateboard' | 'Snowboard' | 'Snowshoe' | 'Soccer' | 'StairStepper' | 'StandUpPaddling' | 'Surfing' | 'Swim' | 'Velomobile' | 'VirtualRide' | 'VirtualRun' | 'Walk' | 'WeightTraining' | 'Wheelchair' | 'Windsurf' | 'Workout' | 'Yoga') | undefined, private?: boolean | undefined, authorized?: boolean | undefined}; export type StravaWebhookBodyDto = {objectType: 'activity' | 'athlete', objectId: string, aspectType: string, updates: StravaWebhookUpdatesDto, ownerId: string, subscriptionId: number, eventTime: string}; export type CreateApiV1DataSourcesStravaWebhookArgs = {body: StravaWebhookBodyDto}; export type CreateApiV1DataSourcesStravaWebhookOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /v1/data-sources/strava/webhook */ export const createApiV1DataSourcesStravaWebhook = async (args: CreateApiV1DataSourcesStravaWebhookArgs, options: CreateApiV1DataSourcesStravaWebhookOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/data-sources/strava/webhook${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 };