/* tslint:disable */
/* eslint-disable */
/**
 * Hexiosec Transfer API
 * API description for Hexiosec Transfer  ## Testing Requests  Endpoints that require authentication will use your session cookie from the main application if an API key is not provided. This is fine for testing GET requests, however POST/DELETE requests will require a CSRF token when using a session cookie. It is not possible to provide a CSRF token from this page, and so an API key must be used.
 *
 * The version of the OpenAPI document: 0.0.1
 * Contact: support@hexiosec.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */
import * as runtime from '../runtime.js';
import { AuthEmailCodeRequestToJSON, AuthEmailVerifyRequestToJSON, AuthFinishOIDCRequestToJSON, AuthResponseFromJSON, AuthSignOutResponseFromJSON, AuthStartOIDCResponseFromJSON, } from '../models/index.js';
/**
 *
 */
export class AuthApi extends runtime.BaseAPI {
    /**
     * Clear a verified email session
     */
    async clearVerifiedEmailRaw(initOverrides) {
        const queryParameters = {};
        const headerParameters = {};
        const response = await this.request({
            path: `/auth/verify_email`,
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.VoidApiResponse(response);
    }
    /**
     * Clear a verified email session
     */
    async clearVerifiedEmail(initOverrides) {
        await this.clearVerifiedEmailRaw(initOverrides);
    }
    /**
     * Finishes OIDC flow
     */
    async finishOIDCRaw(requestParameters, initOverrides) {
        if (requestParameters['authFinishOIDCRequest'] == null) {
            throw new runtime.RequiredError('authFinishOIDCRequest', 'Required parameter "authFinishOIDCRequest" was null or undefined when calling finishOIDC().');
        }
        const queryParameters = {};
        const headerParameters = {};
        headerParameters['Content-Type'] = 'application/json';
        const response = await this.request({
            path: `/auth/oidc`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: AuthFinishOIDCRequestToJSON(requestParameters['authFinishOIDCRequest']),
        }, initOverrides);
        return new runtime.VoidApiResponse(response);
    }
    /**
     * Finishes OIDC flow
     */
    async finishOIDC(requestParameters, initOverrides) {
        await this.finishOIDCRaw(requestParameters, initOverrides);
    }
    /**
     * Get the auth state and associated user for the request
     */
    async getAuthStateRaw(initOverrides) {
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/auth`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => AuthResponseFromJSON(jsonValue));
    }
    /**
     * Get the auth state and associated user for the request
     */
    async getAuthState(initOverrides) {
        const response = await this.getAuthStateRaw(initOverrides);
        return await response.value();
    }
    /**
     * Send a verification code to a chosen email address.
     */
    async getEmailCodeRaw(requestParameters, initOverrides) {
        if (requestParameters['authEmailCodeRequest'] == null) {
            throw new runtime.RequiredError('authEmailCodeRequest', 'Required parameter "authEmailCodeRequest" was null or undefined when calling getEmailCode().');
        }
        const queryParameters = {};
        const headerParameters = {};
        headerParameters['Content-Type'] = 'application/json';
        const response = await this.request({
            path: `/auth/email_code`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: AuthEmailCodeRequestToJSON(requestParameters['authEmailCodeRequest']),
        }, initOverrides);
        return new runtime.VoidApiResponse(response);
    }
    /**
     * Send a verification code to a chosen email address.
     */
    async getEmailCode(requestParameters, initOverrides) {
        await this.getEmailCodeRaw(requestParameters, initOverrides);
    }
    /**
     * Sign out of current session
     */
    async signOutRaw(initOverrides) {
        const queryParameters = {};
        const headerParameters = {};
        const response = await this.request({
            path: `/auth`,
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => AuthSignOutResponseFromJSON(jsonValue));
    }
    /**
     * Sign out of current session
     */
    async signOut(initOverrides) {
        const response = await this.signOutRaw(initOverrides);
        return await response.value();
    }
    /**
     * Starts OIDC flow
     */
    async startOIDCRaw(initOverrides) {
        const queryParameters = {};
        const headerParameters = {};
        const response = await this.request({
            path: `/auth/oidc`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => AuthStartOIDCResponseFromJSON(jsonValue));
    }
    /**
     * Starts OIDC flow
     */
    async startOIDC(initOverrides) {
        const response = await this.startOIDCRaw(initOverrides);
        return await response.value();
    }
    /**
     * Verify an email address for the current session.
     */
    async verifyEmailCodeRaw(requestParameters, initOverrides) {
        if (requestParameters['authEmailVerifyRequest'] == null) {
            throw new runtime.RequiredError('authEmailVerifyRequest', 'Required parameter "authEmailVerifyRequest" was null or undefined when calling verifyEmailCode().');
        }
        const queryParameters = {};
        const headerParameters = {};
        headerParameters['Content-Type'] = 'application/json';
        const response = await this.request({
            path: `/auth/verify_email`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: AuthEmailVerifyRequestToJSON(requestParameters['authEmailVerifyRequest']),
        }, initOverrides);
        return new runtime.VoidApiResponse(response);
    }
    /**
     * Verify an email address for the current session.
     */
    async verifyEmailCode(requestParameters, initOverrides) {
        await this.verifyEmailCodeRaw(requestParameters, initOverrides);
    }
}
