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.4 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { simplirouteAuth } from '../../auth';
import { API_BASE_URL, commonHeaders } from '../../common/constants';

export const get_plan_vehicles = createAction({
    name: 'get_plan_vehicles',
    auth: simplirouteAuth,
    displayName: 'Get vehicles with routes on date',
    description: 'Returns the vehicles that have planned routes on the indicated date.',
    audience: 'both',
    aiMetadata: { description: 'Look up which vehicles have planned routes on a specific date. Read-only and idempotent; use when you need the routed-vehicle subset for a day rather than the full plan or the entire vehicle fleet.', idempotent: true },
    props: {
        planned_date: Property.ShortText({ displayName: 'planned_date', description: 'Planned date (YYYY-MM-DD).', required: true }),
    },
    async run(context) {
        const url = `${API_BASE_URL}/v1/plans/${context.propsValue.planned_date}/vehicles/`;
        const response = await httpClient.sendRequest({
            method: HttpMethod.GET,
            url,
            headers: {
                ...commonHeaders,
                'Authorization': `Token ${context.auth.secret_text}`
            }
        });
        return {
            status: response.status,
            data: response.body
        };
    },
});