UNPKG

@codesandbox/api

Version:
61 lines (60 loc) 1.72 kB
import { GQLApi } from "./GQLApi"; import { RESTApi } from "./RESTApi"; import { ServerApi } from "./ServerApi"; import { SessionApi } from "./SessionApi"; import type { CodeSandboxApiOptions } from "./types"; export * as rest from "./RESTTypes"; export * as gql from "./generated_gql"; export { ApiResponseError } from "./utils"; export declare class CodeSandboxApi { gql: GQLApi; rest: RESTApi; session: SessionApi; server: ServerApi; private rootApiRequest; constructor(options: CodeSandboxApiOptions); private createQueryPath; /** * Do a generic GET request to the API */ get<T>(options: { path: string; headers?: Record<string, string>; query?: Record<string, string>; }): Promise<T>; /** * Do a generic POST request to the API */ post<T>(options: { path: string; data?: Record<string, unknown>; headers?: Record<string, string>; query?: Record<string, string>; }): Promise<T>; /** * Do a generic PUT request to the API */ put<T>(options: { path: string; data: Record<string, unknown>; headers?: Record<string, string>; query?: Record<string, string>; }): Promise<T>; /** * Do a generic PATCH request to the API */ patch<T>(options: { path: string; data: Record<string, unknown>; headers?: Record<string, string>; query?: Record<string, string>; }): Promise<T>; /** * Do a generic DELETE request to the API */ delete<T>(options: { path: string; headers?: Record<string, string>; query?: Record<string, string>; }): Promise<T>; }