/**
 * 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 { AgravityInfoResponse } from '../model/agravityInfoResponse.pub.agravity';
// @ts-ignore
import { AgravityVersion } from '../model/agravityVersion.pub.agravity';
// @ts-ignore
import { DeletedEntities } from '../model/deletedEntities.pub.agravity';

// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { AgravityPublicConfiguration } from '../configuration';
import { BaseService } from '../api.base.service';

export interface HttpGetDeletedEntitiesRequestParams {
	/** The type of the entity (e.g. \&#39;asset\&#39;, \&#39;collection_type\&#39;, \&#39;collection_type\&#39; */
	entityType?: string;
	/** The date in the past since the entities are marked as deleted in the database. */
	since?: string;
	/** The date in the past until the entities are marked as deleted in the database. */
	until?: string;
	/** If the request comes from portal this is the indicator. */
	portalId?: string;
}

export interface HttpTriggerDurableContinueRequestParams {
	/** The instance ID of the durable function. */
	instanceId: string;
}

export interface HttpTriggerDurableScchTrainingDoneRequestParams {
	/** The instance ID of the durable function. */
	instanceId: string;
}

@Injectable({
	providedIn: 'root'
})
export class PublicGeneralManagementService extends BaseService {
	constructor(
		protected httpClient: HttpClient,
		@Optional() @Inject(BASE_PATH) basePath: string | string[],
		@Optional() configuration?: AgravityPublicConfiguration
	) {
		super(basePath, configuration);
	}

