/* 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 {
  ServiceOTPRequest,
  ServiceOTPVerify,
  ServiceOTPVerifyResponse,
} from '../models';

export interface ServiceAuthOtpRequestRequest {
    data: ServiceOTPRequest;
}

export interface ServiceAuthOtpVerifyRequest {
    data: ServiceOTPVerify;
}

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

    /**
     * Service-to-service: upsert user by phone and send OTP.
     */
    async serviceAuthOtpRequestRaw(requestParameters: ServiceAuthOtpRequestRequest, 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 serviceAuthOtpRequest.');
        }

        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/service/v1/auth/otp/request/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Service-to-service: upsert user by phone and send OTP.
     */
    async serviceAuthOtpRequest(requestParameters: ServiceAuthOtpRequestRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.serviceAuthOtpRequestRaw(requestParameters, initOverrides);
    }

    /**
     * Service-to-service: verify OTP and receive JWT access & refresh tokens.
     */
    async serviceAuthOtpVerifyRaw(requestParameters: ServiceAuthOtpVerifyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ServiceOTPVerifyResponse>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling serviceAuthOtpVerify.');
        }

        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/service/v1/auth/otp/verify/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Service-to-service: verify OTP and receive JWT access & refresh tokens.
     */
    async serviceAuthOtpVerify(requestParameters: ServiceAuthOtpVerifyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ServiceOTPVerifyResponse> {
        const response = await this.serviceAuthOtpVerifyRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
