/**
 * Agravity OpenAPI Documentation - Public Functions
 *
 * Contact: support@agravity.io
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */
/* tslint:disable:no-unused-variable member-ordering */

import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams, HttpResponse, HttpEvent, HttpContext } from '@angular/common/http';
import { Observable } from 'rxjs';
import { OpenApiHttpParams, QueryParamStyle } from '../query.params';

// @ts-ignore
import { AgravityErrorResponse } from '../model/agravityErrorResponse.pub.agravity';
// @ts-ignore
import { CollectionUDL } from '../model/collectionUDL.pub.agravity';
// @ts-ignore
import { CollectionUDLListEntity } from '../model/collectionUDLListEntity.pub.agravity';
// @ts-ignore
import { SearchableItem } from '../model/searchableItem.pub.agravity';

// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { AgravityPublicConfiguration } from '../configuration';
import { BaseService } from '../api.base.service';

export interface HttpGetAllUserDefinedListsRequestParams {
	/** When default language should be returned and the translation dictionary is delivered. (Ignores the \&quot;Accept-Language\&quot; header) */
	translations?: boolean;
	/** The requested language of the response. If not matching it falls back to default language. */
	acceptLanguage?: string;
}

export interface HttpGetAllowedFilterableItemsRequestParams {
	/** If the search should be redirected to a specific portal. */
	portalId?: string;
}

export interface HttpGetAllowedSearchableItemNamesRequestParams {
	/** If the search should be redirected to a specific portal. */
	portalId?: string;
}

export interface HttpGetAllowedSearchableItemsRequestParams {
	/** If the search should be redirected to a specific portal. */
	portalId?: string;
}

@Injectable({
	providedIn: 'root'
})
export class PublicHelperToolsService extends BaseService {
	constructor(
		protected httpClient: HttpClient,
		@Optional() @Inject(BASE_PATH) basePath: string | string[],
		@Optional() configuration?: AgravityPublicConfiguration
	) {
		super(basePath, configuration);
	}

