import { HttpMethod } from '@activepieces/pieces-common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { ampecoAuth } from '../../../common/auth';
import { handleApiError, makeAmpecoApiCall, prepareQueryParams, processPathParameters } from '../../../common/utils';

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

// Endpoint: DELETE /public-api/resources/electricity-meters/v1.0/{electricityMeter}

export const electricityMeterDeleteAction = createAction({
  auth: ampecoAuth,
  name: 'electricityMeterDelete',
  displayName: 'Resources - Electricity Meters - Delete',
  description: 'Delete an electricity meter.',
  audience: 'both',
  aiMetadata: { description: 'Permanently delete an AMPECO electricity meter by its numeric ID. Destructive; deleting an already-removed meter returns an error rather than succeeding silently. Confirm the meter ID via the listing action first.', idempotent: false },
  props: {
        
  electricityMeter: Property.Number({
    displayName: 'Electricity Meter',
    required: true,
  }),
  },
  async run(context): Promise<unknown> {
    try {
      const url = processPathParameters('/public-api/resources/electricity-meters/v1.0/{electricityMeter}', context.propsValue);
      
      const queryParams = prepareQueryParams(context.propsValue, []);
      
      const body = undefined;

      
      return await makeAmpecoApiCall(
        context.auth,
        url,
        HttpMethod.DELETE,
        body,
        queryParams
      ) as unknown;

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