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-rates/v2.0/{electricityRate}

export const electricityRateDeleteAction = createAction({
  auth: ampecoAuth,
  name: 'electricityRateDelete',
  displayName: 'Resources - Electricity Rates - Delete',
  description: 'Delete a Electricity rate.',
  audience: 'both',
  aiMetadata: { description: 'Permanently delete an electricity rate from AMPECO by its numeric id. Destructive and cannot be undone; repeating after success fails because the rate no longer exists. Confirm the correct id before calling.', idempotent: false },
  props: {
        
  electricityRate: Property.Number({
    displayName: 'Electricity Rate',
    description: '',
    required: true,
  }),
  },
  async run(context): Promise<unknown> {
    try {
      const url = processPathParameters('/public-api/resources/electricity-rates/v2.0/{electricityRate}', 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);
    }
  },
});
