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.4 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 { FaqUpdateResponse } from '../../../models/responses';

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

//  Endpoint: PATCH /public-api/resources/faqs/v2.0/{faq}

export const faqUpdateAction = createAction({
  auth: ampecoAuth,
  name: 'faqUpdate',
  displayName: 'Resources - Faqs - Update',
  description: 'Update FAQs.',
  audience: 'both',
  aiMetadata: { description: 'Update an existing FAQ entry identified by its numeric id, replacing its localized question and/or answer text. Targets one known entry (it does not create); idempotent when sending the same values. To add a new FAQ use Faq Create instead.', idempotent: true },
  props: {
        
  faq: Property.Number({
    displayName: 'Faq',
    description: '',
    required: true,
  }),

  question: Property.Array({
    displayName: 'Question',
    description: '',
    required: false,
    properties: { 
         
  locale: Property.ShortText({
    displayName: 'Locale',
    description: 'valid locale.',
    required: false,
  }),

  translation: Property.ShortText({
    displayName: 'Translation',
    description: '',
    required: false,
  }), 
    },
  }),

  answer: Property.Array({
    displayName: 'Answer',
    description: '',
    required: false,
    properties: { 
         
  locale: Property.ShortText({
    displayName: 'Locale',
    description: 'valid locale.',
    required: false,
  }),

  translation: Property.ShortText({
    displayName: 'Translation',
    description: '',
    required: false,
  }), 
    },
  }),
  },
  async run(context): Promise<FaqUpdateResponse> {
    try {
      const url = processPathParameters('/public-api/resources/faqs/v2.0/{faq}', context.propsValue);
      
      const queryParams = prepareQueryParams(context.propsValue, []);
      
      const body = prepareRequestBody(context.propsValue,
        ['question', 'answer']
      );

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

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