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.2 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { assembledCommon } from '../common';
import { HttpMethod } from '@activepieces/pieces-common';
import { assembledAuth } from '../common/auth';

export const getUserSchedule = createAction({
  auth: assembledAuth,
  name: 'get_user_schedule',
  classification: 'READ',
  displayName: 'Get User Schedule',
  description: 'Retrieves user\'s schedule for specified period.',
  props: {
    user_id: Property.ShortText({
      displayName: 'User ID',
      required: true,
    }),
    start_date: Property.DateTime({
      displayName: 'Start Date',
      required: true,
    }),
    end_date: Property.DateTime({
      displayName: 'End Date',
      required: true,
    }),
  },
  async run(context) {
    const { user_id, start_date, end_date } = context.propsValue;
    
    const params = new URLSearchParams({
      start_date: assembledCommon.formatDate(start_date),
      end_date: assembledCommon.formatDate(end_date),
    });

    const response = await assembledCommon.makeRequest(
      context.auth.secret_text,
      HttpMethod.GET,
      `/users/${user_id}/schedule?${params.toString()}`
    );

    return response.body;
  },
});