import { apiUrls } from '~/driven/utils/configs/appConfig';
import { HttpOptionsType } from '~/driven/boundaries/http-boundary/protocols';
import { HTTPPovider } from '~/driven/boundaries/http-boundary/httpBoundary';
import { IOtpAuthDrivenPort } from '~/business-logic/generic/admin-user/authentication/otp-auth/port';
import { OtpAuthResponse } from '~/business-logic/generic/admin-user/authentication/otp-auth/data/reponse-object/otpAuthRO';
import { OtpAuthDTOReturnType } from '~/business-logic/generic/admin-user/authentication/otp-auth/data/dto/otpAuthDto';

const authAdminLogin = (): IOtpAuthDrivenPort => {
  const httpProvider = new HTTPPovider();
  const httpHandler = (data: OtpAuthDTOReturnType): Promise<OtpAuthResponse> => {
    const url = apiUrls.generic.authLogin;
    const options: HttpOptionsType = {
      url,
      headers: {
        'Content-Type': 'application/json',
      },
      data,
    };
    return httpProvider.request<OtpAuthResponse>(options);
  };

  return {
    httpHandler,
  };
};

export default authAdminLogin;