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

3.5 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 { UpdatePcIdResponse } from '../../../models/responses';

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

// Endpoint: PATCH /public-api/resources/provisioning-certificates/v2.0/{provisioningCertificate}

export const updatePcIdAction = createAction({
  auth: ampecoAuth,
  name: 'updatePcId',
  displayName: 'Resources - Provisioning Certificates - Update Pc Id',
  description: 'Update a Provisioning Certificate.',
  audience: 'both',
  aiMetadata: { description: 'Update an existing AMPECO provisioning certificate identified by its numeric ID, changing fields such as PC ID, name, vehicle type, user, or ID tags. A partial PATCH that applies only the fields you supply. Use create pc id to register a new certificate instead.', idempotent: false },
  props: {
        
  provisioningCertificate: Property.Number({
    displayName: 'Provisioning Certificate',
    description: '',
    required: true,
  }),

  pcId: Property.ShortText({
    displayName: 'Pc Id',
    description: '',
    required: false,
  }),

  name: Property.ShortText({
    displayName: 'Name',
    description: '',
    required: false,
  }),

  vehicleType: Property.StaticDropdown({
    displayName: 'Vehicle Type',
    description: '',
    required: false,
    options: {
      options: [
      { label: 'company', value: 'company' },
      { label: 'private', value: 'private' }
      ],
    },
  }),

  userId: Property.Number({
    displayName: 'User Id',
    description: '',
    required: false,
  }),

  idTags: Property.Array({
    displayName: 'Id Tags',
    description: '',
    required: false,
    properties: { 
         
  id: Property.Number({
    displayName: 'Id',
    description: '',
    required: false,
  }),

  type: Property.StaticDropdown({
    displayName: 'Type',
    description: '',
    required: false,
    options: {
      options: [
      { label: 'rfid', value: 'rfid' },
      { label: 'mac_address', value: 'mac_address' },
      { label: 'emaid', value: 'emaid' }
      ],
    },
  }),

  name: Property.ShortText({
    displayName: 'Name',
    description: '',
    required: false,
  }),

  paymentMethod: Property.ShortText({
    displayName: 'Payment Method',
    description: '',
    required: false,
  }),

  status: Property.StaticDropdown({
    displayName: 'Status',
    description: '',
    required: false,
    options: {
      options: [
      { label: 'active', value: 'active' },
      { label: 'disabled', value: 'disabled' },
      { label: 'suspended', value: 'suspended' }
      ],
    },
  }),

  expireAt: Property.DateTime({
    displayName: 'Expire At',
    description: '',
    required: false,
  }), 
    },
  }),
  },
  async run(context): Promise<UpdatePcIdResponse> {
    try {
      const url = processPathParameters('/public-api/resources/provisioning-certificates/v2.0/{provisioningCertificate}', context.propsValue);
      
      const queryParams = prepareQueryParams(context.propsValue, []);
      
      const body = prepareRequestBody(context.propsValue,
        ['pcId', 'name', 'vehicleType', 'userId', 'idTags']
      );

      
      return await makeAmpecoApiCall(
        context.auth,
        url,
        HttpMethod.PATCH,
        body,
        queryParams
      ) as UpdatePcIdResponse;

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