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/taxes/v2.0/{tax}

export const taxDeleteAction = createAction({
  auth: ampecoAuth,
  name: 'taxDelete',
  displayName: 'Resources - Taxes - Delete',
  description: 'Delete a Tax.',
  audience: 'both',
  aiMetadata: { description: 'Permanently delete a tax rate by its numeric ID. Destructive and irreversible; effectively idempotent since deleting an already-removed tax has no further effect, though it may return a not-found error. Confirm the ID before calling.', idempotent: true },
  props: {
        
  tax: Property.Number({
    displayName: 'Tax',
    description: '',
    required: true,
  }),
  },
  async run(context): Promise<unknown> {
    try {
      const url = processPathParameters('/public-api/resources/taxes/v2.0/{tax}', 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);
    }
  },
});
