import { Response, QueryParams } from "./server"; import { Json } from "./interfaces"; /** * Base class for all API resources. */ export declare abstract class Resource { /** * Provide an implementation for serializing the resource for the API server. */ abstract serializeAPI(): any; /** * Provide an implementation for deserializing data from the API server. * * @param data The data from the API server */ abstract deserializeAPI(data: any): void; /** * Provide an implementation for serializing the resource for the Redux store. * * @returns data for the redux store. */ abstract serializeRedux(): any; /** * Provide an implementation for handling errors from the API server. * * @param response The response from the server, */ protected static handleError(response: Response): Resource | null; /** * Provide an implementation for creating the resource from API server data. * * @param data The data from the server * * @returns A new resource created from the given data. */ static apiFactory(data: any): Resource; /** * Provide an implementation for creating the resource from the Redux store. * * @param data The data from the Redux store * * @returns A new resource created from the given data. */ static reduxFactory(data: any): Resource; /** * Name of the resource */ static get resourceName(): string; /** * The name of the service the resource belongs to. */ static get serviceName(): string; /** * The path to the resource on the API server. */ static get path(): string; /** * The id for the resource. */ get id(): string | undefined; set id(id: string | undefined); private _id?; /** * Indicates if the resource may have differences with the server data * True until its saved successfully */ private _dirty; /** * Indicates if the resource may have differences with the server data * True until its saved successfully */ get isDirty(): boolean; /** * Fetch the resource from the server. * * @param id The id of the resource. * * @returns The resource. */ static get(id: string): Promise; /** * List the resource. * * @param queryParams Params to send with the request. * * @returns The list of resources from the server. */ static list(queryParams?: QueryParams): Promise>; /** * Create or update this resource on the server. */ save(): Promise; /** * Delete the resource on the server. */ delete(): Promise; /** * Parse a response from the list endpoint from the API server. * * @param data Data from the server * * @returns The list of data from the api server. */ protected static parseList(data: Response["data"]): Array; }