| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- /* tslint:disable */
- /* eslint-disable */
- import { formatDate } from '@angular/common';
- import { Injectable } from '@angular/core';
- import { HttpClient, HttpResponse } from '@angular/common/http';
- import { BaseService } from '../base-service';
- import { ApiConfiguration } from '../api-configuration';
- import { StrictHttpResponse } from '../strict-http-response';
- import { RequestBuilder } from '../request-builder';
- import { Observable } from 'rxjs';
- import { map, filter } from 'rxjs/operators';
- import { OldObservation } from '../models/old-observation';
- /**
- * Observations endpoints
- */
- @Injectable({
- providedIn: 'root',
- })
- export class ObservationService extends BaseService {
- constructor(
- config: ApiConfiguration,
- http: HttpClient
- ) {
- super(config, http);
- }
- /**
- * Path part for operation getObservation
- */
- static readonly GetObservationPath = '/senslog15/SensorService?Operation=GetObservations';
- static readonly RestObservationsPath = '/senslog15/rest/observation/';
- /**
- * Get observation.
- *
- *
- *
- * This method provides access to the full `HttpResponse`, allowing access to response headers.
- * To access only the response body, use `getObservation()` instead.
- *
- * This method doesn't expect any request body.
- */
- getObservation$Response(params: {
- unit_id: number;
- sensor_id: number;
- from?: string;
- to?: string;
- }): Observable<StrictHttpResponse<Array<OldObservation>>> {
- const rb = new RequestBuilder(this.rootUrl, ObservationService.GetObservationPath, 'get');
- if (params) {
- rb.query('unit_id', params.unit_id, {});
- rb.query('sensor_id', params.sensor_id, {});
- rb.query('from', params.from, {});
- rb.query('to', params.to, {});
- }
- return this.http.request(rb.build({
- responseType: 'json',
- accept: 'application/json'
- })).pipe(
- filter((r: any) => r instanceof HttpResponse),
- map((r: HttpResponse<any>) => {
- return r as StrictHttpResponse<Array<OldObservation>>;
- })
- );
- }
- /**
- * Get observation.
- *
- *
- *
- * This method provides access to only to the response body.
- * To access the full response (for headers, for example), `getObservation$Response()` instead.
- *
- * This method doesn't expect any request body.
- */
- getObservation(params: {
- unit_id: number;
- sensor_id: number;
- from?: string;
- to?: string;
- }): Observable<Array<OldObservation>> {
- return this.getObservation$Response(params).pipe(
- map((r: StrictHttpResponse<Array<OldObservation>>) => r.body as Array<OldObservation>)
- );
- }
- exportObservations(params: {
- //group_id: number,
- sensor_id: number,
- from?: Date;
- to?: Date;
- }): Observable<StrictHttpResponse<string>> {
- const rb = new RequestBuilder(this.rootUrl, ObservationService.RestObservationsPath + 'export', 'get');
- if (params) {
- rb.query('sensor_id', params.sensor_id);
- rb.query('from_time', formatDate(params.from, 'yyyy-MM-dd', 'en-US'));
- rb.query('to_time', formatDate(params.to, 'yyyy-MM-dd', 'en-US'));
- rb.query('style', 'crosstab');
- rb.query('nullable', false);
- }
- return this.http.request(rb.build({
- responseType: 'text',
- accept: 'text/plain'
- })).pipe(
- filter((r: any) => r instanceof HttpResponse),
- map((r: HttpResponse<any>) => {
- return r as StrictHttpResponse<string>;
- })
- );
- }
- }
|