/* tslint:disable */
/* eslint-disable */
/**
 * Vitron API
 * API documentation for Vitron backend
 *
 * The version of the OpenAPI document: v1
 * Contact: support@yourcompany.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';
import type {
  Address,
  ApiUserV1LogoutCreateRequest,
  Login,
  LoginOTPSend,
  OTP,
  OTPVerification,
  OTPVerifyResponse,
  ResetPassword,
  ResetPasswordOTPSend,
  UserProfile,
  UserProfileUpdate,
} from '../models';

export interface ApiUserV1AddressCreateCreateRequest {
    data: Address;
}

export interface ApiUserV1AddressDeleteDeleteRequest {
    id: string;
}

export interface ApiUserV1AddressReadRequest {
    id: string;
}

export interface ApiUserV1AddressSetDefaultPartialUpdateRequest {
    id: string;
    data: Address;
}

export interface ApiUserV1AddressUpdatePartialUpdateRequest {
    id: string;
    data: Address;
}

export interface ApiUserV1LoginCreateRequest {
    data: Login;
}

export interface ApiUserV1LoginSendOtpCreateRequest {
    data: LoginOTPSend;
}

export interface ApiUserV1LogoutCreateOperationRequest {
    data: ApiUserV1LogoutCreateRequest;
}

export interface ApiUserV1ProfilePartialUpdateRequest {
    data: UserProfileUpdate;
}

export interface ApiUserV1RegisterCreateRequest {
    data: OTP;
}

export interface ApiUserV1ResetPasswordCreateRequest {
    data: ResetPassword;
}

export interface ApiUserV1ResetPasswordSendOtpCreateRequest {
    data: ResetPasswordOTPSend;
}

export interface ApiUserV1VerifyOtpCreateRequest {
    data: OTPVerification;
}

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

    /**
     * Create a new address for the authenticated user.
     */
    async apiUserV1AddressCreateCreateRaw(requestParameters: ApiUserV1AddressCreateCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Address>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiUserV1AddressCreateCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/address/create/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Create a new address for the authenticated user.
     */
    async apiUserV1AddressCreateCreate(requestParameters: ApiUserV1AddressCreateCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Address> {
        const response = await this.apiUserV1AddressCreateCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Delete an address.
     */
    async apiUserV1AddressDeleteDeleteRaw(requestParameters: ApiUserV1AddressDeleteDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling apiUserV1AddressDeleteDelete.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/address/{id}/delete/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Delete an address.
     */
    async apiUserV1AddressDeleteDelete(requestParameters: ApiUserV1AddressDeleteDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiUserV1AddressDeleteDeleteRaw(requestParameters, initOverrides);
    }

    /**
     * Retrieve all addresses of the authenticated user.
     */
    async apiUserV1AddressListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<Address>>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/address/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Retrieve all addresses of the authenticated user.
     */
    async apiUserV1AddressList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<Address>> {
        const response = await this.apiUserV1AddressListRaw(initOverrides);
        return await response.value();
    }

    /**
     * Retrieve details of a specific address.
     */
    async apiUserV1AddressReadRaw(requestParameters: ApiUserV1AddressReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Address>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling apiUserV1AddressRead.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/address/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Retrieve details of a specific address.
     */
    async apiUserV1AddressRead(requestParameters: ApiUserV1AddressReadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Address> {
        const response = await this.apiUserV1AddressReadRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Set an address as the default address (PATCH only).
     */
    async apiUserV1AddressSetDefaultPartialUpdateRaw(requestParameters: ApiUserV1AddressSetDefaultPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Address>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling apiUserV1AddressSetDefaultPartialUpdate.');
        }

        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiUserV1AddressSetDefaultPartialUpdate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/address/{id}/set_default/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Set an address as the default address (PATCH only).
     */
    async apiUserV1AddressSetDefaultPartialUpdate(requestParameters: ApiUserV1AddressSetDefaultPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Address> {
        const response = await this.apiUserV1AddressSetDefaultPartialUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Update an existing address (PATCH only).
     */
    async apiUserV1AddressUpdatePartialUpdateRaw(requestParameters: ApiUserV1AddressUpdatePartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Address>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling apiUserV1AddressUpdatePartialUpdate.');
        }

        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiUserV1AddressUpdatePartialUpdate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/address/{id}/update/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Update an existing address (PATCH only).
     */
    async apiUserV1AddressUpdatePartialUpdate(requestParameters: ApiUserV1AddressUpdatePartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Address> {
        const response = await this.apiUserV1AddressUpdatePartialUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Login with either password or OTP.
     */
    async apiUserV1LoginCreateRaw(requestParameters: ApiUserV1LoginCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Login>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiUserV1LoginCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/login/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Login with either password or OTP.
     */
    async apiUserV1LoginCreate(requestParameters: ApiUserV1LoginCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Login> {
        const response = await this.apiUserV1LoginCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Send OTP for login.
     */
    async apiUserV1LoginSendOtpCreateRaw(requestParameters: ApiUserV1LoginSendOtpCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LoginOTPSend>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiUserV1LoginSendOtpCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/login/send-otp/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Send OTP for login.
     */
    async apiUserV1LoginSendOtpCreate(requestParameters: ApiUserV1LoginSendOtpCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LoginOTPSend> {
        const response = await this.apiUserV1LoginSendOtpCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Logout and invalidate the refresh token.
     */
    async apiUserV1LogoutCreateRaw(requestParameters: ApiUserV1LogoutCreateOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiUserV1LogoutCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/logout/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Logout and invalidate the refresh token.
     */
    async apiUserV1LogoutCreate(requestParameters: ApiUserV1LogoutCreateOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiUserV1LogoutCreateRaw(requestParameters, initOverrides);
    }

    /**
     * Retrieve user profile details.
     */
    async apiUserV1ProfileListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserProfile>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/profile/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Retrieve user profile details.
     */
    async apiUserV1ProfileList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserProfile> {
        const response = await this.apiUserV1ProfileListRaw(initOverrides);
        return await response.value();
    }

    /**
     * Update user profile (first name, last name, password).
     */
    async apiUserV1ProfilePartialUpdateRaw(requestParameters: ApiUserV1ProfilePartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserProfileUpdate>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiUserV1ProfilePartialUpdate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/profile/`,
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Update user profile (first name, last name, password).
     */
    async apiUserV1ProfilePartialUpdate(requestParameters: ApiUserV1ProfilePartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserProfileUpdate> {
        const response = await this.apiUserV1ProfilePartialUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Send OTP for phone verification (login or registration).
     */
    async apiUserV1RegisterCreateRaw(requestParameters: ApiUserV1RegisterCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiUserV1RegisterCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/register/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Send OTP for phone verification (login or registration).
     */
    async apiUserV1RegisterCreate(requestParameters: ApiUserV1RegisterCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiUserV1RegisterCreateRaw(requestParameters, initOverrides);
    }

    /**
     * Reset user password using OTP.
     */
    async apiUserV1ResetPasswordCreateRaw(requestParameters: ApiUserV1ResetPasswordCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ResetPassword>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiUserV1ResetPasswordCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/reset-password/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Reset user password using OTP.
     */
    async apiUserV1ResetPasswordCreate(requestParameters: ApiUserV1ResetPasswordCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ResetPassword> {
        const response = await this.apiUserV1ResetPasswordCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Send OTP to reset password.
     */
    async apiUserV1ResetPasswordSendOtpCreateRaw(requestParameters: ApiUserV1ResetPasswordSendOtpCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ResetPasswordOTPSend>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiUserV1ResetPasswordSendOtpCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/reset-password/send-otp/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Send OTP to reset password.
     */
    async apiUserV1ResetPasswordSendOtpCreate(requestParameters: ApiUserV1ResetPasswordSendOtpCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ResetPasswordOTPSend> {
        const response = await this.apiUserV1ResetPasswordSendOtpCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Verify OTP and receive JWT access & refresh token.
     */
    async apiUserV1VerifyOtpCreateRaw(requestParameters: ApiUserV1VerifyOtpCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OTPVerifyResponse>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiUserV1VerifyOtpCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/user/v1/verify-otp/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Verify OTP and receive JWT access & refresh token.
     */
    async apiUserV1VerifyOtpCreate(requestParameters: ApiUserV1VerifyOtpCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OTPVerifyResponse> {
        const response = await this.apiUserV1VerifyOtpCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
