libs/eventing/src/lib/eventing-impl-api-interface.service.ts
Methods |
|
constructor(httpService: HttpService)
|
||||||
Parameters :
|
Private addParameterFilter | ||||||||||||
addParameterFilter(params: EventingFilter, key: string, httpParams: HttpParams)
|
||||||||||||
Parameters :
Returns :
HttpParams
|
Private addTimespan | |||||||||
addTimespan(timespan: Timespan, httpParams: HttpParams)
|
|||||||||
Parameters :
Returns :
HttpParams
|
Public getEvent | ||||||||||||||||
getEvent(id: string, apiUrl: string, options: HttpRequestOptions)
|
||||||||||||||||
Parameters :
Returns :
Observable<Event>
|
Public getEvents | ||||||||||||||||
getEvents(apiUrl: string, filterParameter: EventFilter, options: HttpRequestOptions)
|
||||||||||||||||
Parameters :
Returns :
Observable<EventResults>
|
Public getNotification | ||||||||||||
getNotification(id: string, apiUrl: string, options?: HttpRequestOptions)
|
||||||||||||
Parameters :
Returns :
Observable<Notification>
|
Public getNotifications | ||||||||||||||||
getNotifications(apiUrl: string, filterParameter: NotificationFilter, options?: HttpRequestOptions)
|
||||||||||||||||
Parameters :
Returns :
Observable<NotificationResults>
|
Public getPublication | ||||||||||||||||
getPublication(id: string, apiUrl: string, options: HttpRequestOptions)
|
||||||||||||||||
Parameters :
Returns :
Observable<Publication>
|
Public getPublications | ||||||||||||||||
getPublications(apiUrl: string, filterParameter: PublicationFilter, options?: HttpRequestOptions)
|
||||||||||||||||
Parameters :
Returns :
Observable<PublicationResults>
|
Public getSubscription | ||||||||||||||||
getSubscription(id: string, apiUrl: string, options: HttpRequestOptions)
|
||||||||||||||||
Parameters :
Returns :
Observable<Subscription>
|
Public getSubscriptions | ||||||||||||||||
getSubscriptions(apiUrl: string, filterParameter: SubscriptionFilter, options: HttpRequestOptions)
|
||||||||||||||||
Parameters :
Returns :
Observable<SubscriptionResults>
|
Protected prepareFilterParams | ||||||
prepareFilterParams(params: EventingFilter)
|
||||||
Parameters :
Returns :
HttpParams
|
Protected requestApi | ||||||||||||||||
requestApi(url: string, params: HttpParams, options: HttpRequestOptions)
|
||||||||||||||||
Type parameters :
|
||||||||||||||||
Parameters :
Returns :
Observable<T>
|
Public Abstract getEvent | ||||||||||||
getEvent(id: string, apiUrl: string, options?: HttpRequestOptions)
|
||||||||||||
Inherited from
EventingApiService
|
||||||||||||
Defined in
EventingApiService:17
|
||||||||||||
Parameters :
Returns :
Observable<Event>
|
Public Abstract getEvents | ||||||||||||
getEvents(apiUrl: string, params?: EventFilter, options?: HttpRequestOptions)
|
||||||||||||
Inherited from
EventingApiService
|
||||||||||||
Defined in
EventingApiService:15
|
||||||||||||
Parameters :
Returns :
Observable<EventResults>
|
Public Abstract getNotification | ||||||||||||
getNotification(id: string, apiUrl: string, options?: HttpRequestOptions)
|
||||||||||||
Inherited from
EventingApiService
|
||||||||||||
Defined in
EventingApiService:29
|
||||||||||||
Parameters :
Returns :
Observable<Notification>
|
Public Abstract getNotifications | ||||||||||||
getNotifications(apiUrl: string, params?: NotificationFilter, options?: HttpRequestOptions)
|
||||||||||||
Inherited from
EventingApiService
|
||||||||||||
Defined in
EventingApiService:27
|
||||||||||||
Parameters :
Returns :
Observable<NotificationResults>
|
Public Abstract getPublication | ||||||||||||
getPublication(id: string, apiUrl: string, options?: HttpRequestOptions)
|
||||||||||||
Inherited from
EventingApiService
|
||||||||||||
Defined in
EventingApiService:25
|
||||||||||||
Parameters :
Returns :
Observable<Publication>
|
Public Abstract getPublications | ||||||||||||
getPublications(apiUrl: string, params?: PublicationFilter, options?: HttpRequestOptions)
|
||||||||||||
Inherited from
EventingApiService
|
||||||||||||
Defined in
EventingApiService:23
|
||||||||||||
Parameters :
Returns :
Observable<PublicationResults>
|
Public Abstract getSubscription | ||||||||||||
getSubscription(id: string, apiUrl: string, options?: HttpRequestOptions)
|
||||||||||||
Inherited from
EventingApiService
|
||||||||||||
Defined in
EventingApiService:21
|
||||||||||||
Parameters :
Returns :
Observable<Subscription>
|
Public Abstract getSubscriptions | ||||||||||||
getSubscriptions(apiUrl: string, params?: SubscriptionFilter, options?: HttpRequestOptions)
|
||||||||||||
Inherited from
EventingApiService
|
||||||||||||
Defined in
EventingApiService:19
|
||||||||||||
Parameters :
Returns :
Observable<SubscriptionResults>
|
Protected createBasicAuthHeader | ||||||
createBasicAuthHeader(token: string)
|
||||||
Inherited from
EventingApiService
|
||||||
Defined in
EventingApiService:19
|
||||||
Parameters :
Returns :
HttpHeaders
|
Protected createRequestTimespan | ||||||
createRequestTimespan(timespan: Timespan)
|
||||||
Inherited from
EventingApiService
|
||||||
Defined in
EventingApiService:15
|
||||||
Parameters :
Returns :
string
|
Protected createRequestUrl |
createRequestUrl(apiUrl: string, endpoint: string, id?: string)
|
Inherited from
EventingApiService
|
Defined in
EventingApiService:8
|
Returns :
string
|
Protected createBasicAuthHeader | ||||||
createBasicAuthHeader(token: string)
|
||||||
Inherited from
ApiInterface
|
||||||
Defined in
ApiInterface:19
|
||||||
Parameters :
Returns :
HttpHeaders
|
Protected createRequestTimespan | ||||||
createRequestTimespan(timespan: Timespan)
|
||||||
Inherited from
ApiInterface
|
||||||
Defined in
ApiInterface:15
|
||||||
Parameters :
Returns :
string
|
Protected createRequestUrl |
createRequestUrl(apiUrl: string, endpoint: string, id?: string)
|
Inherited from
ApiInterface
|
Defined in
ApiInterface:8
|
Returns :
string
|
import { HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { HttpRequestOptions, HttpService, Timespan, UriParameterCoder } from '@helgoland/core';
import { Observable } from 'rxjs';
import { EventingApiService } from './eventing-api.service';
import { EventingFilter } from './model/request/common';
import { EventFilter } from './model/request/events';
import { NotificationFilter } from './model/request/notifications';
import { PublicationFilter } from './model/request/publications';
import { SubscriptionFilter } from './model/request/subscriptions';
import { Event, EventResults } from './model/response/events';
import { Notification, NotificationResults } from './model/response/notifications';
import { Publication, PublicationResults } from './model/response/publications';
import { Subscription, SubscriptionResults } from './model/response/subscriptions';
@Injectable()
export class EventingImplApiInterface extends EventingApiService {
constructor(
private httpService: HttpService
) { super(); }
public getEvents(apiUrl: string, filterParameter: EventFilter = {}, options: HttpRequestOptions = {}): Observable<EventResults> {
const url = this.createRequestUrl(apiUrl, 'events');
let httpParams = this.prepareFilterParams(filterParameter);
httpParams = this.addParameterFilter(filterParameter, 'latest', httpParams);
httpParams = this.addParameterFilter(filterParameter, 'subscriptions', httpParams);
httpParams = this.addTimespan(filterParameter.timespan, httpParams);
return this.requestApi<EventResults>(url, httpParams, options);
}
public getEvent(id: string, apiUrl: string, options: HttpRequestOptions = {}): Observable<Event> {
const url = this.createRequestUrl(apiUrl, 'events', id);
return this.requestApi<Event>(url, null, options);
}
public getSubscriptions(apiUrl: string, filterParameter: SubscriptionFilter = {}, options: HttpRequestOptions = {}): Observable<SubscriptionResults> {
const url = this.createRequestUrl(apiUrl, 'subscriptions');
const httpParams = this.prepareFilterParams(filterParameter);
return this.requestApi<SubscriptionResults>(url, httpParams, options);
}
public getSubscription(id: string, apiUrl: string, options: HttpRequestOptions = {}): Observable<Subscription> {
const url = this.createRequestUrl(apiUrl, 'subscriptions', id);
return this.requestApi<Subscription>(url, null, options);
}
public getPublications(apiUrl: string, filterParameter: PublicationFilter = {}, options?: HttpRequestOptions): Observable<PublicationResults> {
const url = this.createRequestUrl(apiUrl, 'publications');
let httpParams = this.prepareFilterParams(filterParameter);
httpParams = this.addParameterFilter(filterParameter, 'feature', httpParams);
return this.requestApi<PublicationResults>(url, httpParams, options);
}
public getPublication(id: string, apiUrl: string, options: HttpRequestOptions = {}): Observable<Publication> {
const url = this.createRequestUrl(apiUrl, 'publications', id);
return this.requestApi<Publication>(url, null, options);
}
public getNotifications(apiUrl: string, filterParameter: NotificationFilter = {}, options?: HttpRequestOptions): Observable<NotificationResults> {
const url = this.createRequestUrl(apiUrl, 'notifications');
let httpParams = this.prepareFilterParams(filterParameter);
httpParams = this.addParameterFilter(filterParameter, 'publications', httpParams);
return this.requestApi<NotificationResults>(url, httpParams, options);
}
public getNotification(id: string, apiUrl: string, options?: HttpRequestOptions): Observable<Notification> {
const url = this.createRequestUrl(apiUrl, 'notifications', id);
return this.requestApi<Notification>(url, null, options);
}
protected requestApi<T>(url: string, params: HttpParams = new HttpParams(), options: HttpRequestOptions = {}): Observable<T> {
const headers = this.createBasicAuthHeader(options.basicAuthToken);
return this.httpService.client(options).get<T>(url, { params, headers });
}
protected prepareFilterParams(params: EventingFilter): HttpParams {
let httpParams = new HttpParams({ encoder: new UriParameterCoder() });
httpParams = this.addParameterFilter(params, 'expanded', httpParams);
httpParams = this.addParameterFilter(params, 'offset', httpParams);
httpParams = this.addParameterFilter(params, 'limit', httpParams);
return httpParams;
}
private addTimespan(timespan: Timespan, httpParams: HttpParams): HttpParams {
if (timespan !== undefined) {
return httpParams.set('timespan', this.createRequestTimespan(timespan));
}
return httpParams;
}
private addParameterFilter(params: EventingFilter, key: string, httpParams: HttpParams): HttpParams {
if (params && params[key] !== undefined) {
if (params[key] instanceof Array) {
return httpParams.set(key, params[key].join(','));
}
return httpParams.set(key, params[key]);
}
return httpParams;
}
}