import { HttpMethod } from '../../http/HttpRequest'; import { HalClient } from '../services/HalClient'; import { HalLink } from './HalLink'; /** * @hidden */ export interface HalResourceConstructor { new (data?: any): T; } /** * Base class for all Resources */ export declare class HalResource { _links?: Map; /** * @hidden */ protected _embedded: Map; /** * @hidden */ protected client?: HalClient; /** * Creates a new instance of the resource. * If data is provided it will be parsed as if it had * come from the remote api. * @param data */ constructor(data?: any); /** * Parses the data returned by the API into the model class * @hidden */ parse(data: any): void; /** * Returns a copy of this resource's attributes excluding links and client references */ toJSON(): any; /** * Returns a copy of this resource's attributes excluding links and client references * @deprecated */ toJson(): any; /** * Set automatically by the HalClient when the resource is created. * If this is not set the resource will be unable to resolve related * resources and actions. * * @hidden */ setClient(client: HalClient): void; /** * Converts an _embedded collection into an Array of * Resource instances. * @hidden */ protected parseEmbedded(name: string, resourceConstructor: HalResourceConstructor): T[]; /** * GET a linked resource * @hidden */ protected fetchLinkedResource(name: string, params: any, resourceConstructor: HalResourceConstructor): Promise; /** * POST / CREATE a new resource * @hidden */ protected createLinkedResource(name: string, params: any, resource: T, resourceConstructor: HalResourceConstructor): Promise; /** * POST to an action endpoint and get a resource response * @hidden */ protected performActionThatReturnsResource(name: string, params: any, data: any, resourceConstructor: HalResourceConstructor, method?: HttpMethod.POST | HttpMethod.PATCH | HttpMethod.PUT): Promise; /** * POST to an action endpoint and get a resource response with header data * @hidden */ protected performActionWithHeadersThatReturnsResource(name: string, params: any, data: any, resourceConstructor: HalResourceConstructor, method?: HttpMethod.POST | HttpMethod.PATCH | HttpMethod.PUT): Promise; /** * POST to an action endpoint with no resource response returned. */ protected performActionWithoutResourceResponse(name: string, params: any, data: any, method?: HttpMethod.POST | HttpMethod.PATCH | HttpMethod.PUT): Promise; /** * DELETE the current resource * @hidden */ protected deleteResource(): Promise; /** * DELETE a linked resource * @hidden */ protected deleteLinkedResource(name: string, params: any): Promise; /** * PATCH the current resource * @hidden */ protected updateResource(resource: T, resourceConstructor: HalResourceConstructor, params?: Record): Promise; /** * PATCH a linked resource * @hidden */ protected updateLinkedResource(name: string, params: any, resource: T, resourceConstructor: HalResourceConstructor): Promise; private withHalLink; }