@c8y/client
Version:
Client application programming interface to access the Cumulocity IoT-Platform REST services.
45 lines • 2.37 kB
TypeScript
import { IFetchClient } from './IFetchClient';
import { IFetchOptions } from './IFetchOptions';
import { IFetchResponse } from './IFetchResponse';
import { IIdentified } from './IIdentified';
import { IResult } from './IResult';
import { IResultList } from './IResultList';
import { Paging } from './Paging';
import { Realtime } from '../realtime/index';
export declare abstract class Service<TData extends IIdentified> {
protected client: IFetchClient;
protected realtime?: Realtime;
protected propertyName: string;
protected abstract baseUrl: string;
protected abstract listUrl: string;
protected channel: string;
private cache;
constructor(client: IFetchClient, realtime?: Realtime);
list(filter?: object): Promise<IResultList<TData>>;
protected detail(entityOrId: string | number | IIdentified, filter?: object): Promise<IResult<TData>>;
protected create(entity: Partial<TData>): Promise<IResult<TData>>;
protected update(entity: Partial<TData>): Promise<IResult<TData>>;
protected delete(entityOrId: string | number | IIdentified, params?: any): Promise<IResult<null>>;
protected onBeforeCreate(obj: Partial<TData>): Partial<TData>;
protected onBeforeUpdate(objWithId: Partial<TData>): Partial<TData>;
protected changeFetchOptions(options: any, _url?: string): any;
protected getUrl(url?: string): string;
protected getEntityId(entityOrId: string | number | IIdentified): string;
protected getDetailUrl(entityOrId: string | number | IIdentified): string;
protected fetch(url: string, init?: IFetchOptions): Promise<IFetchResponse>;
/**
* Checks the response for errors and throws exceptions, otherwise returns the response as is.
*
* @param response The response from server.
*
* @returns If no errors are detected, it returns the same response.
*
* @throws If an error is detected, it throws `{ res, data }`, where `data` contains error details from server.
*/
protected handleErrorStatusCodes(response: IFetchResponse): Promise<IFetchResponse>;
protected mimeType(type: string): string;
protected getIdString(reference: number | string | IIdentified): string;
protected getPaging(json: any, filter: object): Paging<TData>;
protected getCurrentPageFromLink(link?: string): number;
}
//# sourceMappingURL=Service.d.ts.map