UNPKG

motidata

Version:

Data retrieval library for services (e.g. App) accessing MotiMate's main Api

54 lines 1.91 kB
import type { Serializable } from "child_process"; import type { SessionRepositoryInterface } from "./SessionRepositoryInterface.js"; type ApiBaseUrlType = (typeof BaseRepository.Api)[keyof typeof BaseRepository.Api]; export interface BaseRepositoryConstructorParam { apiBaseUrl: ApiBaseUrlType; publicApiKey: string; sessionRepository: SessionRepositoryInterface; } interface RequestParams { route: string; method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; queryParams?: URLSearchParams; extraHeaders?: Headers; body?: RequestInit["body"]; signal?: AbortSignal | null; } export declare abstract class BaseRepository { private apiBaseUrl; private publicApiKey; sessionRepository: SessionRepositoryInterface; static Api: { mockaroo: string; }; static Routes: { registration: string; activation: string; personalGoal: string; group: string; message: string; userInfo: string; }; constructor(apiBaseUrl: ApiBaseUrlType, publicApiKey: string, sessionRepository: SessionRepositoryInterface); /** * @throws any {@link sessionRepository} related Error */ private buildBaseHeaders; /** * Sets the Content-Type to application/json by default. Can be overridden by settin {@link extraHeaders}. * @protected * @throws any {@link sessionRepository} related Error */ _bulildRequest({ route, method, queryParams, extraHeaders, body, signal, }: RequestParams): Promise<Request>; /** * @protected */ _buildJsonRequest(unserializedBody: Serializable, requestParams: Omit<RequestParams, "body">): Promise<Request>; /** * @protected * @throws any {@link sessionRepository} related Error */ _handleResponseAfterAuthentication(response: Response): Promise<void>; } export {}; //# sourceMappingURL=BaseRepository.d.ts.map