/* tslint:disable */
/* eslint-disable */
/**
 * Ringer Business API
 * This API provides comprehensive endpoints for the Ringer Business system. It includes functionality for managing customer accounts, addresses, sites, phone numbers, payments, users, and other business resources.  Operations typically require authentication and appropriate permissions. 
 *
 * The version of the OpenAPI document: 1.0.6
 * Contact: support@ringer.tel
 *
 * 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';
import type {
  ForgotPasswordRequest,
  ForgotPasswordResponse,
  ResetPasswordRequest,
  ResetPasswordResponse,
} from '../models/index';
import {
    ForgotPasswordRequestFromJSON,
    ForgotPasswordRequestToJSON,
    ForgotPasswordResponseFromJSON,
    ForgotPasswordResponseToJSON,
    ResetPasswordRequestFromJSON,
    ResetPasswordRequestToJSON,
    ResetPasswordResponseFromJSON,
    ResetPasswordResponseToJSON,
} from '../models/index';

export interface RequestPasswordResetRequest {
    forgotPasswordRequest: ForgotPasswordRequest;
}

export interface ResetPasswordOperationRequest {
    resetPasswordRequest: ResetPasswordRequest;
}

/**
 * 
 */
export class PasswordManagementApi extends runtime.BaseAPI {

    /**
     * Allows a user to request a password reset by providing their registered email address. If the email address is associated with an existing account, the system will typically send an email to that address containing a password reset token and instructions. This endpoint itself usually just confirms that the process has been initiated if the email is found. 
     * Request Password Reset
     */
    async requestPasswordResetRaw(requestParameters: RequestPasswordResetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ForgotPasswordResponse>> {
        if (requestParameters['forgotPasswordRequest'] == null) {
            throw new runtime.RequiredError(
                'forgotPasswordRequest',
                'Required parameter "forgotPasswordRequest" was null or undefined when calling requestPasswordReset().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        const response = await this.request({
            path: `/password`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: ForgotPasswordRequestToJSON(requestParameters['forgotPasswordRequest']),
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => ForgotPasswordResponseFromJSON(jsonValue));
    }

    /**
     * Allows a user to request a password reset by providing their registered email address. If the email address is associated with an existing account, the system will typically send an email to that address containing a password reset token and instructions. This endpoint itself usually just confirms that the process has been initiated if the email is found. 
     * Request Password Reset
     */
    async requestPasswordReset(requestParameters: RequestPasswordResetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ForgotPasswordResponse> {
        const response = await this.requestPasswordResetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Allows a user to set a new password for their account using a valid password reset token. The token is typically obtained from a link sent to their email after initiating a password reset request. 
     * Reset Password
     */
    async resetPasswordRaw(requestParameters: ResetPasswordOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ResetPasswordResponse>> {
        if (requestParameters['resetPasswordRequest'] == null) {
            throw new runtime.RequiredError(
                'resetPasswordRequest',
                'Required parameter "resetPasswordRequest" was null or undefined when calling resetPassword().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        const response = await this.request({
            path: `/password`,
            method: 'PUT',
            headers: headerParameters,
            query: queryParameters,
            body: ResetPasswordRequestToJSON(requestParameters['resetPasswordRequest']),
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => ResetPasswordResponseFromJSON(jsonValue));
    }

    /**
     * Allows a user to set a new password for their account using a valid password reset token. The token is typically obtained from a link sent to their email after initiating a password reset request. 
     * Reset Password
     */
    async resetPassword(requestParameters: ResetPasswordOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ResetPasswordResponse> {
        const response = await this.resetPasswordRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
