UNPKG

@obelisk/client

Version:

Typescript client to interact with Obelisk on a higher level than the regular ReST API calls.

45 lines (44 loc) 1.53 kB
import { Observable } from 'rxjs'; import { AjaxResponse } from 'rxjs/ajax'; import { ApiVersion } from '../interfaces'; import { ObeliskClient } from '../obelisk-client'; /** * Endpoint class represents an Obelisk API Endpoint. */ export declare class Endpoint { private client; private _url; /** * Absolute url to use in requests */ get url(): string; /** * Creates an Endpoint instance, the client is used to add tokens and uri is relative path starting after /api/<version>. * Examples are: <code>/things/my_thing/metrics/my_metric/events?from=1530089953000</code> or <code>/locations/my_loc/metrics/my_metric/stats/unit</code> */ static create(client: ObeliskClient, uri: string, apiVersion?: ApiVersion): Endpoint; private constructor(); /** * Perform an ajax get request and handle any auth errors. */ get(): Observable<AjaxResponse>; /** * Perform an ajax head request and handle any auth errors. */ head(): Observable<AjaxResponse>; /** * Perform an ajax post request and handle any auth errors. * @param body The body */ post(body: any): Observable<AjaxResponse>; /** * Perform an ajax put request and handle any auth errors. * @param body The body */ put(body: any): Observable<AjaxResponse>; /** * Perform an ajax delete request and handle any auth errors. * @param body The body */ delete(): Observable<AjaxResponse>; }