import {
  AccountInfo,
  GoogleCallbackResponse,
  GoogleLoginResponse,
  RequestOtpResponse,
} from "../services/auth/types";
import { Area } from "../services/product/type";
import { BaseApi } from "./baseApi";

class AuthApi extends BaseApi {
  constructor() {
    super("/auth");
  }

  async requestOtp({ email }) {
    return this.authPost<RequestOtpResponse>("/request-otp", { email });
  }

  async verifyOtp({ email, otp }) {
    return this.authPost<AccountInfo>("/verify-otp", { email, otpCode: otp });
  }

  async resendOtp({ email }) {
    return this.authPost<RequestOtpResponse>("/resend-otp", { email });
  }

  async googleLogin() {
    return this.authPost<GoogleLoginResponse>("/google-login", {});
  }

  async googleCallback({ code }) {
    return this.authPost<AccountInfo>("/google-callback", {
      code,
    });
  }

  async partnerLogin({ partner, data }) {
    return this.authPost<AccountInfo>("/partner-login", {
      partner,
      data,
    });
  }
}

export const authApi = new AuthApi();
