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.8 KB
Raw Blame
import { HttpMethod } from '@activepieces/pieces-common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { ampecoAuth } from '../../../common/auth';
import { handleApiError, makeAmpecoApiCall, prepareQueryParams, prepareRequestBody, processPathParameters } from '../../../common/utils';
import { ChargePointShareCreateResponse } from '../../../models/responses';

/**
 * Generated from API version: 3.96.4
 */

//Endpoint: POST /public-api/resources/charge-points/v2.0/{chargePoint}/shares

export const chargePointShareCreateAction = createAction({
  auth: ampecoAuth,
  name: 'chargePointShareCreate',
  displayName: 'Resources - Charge Points - Charge Point Share Create',
  description: 'Create new Share within the Charge Point.',
  audience: 'both',
  aiMetadata: { description: 'Grant a user access to a charge point by creating a new share, given the charge point ID and the user ID. This is a mutating create that adds a new share each call, so it is not idempotent.', idempotent: false },
  props: {
        
  chargePoint: Property.Number({
    displayName: 'Charge Point',
    required: true,
  }),

  userId: Property.Number({
    displayName: 'User Id',
    required: true,
  }),
  },
  async run(context): Promise<ChargePointShareCreateResponse> {
    try {
      const url = processPathParameters('/public-api/resources/charge-points/v2.0/{chargePoint}/shares', context.propsValue);
      
      const queryParams = prepareQueryParams(context.propsValue, []);
      
      const body = prepareRequestBody(context.propsValue,
        ['userId']
      );

      
      return await makeAmpecoApiCall(
        context.auth,
        url,
        HttpMethod.POST,
        body,
        queryParams
      ) as ChargePointShareCreateResponse;

    } catch (error) {
      handleApiError(error);
    }
  },
});