/* tslint:disable */
/* eslint-disable */
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 { Sensors } from '../models/sensors';


/**
 * Analitics endpoints
 */
@Injectable({
  providedIn: 'root',
})
export class AnalyticsService extends BaseService {
  constructor(
    config: ApiConfiguration,
    http: HttpClient
  ) {
    super(config, http);
  }

  /**
   * Path part for operation getAnalytics
   */
  static readonly GetAnalyticsPath = '/analytics/analytics';

  /**
   * Get analytics.
   *
   *
   *
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `getAnalytics()` instead.
   *
   * This method doesn't expect any request body.
   */
  getAnalytics$Response(params: {
    unit_id: number;
    sensor_id?: number;
    from?: string;
    to?: string;
    interval?: string;
  }): Observable<StrictHttpResponse<Array<any>>> {

    const rb = new RequestBuilder(this.rootUrl, AnalyticsService.GetAnalyticsPath, '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, {});
      rb.query('interval', params.interval, {});
    }

    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<any>>;
      })
    );
  }

  /**
   * Get analytics.
   *
   *
   *
   * This method provides access to only to the response body.
   * To access the full response (for headers, for example), `getAnalytics$Response()` instead.
   *
   * This method doesn't expect any request body.
   */
  getAnalytics(params: {
    unit_id: number;
    sensor_id?: number;
    from?: string;
    to?: string;
    interval?: string;
  }): Observable<Array<any>> {

    return this.getAnalytics$Response(params).pipe(
      map((r: StrictHttpResponse<Array<any>>) => r.body as Array<any>)
    );
  }

}
