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/charge-points/v2.0/{chargePoint}/shares/{share}
export const charegPointShareDeleteAction = createAction({
  auth: ampecoAuth,
  name: 'charegPointShareDelete',
  displayName: 'Resources - Charge Points - Chareg Point Share Delete',
  description: 'Delete an Share.',
  audience: 'both',
  aiMetadata: { description: 'Permanently remove a share from a charge point, identified by the charge point ID and the share ID, revoking that shared access. Destructive and irreversible; effectively idempotent since deleting an already-removed share has no further effect, though it may return a not-found error. Confirm both IDs before calling.', idempotent: true },
  props: {
        
  chargePoint: Property.Number({
    displayName: 'Charge Point',
    required: true,
  }),

  share: Property.Number({
    displayName: 'Share',
    required: true,
  }),
  },
  async run(context): Promise<unknown> {
    try {
      const url = processPathParameters('/public-api/resources/charge-points/v2.0/{chargePoint}/shares/{share}', 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);
    }
  },
});
