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

1.8 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, processPathParameters } from '../../../common/utils';
import { PaymentMethodReadResponse } from '../../../models/responses';

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

// Endpoint: GET /public-api/resources/users/v1.0/{user}/payment-methods/{paymentMethodId}

export const paymentMethodReadAction = createAction({
  auth: ampecoAuth,
  name: 'paymentMethodRead',
  displayName: 'Resources - Users - Payment Method Read',
  description: 'Get information for a payment method by ID.',
  audience: 'both',
  aiMetadata: { description: 'Fetch a single payment method for an AMPECO user, identified by user id and payment method id. Read-only and idempotent. Use Payment Methods Listing to discover the ids first.', idempotent: true },
  props: {
        
  user: Property.Number({
    displayName: 'User',
    description: '',
    required: true,
  }),

  paymentMethodId: Property.ShortText({
    displayName: 'Payment Method Id',
    description: '',
    required: true,
  }),
  },
  async run(context): Promise<PaymentMethodReadResponse> {
    try {
      const url = processPathParameters('/public-api/resources/users/v1.0/{user}/payment-methods/{paymentMethodId}', context.propsValue);
      
      const queryParams = prepareQueryParams(context.propsValue, []);
      
      const body = undefined;

      
      return await makeAmpecoApiCall(
        context.auth,
        url,
        HttpMethod.GET,
        body,
        queryParams
      ) as PaymentMethodReadResponse;

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