import Ajax from './base';

const Auth = {
  sendOtp: (data?: {payload?: object; headers?: object}) => {
    const {payload, headers} = data || {};
    const route = '/otp/send';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: false,
      isEncrypted: true,
      payload,
      headers,
    });
  },
  verifyOtp: (data?: {payload?: object; headers?: object}) => {
    const {payload, headers} = data || {};
    const route = '/otp/verify';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: false,
      isEncrypted: true,
      payload,
      headers,
    });
  },
  getOnboardingData: (payload?: object) => {
    const route = '/patient/onbording_signup_data';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: false,
      payload,
    });
  },
  loginSendOtp: (payload: object) => {
    const route = '/patient/login_send_otp';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: false,
      payload,
    });
  },
  sendSignUpOtp: (payload: object) => {
    const route = '/patient/send_otp_signup';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: false,
      payload,
    });
  },
  verifyOTPSignUp: (payload: object) => {
    const route = '/patient/verify_otp_signup';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: false,
      payload,
    });
  },
  verifyOTPLogin: (payload: object) => {
    const route = '/patient/login_verify_otp';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: false,
      payload,
    });
  },
  updateSignupStep: (payload: object) => {
    const route = '/patient/update_signup_for';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: true,
      payload,
    });
  },
  tempPatientSignUp: (payload: object) => {
    const route = '/patient/register_temp_patient_profile';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: true,
      payload,
    });
  },
  authenticateUser: (requestObj: {payload: object, environment: string}) => {
    const payload = requestObj?.payload;
    const environment = requestObj?.environment;
    const route = '/patient/login_or_register_patient';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: false,
      payload,
      environment: environment,
    });
  },

  medicalConditionGroupList: (payload: object) => {
    const route = '/patient/medical_condition_group_list';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: false,
      payload,
    });
  },

  registerPatient: (data: {payload?: object; headers?: object}) => {
    const {payload, headers} = data || {};
    const route = '/patient/register';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: false,
      payload,
      headers,
    });
  },

  verifyDoctorCode: (payload: object) => {
    const route = '/patient/verify_doctor_access_code';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: true,
      payload,
    });
  },

  updateDeviceInfo: (payload: object) => {
    const route = '/patient/update_device_info';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: true,
      payload,
    });
  },

  getPatientDetails: (payload: object) => {
    const route = '/patient/get_patient_details';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: true,
      payload,
    });
  },
  getUserStatusApi: (payload: object) => {
    const route = '/Patient/get_patient_source';
    return Ajax.request(route, {
      method: Ajax.POST,
      priv: true,
      payload,
    });
  },
  getUserMetaInfo: (payload: any) => {
    const route = `/patient/get_patient_meta_info?get_bca_readings=${payload?.get_bca_readings}`;
    return Ajax.request(route, {
      method: Ajax.GET,
      priv: true,
    });
  },
};
export default Auth;
