Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

2.2 KB
Raw Blame
import { HttpMethod } from '@activepieces/pieces-common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { ampecoAuth } from '../../../common/auth';
import { handleApiError, makeAmpecoApiCall, prepareQueryParams, prepareRequestBody, processPathParameters } from '../../../common/utils';
import { TopUpPackageUpdateResponse } from '../../../models/responses';

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

// Endpoint: PATCH /public-api/resources/top-up-packages/v2.0/{topUpPackage}

export const topUpPackageUpdateAction = createAction({
  auth: ampecoAuth,
  name: 'topUpPackageUpdate',
  displayName: 'Resources - Top Up Packages - Update',
  description: 'Top-Up Packages.',
  audience: 'both',
  aiMetadata: { description: 'Update an existing top-up package, identified by its numeric id, changing only the fields you supply (price, bonus, enabled flag). Not idempotent: each call mutates live state. Use Create to add a new package and Listing to find the package id.', idempotent: false },
  props: {
        
  topUpPackage: Property.Number({
    displayName: 'Top Up Package',
    description: '',
    required: true,
  }),

  price: Property.Number({
    displayName: 'Price',
    description: '',
    required: false,
  }),

  bonus: Property.Number({
    displayName: 'Bonus',
    description: '',
    required: false,
  }),

  enabled: Property.StaticDropdown({
    displayName: 'Enabled',
    description: '',
    required: false,
    options: {
      options: [
      { label: 'true', value: 'true' },
      { label: 'false', value: 'false' }
      ],
    },
  }),
  },
  async run(context): Promise<TopUpPackageUpdateResponse> {
    try {
      const url = processPathParameters('/public-api/resources/top-up-packages/v2.0/{topUpPackage}', context.propsValue);
      
      const queryParams = prepareQueryParams(context.propsValue, []);
      
      const body = prepareRequestBody(context.propsValue,
        ['price', 'bonus', 'enabled']
      );

      
      return await makeAmpecoApiCall(
        context.auth,
        url,
        HttpMethod.PATCH,
        body,
        queryParams
      ) as TopUpPackageUpdateResponse;

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