/* tslint:disable */
import { Injectable } from '@angular/core';
import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http';
import { BaseService as __BaseService } from '../base-service';
import { CatConfiguration as __Configuration } from '../cat-configuration';
import { StrictHttpResponse as __StrictHttpResponse } from '../strict-http-response';
import { Observable as __Observable } from 'rxjs';
import { map as __map, filter as __filter } from 'rxjs/operators';

import { ListResponseArgsOfItemDTO } from '../models/list-response-args-of-item-dto';
import { QueryTokenDTO } from '../models/query-token-dto';
import { ListResponseArgsOfAutocompleteDTO } from '../models/list-response-args-of-autocomplete-dto';
import { AutocompleteTokenDTO } from '../models/autocomplete-token-dto';
import { ResponseArgsOfItemDTO } from '../models/response-args-of-item-dto';
import { ResponseArgsOfUISettingsDTO } from '../models/response-args-of-uisettings-dto';
import { ResponseArgsOfIEnumerableOfQueryTokenDTO } from '../models/response-args-of-ienumerable-of-query-token-dto';
import { ResponseArgsOfIEnumerableOfItemDTO } from '../models/response-args-of-ienumerable-of-item-dto';
@Injectable({
  providedIn: 'root',
})
class SearchService extends __BaseService {
  static readonly SearchTopPath = '/s/top';
  static readonly SearchSearchPath = '/s';
  static readonly SearchAutocompletePath = '/s/complete';
  static readonly SearchByIdPath = '/s/byid';
  static readonly SearchByEANPath = '/s/byean';
  static readonly SearchDetailPath = '/s/{id}';
  static readonly SearchDetailByEANPath = '/s/ean/{ean}';
  static readonly SearchSettingsPath = '/s/settings';
  static readonly SearchHistoryPath = '/s/history';
  static readonly SearchGetRecommendationsPath = '/s/recommendations/{digId}';

  constructor(
    config: __Configuration,
    http: HttpClient
  ) {
    super(config, http);
  }