	/**
	 * Returns all user defined lists of all collection types
	 * @endpoint get /helper/userdefinedlists
	 * @param requestParameters
	 * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
	 * @param reportProgress flag to report request and response progress.
	 * @param options additional options
	 */
	public httpGetAllUserDefinedLists(
		requestParameters?: HttpGetAllUserDefinedListsRequestParams,
		observe?: 'body',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<Array<CollectionUDL>>;
	public httpGetAllUserDefinedLists(
		requestParameters?: HttpGetAllUserDefinedListsRequestParams,
		observe?: 'response',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpResponse<Array<CollectionUDL>>>;
	public httpGetAllUserDefinedLists(
		requestParameters?: HttpGetAllUserDefinedListsRequestParams,
		observe?: 'events',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpEvent<Array<CollectionUDL>>>;
	public httpGetAllUserDefinedLists(
		requestParameters?: HttpGetAllUserDefinedListsRequestParams,
		observe: any = 'body',
		reportProgress: boolean = false,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<any> {
		const translations = requestParameters?.translations;
		const acceptLanguage = requestParameters?.acceptLanguage;

		let localVarQueryParameters = new OpenApiHttpParams(this.encoder);

		localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, 'translations', <any>translations, QueryParamStyle.Form, true);

		let localVarHeaders = this.defaultHeaders;
		if (acceptLanguage !== undefined && acceptLanguage !== null) {
			localVarHeaders = localVarHeaders.set('Accept-Language', String(acceptLanguage));
		}

		// authentication (function_key) required
		localVarHeaders = this.configuration.addCredentialToHeaders('function_key', 'x-functions-key', localVarHeaders);

		const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept(['application/json']);
		if (localVarHttpHeaderAcceptSelected !== undefined) {
			localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
		}

		const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();

		const localVarTransferCache: boolean = options?.transferCache ?? true;

		let responseType_: 'text' | 'json' | 'blob' = 'json';
		if (localVarHttpHeaderAcceptSelected) {
			if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
				responseType_ = 'text';
			} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
				responseType_ = 'json';
			} else {
				responseType_ = 'blob';
			}
		}

		let localVarPath = `/helper/userdefinedlists`;
		const { basePath, withCredentials } = this.configuration;
		return this.httpClient.request<Array<CollectionUDL>>('get', `${basePath}${localVarPath}`, {
			context: localVarHttpContext,
			params: localVarQueryParameters.toHttpParams(),
			responseType: <any>responseType_,
			...(withCredentials ? { withCredentials } : {}),
			headers: localVarHeaders,
			observe: observe,
			...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
			reportProgress: reportProgress
		});
	}

	/**
	 * Returns all filterable items directly from the search index
	 * @endpoint get /helper/filterableitems
	 * @param requestParameters
	 * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
	 * @param reportProgress flag to report request and response progress.
	 * @param options additional options
	 */
	public httpGetAllowedFilterableItems(
		requestParameters?: HttpGetAllowedFilterableItemsRequestParams,
		observe?: 'body',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<Array<string>>;
	public httpGetAllowedFilterableItems(
		requestParameters?: HttpGetAllowedFilterableItemsRequestParams,
		observe?: 'response',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpResponse<Array<string>>>;
	public httpGetAllowedFilterableItems(
		requestParameters?: HttpGetAllowedFilterableItemsRequestParams,
		observe?: 'events',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpEvent<Array<string>>>;
	public httpGetAllowedFilterableItems(
		requestParameters?: HttpGetAllowedFilterableItemsRequestParams,
		observe: any = 'body',
		reportProgress: boolean = false,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<any> {
		const portalId = requestParameters?.portalId;

		let localVarQueryParameters = new OpenApiHttpParams(this.encoder);

		localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, 'portal_id', <any>portalId, QueryParamStyle.Form, true);

		let localVarHeaders = this.defaultHeaders;

		// authentication (function_key) required
		localVarHeaders = this.configuration.addCredentialToHeaders('function_key', 'x-functions-key', localVarHeaders);

		const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept(['application/json']);
		if (localVarHttpHeaderAcceptSelected !== undefined) {
			localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
		}

		const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();

		const localVarTransferCache: boolean = options?.transferCache ?? true;

		let responseType_: 'text' | 'json' | 'blob' = 'json';
		if (localVarHttpHeaderAcceptSelected) {
			if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
				responseType_ = 'text';
			} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
				responseType_ = 'json';
			} else {
				responseType_ = 'blob';
			}
		}

		let localVarPath = `/helper/filterableitems`;
		const { basePath, withCredentials } = this.configuration;
		return this.httpClient.request<Array<string>>('get', `${basePath}${localVarPath}`, {
			context: localVarHttpContext,
			params: localVarQueryParameters.toHttpParams(),
			responseType: <any>responseType_,
			...(withCredentials ? { withCredentials } : {}),
			headers: localVarHeaders,
			observe: observe,
			...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
			reportProgress: reportProgress
		});
	}

	/**
	 * Returns all searchable items directly from the search index
	 * @endpoint get /helper/searchableitemnames
	 * @param requestParameters
	 * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
	 * @param reportProgress flag to report request and response progress.
	 * @param options additional options
	 */
	public httpGetAllowedSearchableItemNames(
		requestParameters?: HttpGetAllowedSearchableItemNamesRequestParams,
		observe?: 'body',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<Array<string>>;
	public httpGetAllowedSearchableItemNames(
		requestParameters?: HttpGetAllowedSearchableItemNamesRequestParams,
		observe?: 'response',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpResponse<Array<string>>>;
	public httpGetAllowedSearchableItemNames(
		requestParameters?: HttpGetAllowedSearchableItemNamesRequestParams,
		observe?: 'events',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpEvent<Array<string>>>;
	public httpGetAllowedSearchableItemNames(
		requestParameters?: HttpGetAllowedSearchableItemNamesRequestParams,
		observe: any = 'body',
		reportProgress: boolean = false,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<any> {
		const portalId = requestParameters?.portalId;

		let localVarQueryParameters = new OpenApiHttpParams(this.encoder);

		localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, 'portal_id', <any>portalId, QueryParamStyle.Form, true);

		let localVarHeaders = this.defaultHeaders;

		// authentication (function_key) required
		localVarHeaders = this.configuration.addCredentialToHeaders('function_key', 'x-functions-key', localVarHeaders);

		const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept(['application/json']);
		if (localVarHttpHeaderAcceptSelected !== undefined) {
			localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
		}

		const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();

		const localVarTransferCache: boolean = options?.transferCache ?? true;

		let responseType_: 'text' | 'json' | 'blob' = 'json';
		if (localVarHttpHeaderAcceptSelected) {
			if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
				responseType_ = 'text';
			} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
				responseType_ = 'json';
			} else {
				responseType_ = 'blob';
			}
		}

		let localVarPath = `/helper/searchableitemnames`;
		const { basePath, withCredentials } = this.configuration;
		return this.httpClient.request<Array<string>>('get', `${basePath}${localVarPath}`, {
			context: localVarHttpContext,
			params: localVarQueryParameters.toHttpParams(),
			responseType: <any>responseType_,
			...(withCredentials ? { withCredentials } : {}),
			headers: localVarHeaders,
			observe: observe,
			...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
			reportProgress: reportProgress
		});
	}

	/**
	 * Returns all searchable items directly from the search index
	 * @endpoint get /helper/searchableitems
	 * @param requestParameters
	 * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
	 * @param reportProgress flag to report request and response progress.
	 * @param options additional options
	 */
	public httpGetAllowedSearchableItems(
		requestParameters?: HttpGetAllowedSearchableItemsRequestParams,
		observe?: 'body',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<Array<SearchableItem>>;
	public httpGetAllowedSearchableItems(
		requestParameters?: HttpGetAllowedSearchableItemsRequestParams,
		observe?: 'response',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpResponse<Array<SearchableItem>>>;
	public httpGetAllowedSearchableItems(
		requestParameters?: HttpGetAllowedSearchableItemsRequestParams,
		observe?: 'events',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpEvent<Array<SearchableItem>>>;
	public httpGetAllowedSearchableItems(
		requestParameters?: HttpGetAllowedSearchableItemsRequestParams,
		observe: any = 'body',
		reportProgress: boolean = false,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<any> {
		const portalId = requestParameters?.portalId;

		let localVarQueryParameters = new OpenApiHttpParams(this.encoder);

		localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, 'portal_id', <any>portalId, QueryParamStyle.Form, true);

		let localVarHeaders = this.defaultHeaders;

		// authentication (function_key) required
		localVarHeaders = this.configuration.addCredentialToHeaders('function_key', 'x-functions-key', localVarHeaders);

		const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept(['application/json']);
		if (localVarHttpHeaderAcceptSelected !== undefined) {
			localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
		}

		const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();

		const localVarTransferCache: boolean = options?.transferCache ?? true;

		let responseType_: 'text' | 'json' | 'blob' = 'json';
		if (localVarHttpHeaderAcceptSelected) {
			if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
				responseType_ = 'text';
			} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
				responseType_ = 'json';
			} else {
				responseType_ = 'blob';
			}
		}

		let localVarPath = `/helper/searchableitems`;
		const { basePath, withCredentials } = this.configuration;
		return this.httpClient.request<Array<SearchableItem>>('get', `${basePath}${localVarPath}`, {
			context: localVarHttpContext,
			params: localVarQueryParameters.toHttpParams(),
			responseType: <any>responseType_,
			...(withCredentials ? { withCredentials } : {}),
			headers: localVarHeaders,
			observe: observe,
			...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
			reportProgress: reportProgress
		});
	}

	/**
	 * This updates the cached user defined lists and store it in the system.
	 * @endpoint patch /helper/userdefinedlists
	 * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
	 * @param reportProgress flag to report request and response progress.
	 * @param options additional options
	 */
	public httpPatchUpdateCachedUserDefinedLists(
		observe?: 'body',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<CollectionUDLListEntity>;
	public httpPatchUpdateCachedUserDefinedLists(
		observe?: 'response',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpResponse<CollectionUDLListEntity>>;
	public httpPatchUpdateCachedUserDefinedLists(
		observe?: 'events',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpEvent<CollectionUDLListEntity>>;
	public httpPatchUpdateCachedUserDefinedLists(
		observe: any = 'body',
		reportProgress: boolean = false,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<any> {
		let localVarHeaders = this.defaultHeaders;

		// authentication (function_key) required
		localVarHeaders = this.configuration.addCredentialToHeaders('function_key', 'x-functions-key', localVarHeaders);

		const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept(['application/json']);
		if (localVarHttpHeaderAcceptSelected !== undefined) {
			localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
		}

		const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();

		const localVarTransferCache: boolean = options?.transferCache ?? true;

		let responseType_: 'text' | 'json' | 'blob' = 'json';
		if (localVarHttpHeaderAcceptSelected) {
			if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
				responseType_ = 'text';
			} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
				responseType_ = 'json';
			} else {
				responseType_ = 'blob';
			}
		}

		let localVarPath = `/helper/userdefinedlists`;
		const { basePath, withCredentials } = this.configuration;
		return this.httpClient.request<CollectionUDLListEntity>('patch', `${basePath}${localVarPath}`, {
			context: localVarHttpContext,
			responseType: <any>responseType_,
			...(withCredentials ? { withCredentials } : {}),
			headers: localVarHeaders,
			observe: observe,
			...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
			reportProgress: reportProgress
		});
	}
}
