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/evse-downtime-periods/v1.0/{evseDowntimePeriod}

export const evseDowntimePeriodDeleteAction = createAction({
  auth: ampecoAuth,
  name: 'evseDowntimePeriodDelete',
  displayName: 'Resources - Evse Downtime Periods - Delete',
  description: 'Delete Manual Created EVSE Downtime Period.',
  audience: 'both',
  aiMetadata: { description: 'Permanently delete a manually created EVSE downtime period by its numeric ID. Destructive and irreversible; a repeat call fails once the period is gone. Only manually created periods can be removed.', idempotent: false },
  props: {
        
  evseDowntimePeriod: Property.Number({
    displayName: 'Evse Downtime Period',
    description: '',
    required: true,
  }),
  },
  async run(context): Promise<unknown> {
    try {
      const url = processPathParameters('/public-api/resources/evse-downtime-periods/v1.0/{evseDowntimePeriod}', 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);
    }
  },
});
