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.0 KB
Raw Blame
import { SeekPage } from '@activepieces/core-utils';
import {
  ConsumableProductAutoTopupParams,
  PlatformBillingInformation,
  ProjectCreditUsage,
  PurchasablePlan,
  CheckoutPlanParams,
  CheckoutSessionResponse,
  SetupPaymentParams,
  AdjustUnconsumableFeatureQuantityParams,
  CancelSubscriptionRequest,
} from '@activepieces/shared';

import { api } from '@/lib/api';

export const platformBillingApi = {
  getSubscriptionInfo() {
    return api.get<PlatformBillingInformation>('/v1/platform-billing/info');
  },
  refreshSubscriptionInfo() {
    return api.post<PlatformBillingInformation>(
      '/v1/platform-billing/refresh',
      {},
    );
  },
  listPlans() {
    return api.get<PurchasablePlan[]>('/v1/platform-billing/plans');
  },
  checkout(params: CheckoutPlanParams) {
    return api.post<CheckoutSessionResponse>(
      '/v1/platform-billing/checkout',
      params,
    );
  },
  getPortalLink() {
    return api.post<string>('/v1/platform-billing/portal');
  },
  cancel(request: CancelSubscriptionRequest) {
    return api.post<void>('/v1/platform-billing/cancel', request);
  },
  reactivate() {
    return api.post<void>('/v1/platform-billing/reactivate', {});
  },
  adjustUnconsumableFeatureQuantity(
    params: AdjustUnconsumableFeatureQuantityParams,
  ) {
    return api.post<{ paymentUrl: string | null }>(
      '/v1/platform-billing/unconsumable-feature-quantity',
      params,
    );
  },
  updateAutoTopUp(params: ConsumableProductAutoTopupParams) {
    return api.post<object>(
      '/v1/platform-billing/consumable-product-topups/auto-topup',
      params,
    );
  },
  setupPayment(params: SetupPaymentParams) {
    return api.post<{ url: string | null }>(
      '/v1/platform-billing/setup-payment',
      params,
    );
  },
  getProjectsUsage(params: {
    startDate?: string;
    endDate?: string;
    cursor?: string;
    limit?: number;
  }) {
    return api.get<SeekPage<ProjectCreditUsage>>(
      '/v1/platform-billing/projects-usage',
      params,
    );
  },
};