	/**
	 * Get the current version of the backend. To see if backend was updated or not.
	 * @endpoint get /version
	 * @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 httpAgravityVersionInfo(
		observe?: 'body',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<AgravityVersion>;
	public httpAgravityVersionInfo(
		observe?: 'response',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpResponse<AgravityVersion>>;
	public httpAgravityVersionInfo(
		observe?: 'events',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpEvent<AgravityVersion>>;
	public httpAgravityVersionInfo(
		observe: any = 'body',
		reportProgress: boolean = false,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<any> {
		let localVarHeaders = this.defaultHeaders;

		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 = `/version`;
		const { basePath, withCredentials } = this.configuration;
		return this.httpClient.request<AgravityVersion>('get', `${basePath}${localVarPath}`, {
			context: localVarHttpContext,
			responseType: <any>responseType_,
			...(withCredentials ? { withCredentials } : {}),
			headers: localVarHeaders,
			observe: observe,
			...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
			reportProgress: reportProgress
		});
	}

	/**
	 * This endpoint checks all deleted entities in the database until a specific date and returns the elements which are deleted.
	 * @endpoint get /deleted
	 * @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 httpGetDeletedEntities(
		requestParameters?: HttpGetDeletedEntitiesRequestParams,
		observe?: 'body',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<Array<DeletedEntities>>;
	public httpGetDeletedEntities(
		requestParameters?: HttpGetDeletedEntitiesRequestParams,
		observe?: 'response',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpResponse<Array<DeletedEntities>>>;
	public httpGetDeletedEntities(
		requestParameters?: HttpGetDeletedEntitiesRequestParams,
		observe?: 'events',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpEvent<Array<DeletedEntities>>>;
	public httpGetDeletedEntities(
		requestParameters?: HttpGetDeletedEntitiesRequestParams,
		observe: any = 'body',
		reportProgress: boolean = false,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<any> {
		const entityType = requestParameters?.entityType;
		const since = requestParameters?.since;
		const until = requestParameters?.until;
		const portalId = requestParameters?.portalId;

		let localVarQueryParameters = new OpenApiHttpParams(this.encoder);

		localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, 'entity_type', <any>entityType, QueryParamStyle.Form, true);

		localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, 'since', <any>since, QueryParamStyle.Form, true);

		localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, 'until', <any>until, QueryParamStyle.Form, true);

		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 = `/deleted`;
		const { basePath, withCredentials } = this.configuration;
		return this.httpClient.request<Array<DeletedEntities>>('get', `${basePath}${localVarPath}`, {
			context: localVarHttpContext,
			params: localVarQueryParameters.toHttpParams(),
			responseType: <any>responseType_,
			...(withCredentials ? { withCredentials } : {}),
			headers: localVarHeaders,
			observe: observe,
			...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
			reportProgress: reportProgress
		});
	}

	/**
	 * Trigger the durable execution to continue
	 * @endpoint get /durable/{instanceId}
	 * @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 httpTriggerDurableContinue(
		requestParameters: HttpTriggerDurableContinueRequestParams,
		observe?: 'body',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<AgravityInfoResponse>;
	public httpTriggerDurableContinue(
		requestParameters: HttpTriggerDurableContinueRequestParams,
		observe?: 'response',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpResponse<AgravityInfoResponse>>;
	public httpTriggerDurableContinue(
		requestParameters: HttpTriggerDurableContinueRequestParams,
		observe?: 'events',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpEvent<AgravityInfoResponse>>;
	public httpTriggerDurableContinue(
		requestParameters: HttpTriggerDurableContinueRequestParams,
		observe: any = 'body',
		reportProgress: boolean = false,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<any> {
		const instanceId = requestParameters?.instanceId;
		if (instanceId === null || instanceId === undefined) {
			throw new Error('Required parameter instanceId was null or undefined when calling httpTriggerDurableContinue.');
		}

		let localVarHeaders = this.defaultHeaders;

		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 = `/durable/${this.configuration.encodeParam({ name: 'instanceId', value: instanceId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: undefined })}`;
		const { basePath, withCredentials } = this.configuration;
		return this.httpClient.request<AgravityInfoResponse>('get', `${basePath}${localVarPath}`, {
			context: localVarHttpContext,
			responseType: <any>responseType_,
			...(withCredentials ? { withCredentials } : {}),
			headers: localVarHeaders,
			observe: observe,
			...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
			reportProgress: reportProgress
		});
	}

	/**
	 * Trigger the durable execution to continue
	 * @endpoint get /durable/scch/{instanceId}
	 * @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 httpTriggerDurableScchTrainingDone(
		requestParameters: HttpTriggerDurableScchTrainingDoneRequestParams,
		observe?: 'body',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<AgravityInfoResponse>;
	public httpTriggerDurableScchTrainingDone(
		requestParameters: HttpTriggerDurableScchTrainingDoneRequestParams,
		observe?: 'response',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpResponse<AgravityInfoResponse>>;
	public httpTriggerDurableScchTrainingDone(
		requestParameters: HttpTriggerDurableScchTrainingDoneRequestParams,
		observe?: 'events',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<HttpEvent<AgravityInfoResponse>>;
	public httpTriggerDurableScchTrainingDone(
		requestParameters: HttpTriggerDurableScchTrainingDoneRequestParams,
		observe: any = 'body',
		reportProgress: boolean = false,
		options?: { httpHeaderAccept?: 'application/json'; context?: HttpContext; transferCache?: boolean }
	): Observable<any> {
		const instanceId = requestParameters?.instanceId;
		if (instanceId === null || instanceId === undefined) {
			throw new Error('Required parameter instanceId was null or undefined when calling httpTriggerDurableScchTrainingDone.');
		}

		let localVarHeaders = this.defaultHeaders;

		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 = `/durable/scch/${this.configuration.encodeParam({ name: 'instanceId', value: instanceId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: undefined })}`;
		const { basePath, withCredentials } = this.configuration;
		return this.httpClient.request<AgravityInfoResponse>('get', `${basePath}${localVarPath}`, {
			context: localVarHttpContext,
			responseType: <any>responseType_,
			...(withCredentials ? { withCredentials } : {}),
			headers: localVarHeaders,
			observe: observe,
			...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
			reportProgress: reportProgress
		});
	}
}
