/**
 * KADiCon API
 *
 *
 *
 * 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,
	HttpParameterCodec,
	HttpContext,
} from '@angular/common/http'
import { CustomHttpParameterCodec } from '../encoder'
import { Observable } from 'rxjs'

// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables'
import { Configuration } from '../configuration'
import { BaseService } from '../api.base.service'

@Injectable({
	providedIn: 'root',
})
export class WebhookService extends BaseService {
	constructor(
		protected httpClient: HttpClient,
		@Optional() @Inject(BASE_PATH) basePath: string | string[],
		@Optional() configuration?: Configuration,
	) {
		super(basePath, configuration)
	}

	/**
	 *
	 * Handles Stripe webhook events
	 * @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.
	 */
	public webhookControllerHandleStripeWebhook(
		observe?: 'body',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: undefined; context?: HttpContext; transferCache?: boolean },
	): Observable<any>
	public webhookControllerHandleStripeWebhook(
		observe?: 'response',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: undefined; context?: HttpContext; transferCache?: boolean },
	): Observable<HttpResponse<any>>
	public webhookControllerHandleStripeWebhook(
		observe?: 'events',
		reportProgress?: boolean,
		options?: { httpHeaderAccept?: undefined; context?: HttpContext; transferCache?: boolean },
	): Observable<HttpEvent<any>>
	public webhookControllerHandleStripeWebhook(
		observe: any = 'body',
		reportProgress: boolean = false,
		options?: { httpHeaderAccept?: undefined; context?: HttpContext; transferCache?: boolean },
	): Observable<any> {
		let localVarHeaders = this.defaultHeaders

		const localVarHttpHeaderAcceptSelected: string | undefined =
			options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([])
		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 = `/api/billing/stripe/webhook`
		const { basePath, withCredentials } = this.configuration
		return this.httpClient.request<any>('post', `${basePath}${localVarPath}`, {
			context: localVarHttpContext,
			responseType: <any>responseType_,
			...(withCredentials ? { withCredentials } : {}),
			headers: localVarHeaders,
			observe: observe,
			transferCache: localVarTransferCache,
			reportProgress: reportProgress,
		})
	}
}
