Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.0 KB
Raw Blame
import { HttpMethod } from '@activepieces/pieces-common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { ticktickAuth } from '../../auth';
import { tickTickApiCall } from '../../common/client';
import { ticktickCreateHabitOutputSchema } from '../../output-schemas';

export const getHabitAction = createAction({
	auth: ticktickAuth,
	name: 'ticktick_get_habit',
	outputSchema: ticktickCreateHabitOutputSchema,
	displayName: 'Get Habit',
	description: 'Retrieves a habit by its ID.',
	audience: 'ai',
	classification: 'READ',
	aiMetadata: {
		description: 'Fetches one habit in full by habitId from ticktick_list_habits. Read-only.',
		idempotent: true,
	},
	props: {
		habitId: Property.ShortText({
			displayName: 'Habit ID',
			description: 'The habit ID, from the List Habits action.',
			required: true,
		}),
	},
	async run(context) {
		return await tickTickApiCall({
			accessToken: context.auth.access_token,
			method: HttpMethod.GET,
			resourceUri: `/habit/${context.propsValue.habitId}`,
		});
	},
});