Skip to main content
Glama
newsletter.ts2.14 kB
import configuration from '@intlayer/config/built'; import type { IntlayerConfig } from '@intlayer/types'; import { type FetcherOptions, fetcher } from '../fetcher'; import type { NewsletterSubscriptionBody, NewsletterSubscriptionResult, NewsletterUnsubscriptionBody, } from '../types'; export const getNewsletterAPI = ( authAPIOptions: FetcherOptions = {}, intlayerConfig?: IntlayerConfig ) => { const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL; if (!backendURL) { throw new Error( 'Backend URL is not defined in the Intlayer configuration.' ); } const NEWSLETTER_API_ROUTE = `${backendURL}/api/newsletter`; /** * Subscribe a user to newsletter(s) * @param body - Newsletter subscription parameters. * @returns Newsletter subscription result. */ const subscribeToNewsletter = async ( body: NewsletterSubscriptionBody, otherOptions: FetcherOptions = {} ) => await fetcher<NewsletterSubscriptionResult>( `${NEWSLETTER_API_ROUTE}/subscribe`, authAPIOptions, otherOptions, { method: 'POST', body: body, } ); /** * Unsubscribe a user from newsletter(s) * @param body - Newsletter unsubscription parameters. * @returns Newsletter unsubscription result. */ const unsubscribeFromNewsletter = async ( body: NewsletterUnsubscriptionBody, otherOptions: FetcherOptions = {} ) => await fetcher<NewsletterSubscriptionResult>( `${NEWSLETTER_API_ROUTE}/unsubscribe`, authAPIOptions, otherOptions, { method: 'POST', body: body, } ); /** * Get newsletter subscription status for the authenticated user * @returns Newsletter subscription status. */ const getNewsletterStatus = async (otherOptions: FetcherOptions = {}) => await fetcher<NewsletterSubscriptionResult>( `${NEWSLETTER_API_ROUTE}/status`, authAPIOptions, otherOptions, { method: 'GET', } ); return { subscribeToNewsletter, unsubscribeFromNewsletter, getNewsletterStatus, }; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server