UNPKG

@formbricks/api

Version:

Formbricks-api is an api wrapper for the Formbricks client API

74 lines (64 loc) 2.49 kB
import { ForbiddenError } from '@formbricks/types/errors'; import { NetworkError } from '@formbricks/types/errors'; import { Result } from '@formbricks/types/error-handlers'; import { TAttributeUpdateInput } from '@formbricks/types/attributes'; import { TDisplayCreateInput } from '@formbricks/types/displays'; import { TResponseInput } from '@formbricks/types/responses'; import { TResponseUpdateInput } from '@formbricks/types/responses'; import { TUploadFileConfig } from '@formbricks/types/storage'; declare interface ApiConfig { environmentId: string; apiHost: string; } declare class AttributeAPI { private apiHost; private environmentId; constructor(apiHost: string, environmentId: string); update(attributeUpdateInput: Omit<TAttributeUpdateInput, "environmentId">): Promise<Result<{ changed: boolean; message: string; details?: Record<string, string>; }, NetworkError | Error | ForbiddenError>>; } declare class Client { response: ResponseAPI; display: DisplayAPI; storage: StorageAPI; attribute: AttributeAPI; constructor(options: ApiConfig); } declare class DisplayAPI { private apiHost; private environmentId; constructor(baseUrl: string, environmentId: string); create(displayInput: Omit<TDisplayCreateInput, "environmentId">): Promise<Result<{ id: string; }, ForbiddenError | NetworkError | Error>>; } export declare class FormbricksAPI { client: Client; constructor(options: ApiConfig); } declare class ResponseAPI { private apiHost; private environmentId; constructor(apiHost: string, environmentId: string); create(responseInput: Omit<TResponseInput, "environmentId">): Promise<Result<{ id: string; }, ForbiddenError | NetworkError | Error>>; update({ responseId, finished, endingId, data, ttc, variables, language, }: TResponseUpdateInputWithResponseId): Promise<Result<object, NetworkError | Error | ForbiddenError>>; } declare class StorageAPI { private apiHost; private environmentId; constructor(apiHost: string, environmentId: string); uploadFile(file: { type: string; name: string; base64: string; }, { allowedFileExtensions, surveyId }?: TUploadFileConfig | undefined): Promise<string>; } declare type TResponseUpdateInputWithResponseId = TResponseUpdateInput & { responseId: string; }; export { }