File

libs/core/src/lib/api-communication/connectors/sta-api-v1-connector/insert/sta-insert-interface.service.ts

Index

Methods

Constructor

constructor(http: HttpClient)
Parameters :
Name Type Optional
http HttpClient No

Methods

Protected createRequestUrl
createRequestUrl(apiUrl: string, endpoint: string, id?: string)
Parameters :
Name Type Optional
apiUrl string No
endpoint string No
id string Yes
Returns : string
insertDatastream
insertDatastream(apiUrl: string, datastream: InsertDatastream)
Parameters :
Name Type Optional
apiUrl string No
datastream InsertDatastream No
Returns : Observable<Datastream>
insertFeatureOfInterest
insertFeatureOfInterest(apiUrl: string, featureOfInterest: InsertFeatureOfInterest)
Parameters :
Name Type Optional
apiUrl string No
featureOfInterest InsertFeatureOfInterest No
Returns : Observable<FeatureOfInterest>
insertHistoricalLocation
insertHistoricalLocation(apiUrl: string, historicalLocation: InsertHistoricalLocation)
Parameters :
Name Type Optional
apiUrl string No
historicalLocation InsertHistoricalLocation No
Returns : Observable<HistoricalLocation>
insertLocation
insertLocation(apiUrl: string, location: InsertLocation)
Parameters :
Name Type Optional
apiUrl string No
location InsertLocation No
insertObservation
insertObservation(apiUrl: string, observation: InsertObservation)
Parameters :
Name Type Optional
apiUrl string No
observation InsertObservation No
insertObservedProperty
insertObservedProperty(apiUrl: string, observedProperty: InsertObservedProperty)
Parameters :
Name Type Optional
apiUrl string No
observedProperty InsertObservedProperty No
insertSensor
insertSensor(apiUrl: string, sensor: InsertSensor)
Parameters :
Name Type Optional
apiUrl string No
sensor InsertSensor No
Returns : Observable<Sensor>
insertThing
insertThing(apiUrl: string, thing: InsertThing)
Parameters :
Name Type Optional
apiUrl string No
thing InsertThing No
Returns : Observable<Thing>
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

import { Datastream, InsertDatastream } from '../model/datasetreams';
import { FeatureOfInterest, InsertFeatureOfInterest } from '../model/features-of-interest';
import { InsertLocation, Location } from '../model/locations';
import { InsertObservation, Observation } from '../model/observations';
import { StaEndpoint, StaInsertInterface } from '../model/sta-interface';
import { InsertThing, Thing } from '../model/things';
import { HistoricalLocation, InsertHistoricalLocation } from './../model/historical-locations';
import { InsertObservedProperty, ObservedProperty } from './../model/observed-properties';
import { InsertSensor, Sensor } from './../model/sensors';

@Injectable()
export class StaInsertInterfaceService implements StaInsertInterface {

  constructor(
    protected http: HttpClient
  ) { }

  insertDatastream(apiUrl: string, datastream: InsertDatastream): Observable<Datastream> {
    return this.http.post<Datastream>(this.createRequestUrl(apiUrl, StaEndpoint.Datastreams), datastream);
  }

  insertFeatureOfInterest(apiUrl: string, featureOfInterest: InsertFeatureOfInterest): Observable<FeatureOfInterest> {
    return this.http.post<FeatureOfInterest>(this.createRequestUrl(apiUrl, StaEndpoint.FeaturesOfInterest), featureOfInterest);
  }

  insertHistoricalLocation(apiUrl: string, historicalLocation: InsertHistoricalLocation): Observable<HistoricalLocation> {
    return this.http.post<HistoricalLocation>(this.createRequestUrl(apiUrl, StaEndpoint.HistoricalLocations), historicalLocation);
  }

  insertLocation(apiUrl: string, location: InsertLocation): Observable<Location> {
    return this.http.post<Location>(this.createRequestUrl(apiUrl, StaEndpoint.Locations), location);
  }

  insertObservation(apiUrl: string, observation: InsertObservation): Observable<Observation> {
    return this.http.post<Observation>(this.createRequestUrl(apiUrl, StaEndpoint.Observations), observation);
  }

  insertObservedProperty(apiUrl: string, observedProperty: InsertObservedProperty): Observable<ObservedProperty> {
    return this.http.post<ObservedProperty>(this.createRequestUrl(apiUrl, StaEndpoint.ObservedProperties), observedProperty);
  }

  insertSensor(apiUrl: string, sensor: InsertSensor): Observable<Sensor> {
    return this.http.post<Sensor>(this.createRequestUrl(apiUrl, StaEndpoint.Sensors), sensor);
  }

  insertThing(apiUrl: string, thing: InsertThing): Observable<Thing> {
    return this.http.post<Thing>(this.createRequestUrl(apiUrl, StaEndpoint.Things), thing);
  }

  protected createRequestUrl(apiUrl: string, endpoint: string, id?: string) {
    // TODO: Check whether apiUrl ends with slash
    if (id !== null && id !== undefined) {
      return `${apiUrl}${endpoint}('${id}')`;
    } else {
      return `${apiUrl}${endpoint}`;
    }
  }

}

result-matching ""

    No results matching ""