  /**
   * @param queryToken undefined
   */
  SearchTopResponse(queryToken: QueryTokenDTO): __Observable<__StrictHttpResponse<ListResponseArgsOfItemDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    __body = queryToken;
    let req = new HttpRequest<any>(
      'POST',
      this.rootUrl + `/s/top`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ListResponseArgsOfItemDTO>;
      })
    );
  }
  /**
   * @param queryToken undefined
   */
  SearchTop(queryToken: QueryTokenDTO): __Observable<ListResponseArgsOfItemDTO> {
    return this.SearchTopResponse(queryToken).pipe(
      __map(_r => _r.body as ListResponseArgsOfItemDTO)
    );
  }

  /**
   * @param queryToken undefined
   */
  SearchSearchResponse(queryToken: QueryTokenDTO): __Observable<__StrictHttpResponse<ListResponseArgsOfItemDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    __body = queryToken;
    let req = new HttpRequest<any>(
      'POST',
      this.rootUrl + `/s`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ListResponseArgsOfItemDTO>;
      })
    );
  }
  /**
   * @param queryToken undefined
   */
  SearchSearch(queryToken: QueryTokenDTO): __Observable<ListResponseArgsOfItemDTO> {
    return this.SearchSearchResponse(queryToken).pipe(
      __map(_r => _r.body as ListResponseArgsOfItemDTO)
    );
  }

  /**
   * @param queryToken undefined
   */
  SearchAutocompleteResponse(queryToken: AutocompleteTokenDTO): __Observable<__StrictHttpResponse<ListResponseArgsOfAutocompleteDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    __body = queryToken;
    let req = new HttpRequest<any>(
      'POST',
      this.rootUrl + `/s/complete`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ListResponseArgsOfAutocompleteDTO>;
      })
    );
  }
  /**
   * @param queryToken undefined
   */
  SearchAutocomplete(queryToken: AutocompleteTokenDTO): __Observable<ListResponseArgsOfAutocompleteDTO> {
    return this.SearchAutocompleteResponse(queryToken).pipe(
      __map(_r => _r.body as ListResponseArgsOfAutocompleteDTO)
    );
  }

  /**
   * @param ids undefined
   */
  SearchByIdResponse(ids: Array<number>): __Observable<__StrictHttpResponse<ListResponseArgsOfItemDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    __body = ids;
    let req = new HttpRequest<any>(
      'POST',
      this.rootUrl + `/s/byid`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ListResponseArgsOfItemDTO>;
      })
    );
  }
  /**
   * @param ids undefined
   */
  SearchById(ids: Array<number>): __Observable<ListResponseArgsOfItemDTO> {
    return this.SearchByIdResponse(ids).pipe(
      __map(_r => _r.body as ListResponseArgsOfItemDTO)
    );
  }

  /**
   * @param eans undefined
   */
  SearchByEANResponse(eans: Array<string>): __Observable<__StrictHttpResponse<ListResponseArgsOfItemDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    __body = eans;
    let req = new HttpRequest<any>(
      'POST',
      this.rootUrl + `/s/byean`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ListResponseArgsOfItemDTO>;
      })
    );
  }
  /**
   * @param eans undefined
   */
  SearchByEAN(eans: Array<string>): __Observable<ListResponseArgsOfItemDTO> {
    return this.SearchByEANResponse(eans).pipe(
      __map(_r => _r.body as ListResponseArgsOfItemDTO)
    );
  }

  /**
   * @param id undefined
   */
  SearchDetailResponse(id: number): __Observable<__StrictHttpResponse<ResponseArgsOfItemDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;

    let req = new HttpRequest<any>(
      'GET',
      this.rootUrl + `/s/${id}`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ResponseArgsOfItemDTO>;
      })
    );
  }
  /**
   * @param id undefined
   */
  SearchDetail(id: number): __Observable<ResponseArgsOfItemDTO> {
    return this.SearchDetailResponse(id).pipe(
      __map(_r => _r.body as ResponseArgsOfItemDTO)
    );
  }

  /**
   * @param ean undefined
   */
  SearchDetailByEANResponse(ean: null | string): __Observable<__StrictHttpResponse<ResponseArgsOfItemDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;

    let req = new HttpRequest<any>(
      'GET',
      this.rootUrl + `/s/ean/${ean}`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ResponseArgsOfItemDTO>;
      })
    );
  }
  /**
   * @param ean undefined
   */
  SearchDetailByEAN(ean: null | string): __Observable<ResponseArgsOfItemDTO> {
    return this.SearchDetailByEANResponse(ean).pipe(
      __map(_r => _r.body as ResponseArgsOfItemDTO)
    );
  }
  SearchSettingsResponse(): __Observable<__StrictHttpResponse<ResponseArgsOfUISettingsDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    let req = new HttpRequest<any>(
      'GET',
      this.rootUrl + `/s/settings`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ResponseArgsOfUISettingsDTO>;
      })
    );
  }  SearchSettings(): __Observable<ResponseArgsOfUISettingsDTO> {
    return this.SearchSettingsResponse().pipe(
      __map(_r => _r.body as ResponseArgsOfUISettingsDTO)
    );
  }

  /**
   * @param take undefined
   */
  SearchHistoryResponse(take?: null | number): __Observable<__StrictHttpResponse<ResponseArgsOfIEnumerableOfQueryTokenDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    if (take != null) __params = __params.set('take', take.toString());
    let req = new HttpRequest<any>(
      'GET',
      this.rootUrl + `/s/history`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ResponseArgsOfIEnumerableOfQueryTokenDTO>;
      })
    );
  }
  /**
   * @param take undefined
   */
  SearchHistory(take?: null | number): __Observable<ResponseArgsOfIEnumerableOfQueryTokenDTO> {
    return this.SearchHistoryResponse(take).pipe(
      __map(_r => _r.body as ResponseArgsOfIEnumerableOfQueryTokenDTO)
    );
  }

  /**
   * @param params The `SearchService.SearchGetRecommendationsParams` containing the following parameters:
   *
   * - `digId`:
   *
   * - `sessionId`:
   */
  SearchGetRecommendationsResponse(params: SearchService.SearchGetRecommendationsParams): __Observable<__StrictHttpResponse<ResponseArgsOfIEnumerableOfItemDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;

    if (params.sessionId != null) __params = __params.set('sessionId', params.sessionId.toString());
    let req = new HttpRequest<any>(
      'GET',
      this.rootUrl + `/s/recommendations/${params.digId}`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ResponseArgsOfIEnumerableOfItemDTO>;
      })
    );
  }
  /**
   * @param params The `SearchService.SearchGetRecommendationsParams` containing the following parameters:
   *
   * - `digId`:
   *
   * - `sessionId`:
   */
  SearchGetRecommendations(params: SearchService.SearchGetRecommendationsParams): __Observable<ResponseArgsOfIEnumerableOfItemDTO> {
    return this.SearchGetRecommendationsResponse(params).pipe(
      __map(_r => _r.body as ResponseArgsOfIEnumerableOfItemDTO)
    );
  }
}

module SearchService {

  /**
   * Parameters for SearchGetRecommendations
   */
  export interface SearchGetRecommendationsParams {
    digId: null | string;
    sessionId?: null | string;
  }
}

export { SearchService }
