Skip to main content
Glama
client.ts1.83 kB
import { AuthenticationType, httpClient, HttpMethod, HttpRequest, } from '@activepieces/pieces-common'; import { bexioCommon } from './index'; export class BexioClient { constructor(private auth: {access_token: string}) {} async makeRequest<T>( method: HttpMethod, endpoint: string, data?: unknown, queryParams?: Record<string, string> ): Promise<T> { // If endpoint already includes version (starts with /2.0/ or /3.0/), use it directly // Otherwise, prepend the default API version const url = endpoint.startsWith('/2.0/') || endpoint.startsWith('/3.0/') ? `${bexioCommon.baseUrl}${endpoint}` : `${bexioCommon.baseUrl}/${bexioCommon.api_version}${endpoint}`; const request: HttpRequest = { method, url, authentication: { type: AuthenticationType.BEARER_TOKEN, token: this.auth.access_token, }, headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, }; if (data) { request.body = data; } if (queryParams) { request.queryParams = queryParams; } const response = await httpClient.sendRequest<T>(request); return response.body; } async get<T>(endpoint: string, queryParams?: Record<string, string>): Promise<T> { return this.makeRequest<T>(HttpMethod.GET, endpoint, undefined, queryParams); } async post<T>(endpoint: string, data: unknown, queryParams?: Record<string, string>): Promise<T> { return this.makeRequest<T>(HttpMethod.POST, endpoint, data, queryParams); } async patch<T>(endpoint: string, data: unknown): Promise<T> { return this.makeRequest<T>(HttpMethod.PATCH, endpoint, data); } async delete<T>(endpoint: string): Promise<T> { return this.makeRequest<T>(HttpMethod.DELETE, endpoint); } }

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/activepieces/activepieces'

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