UNPKG

angular-odata

Version:

Client side OData typescript library for Angular

83 lines (82 loc) 2.27 kB
import { HttpHeaders, HttpResponse } from '@angular/common/http'; import { ODataEntityAnnotations, ODataEntitiesAnnotations, ODataPropertyAnnotations } from '../annotations'; import { ODataResource } from './resource'; import { ODataApi } from '../api'; import { ODataRequest } from './request'; import { ODataContext } from '../helper'; import { ODataResponseOptions } from './options'; export type ODataEntity<T> = { entity: T | null; annots: ODataEntityAnnotations<T>; }; export type ODataEntities<T> = { entities: T[] | null; annots: ODataEntitiesAnnotations<T>; }; export type ODataProperty<T> = { property: T | null; annots: ODataPropertyAnnotations<T>; }; /** * OData Response */ export declare class ODataResponse<T> extends HttpResponse<T> { readonly api: ODataApi; readonly resource: ODataResource<T>; constructor(init: { api: ODataApi; resource: ODataResource<T>; body: T | null; headers: HttpHeaders; status: number; statusText: string; url?: string; }); static fromHttpResponse<T>(req: ODataRequest<T>, res: HttpResponse<T>): ODataResponse<T>; static fromJson<T>(req: ODataRequest<T>, json: { body: T | null; headers: { [name: string]: string | string[]; }; status: number; statusText: string; url: string | null; }): ODataResponse<T>; toJson(): { body: T | null; headers: { [x: string]: string[]; }; status: number; statusText: string; url: string | null; }; private _options?; get options(): ODataResponseOptions; private _payload?; get payload(): any; private _context?; get context(): ODataContext; private _annotations?; get annotations(): Map<string, any>; /** * Handle the response body as an entity * @returns */ entity(): ODataEntity<T>; /** * Handle the response body as entities * @returns */ entities(): ODataEntities<T>; /** * Handle the response body as a property * @returns */ property(): ODataProperty<T>; /** * Handle the response body as a value * @returns */ value(): T | null; }