package com.b2lmobitech.fieldcloudhrms

import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST
import retrofit2.http.Field
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.Part
import retrofit2.http.Query

interface ApiService {

    @FormUrlEncoded
    @POST("login.php")
    fun login(
        @Field("email") email: String,
        @Field("password") password: String
    ): Call<LoginResponse>

    @POST("attendance.php")
    fun submitAttendance(@Body request: AttendanceRequest): Call<AttendanceResponse>

    @FormUrlEncoded
    @POST("check_today_attendance.php")
    fun checkTodayAttendance(
        @Field("user_id") userId: String,
        @Field("organization_id") organizationId: String
    ): Call<TodayAttendanceResponse>

    @FormUrlEncoded
    @POST("get_week_attendance.php")
    fun getWeekAttendance(
        @Field("user_id") userId: String,
        @Field("organization_id") orgId: String,
        @Field("week_start") weekStart: String,
        @Field("week_end") weekEnd: String
    ): Call<WeekAttendanceResponse>

    @Multipart
    @POST("upload_timesheet_attachment.php")
    fun uploadAttachment(
        @Part file: MultipartBody.Part
    ): Call<ServerResponse>

//    @POST("add_timesheet.php")
//    fun submitTimesheet(
//        @Query("userId") userId: String,
//        @Query("orgId") orgId: String,
//        @Query("activityName") activityName: String,
//        @Query("startTime") startTime: String,
//        @Query("endTime") endTime: String,
//        @Query("description") description: String,
//        @Query("attachmentUrl") attachmentUrl: String?
//    ): Call<ServerResponse>

    @GET("get_timesheets.php")
    fun getTimesheets(
        @Query("userId") userId: String,
        @Query("orgId") orgId: String,
        @Query("month") month: Int,
        @Query("year") year: Int
    ): Call<List<TimesheetModel>>

//    @Multipart
//    @POST("upload_multiple_attachments.php")
//    fun uploadMultipleAttachments(
//        @Query("orgId") orgId: String,
//        @Part files: List<MultipartBody.Part>
//    ): Call<FileResponse>

    @FormUrlEncoded
    @POST("add_timesheet.php")
    fun addTimesheet(
        @Field("userId") userId: String,
        @Field("orgId") orgId: String,
        @Field("activityName") activity: String,
        @Field("startTime") start: String,
        @Field("endTime") end: String,
        @Field("description") desc: String
    ): Call<TimesheetResponse>

    @Multipart
    @POST("upload_multiple_attachments.php")
    fun uploadMultipleAttachments(
        @Part("orgId") orgId: RequestBody,
        @Part("userId") userId: RequestBody,
        @Part("timesheet_id") timesheetId: RequestBody,
        @Part attachments: List<MultipartBody.Part>
    ): Call<FileResponse>


    @Multipart
    @POST("upload_check_in_details.php")
    fun uploadCheckInDetails(
        @Query("orgId") orgId: String,
        @Part image: MultipartBody.Part,
        @Part signature: MultipartBody.Part
    ): Call<BasicUploadResponse>

    @GET("get_timesheet_details.php")
    fun getTimesheetDetails(
        @Query("timesheet_id") timesheetId: String
    ): Call<TimesheetDetailsResponse>

    @GET("get_attendance_config_details.php")
    fun getAttendanceConfig(
        @Query("user_id") userId: String,
        @Query("org_id") orgId: String
    ): Call<UserAttendanceConfigResponse>

    @GET("get_leaves.php")
    fun getLeaves(
        @Query("user_id") userId: String,
        @Query("org_id") orgId: String,
        @Query("month") month: Int,
        @Query("year") year: Int
    ): Call<List<LeaveModel>>

    @FormUrlEncoded
    @POST("apply_leave.php")
    fun applyLeave(
        @Field("people_id") people_id: String,
        @Field("org_id") org_id: String,
        @Field("leavetype") leave_type: String,
        @Field("from") from: String,
        @Field("to") to: String,
        @Field("reason") reason: String,
        @Field("permissiondate") permissiondate: String,
        @Field("permissioninminutes") permissionMinutes: String? = "",
        @Field("leavedays") leaveDays: String? = "",
        @Field("halfday") halfday: String? = "",
        @Field("halfdaytype") halfdaytype: String? = ""
    ): Call<SimpleResponse>

    @GET("get_today_shift.php")
    fun getTodayShift(
        @Query("user_id") userId: String,
        @Query("org_id") orgId: String
    ): Call<TodayShiftResponse>

    @GET("get_people_full_profile.php")
    fun getProfile(
        @Query("people_id") peopleId: String,
        @Query("org_id") orgId: String
    ): Call<ProfileResponse>

    @Multipart
    @POST("update_profile.php")
    fun updateProfile(
        @Part("people_id") peopleId: RequestBody,
        @Part("org_id") orgId: RequestBody,
        @Part("address") address: RequestBody,
        @Part("mobile") mobile: RequestBody,
        @Part("dob") dob: RequestBody,
        @Part("marital") marital: RequestBody,
        @Part("blood") blood: RequestBody,
        @Part("city") city: RequestBody,
        @Part("state") state: RequestBody,
        @Part("country") country: RequestBody,
        @Part("aadhar_no") aadhar: RequestBody,
        @Part("pan_no") pan: RequestBody,
        @Part profile_image: MultipartBody.Part?,
        @Part aadhar_image: MultipartBody.Part?
    ): Call<SimpleResponse>


    @GET("get_travel_list.php")
    fun getTravelList(
        @Query("user_id") userId: String,
        @Query("org_id") orgId: String
    ): Call<TravelResponse>

    @FormUrlEncoded
    @POST("add_travel_request.php")
    fun addTravelRequest(
        @Field("employee_id") employeeId: String,
        @Field("org_id") orgId: String,
        @Field("place_of_visit") placeOfVisit: String,
        @Field("departure_date") departureDate: String,
        @Field("arrival_date") arrivalDate: String,
        @Field("purpose") purpose: String,
        @Field("duration") duration: String,
        @Field("expense") expense: String,
        @Field("billable") isBillable: String,
        @Field("customer_name") customerName: String
    ): Call<ApiResponse>

    @GET("get_countries.php")
    fun getCountries(): Call<ListResponse<Country>>

    @GET("get_states.php")
    fun getStates(@Query("country_id") countryId: String): Call<ListResponse<State>>

    @GET("get_cities.php")
    fun getCities(@Query("state_id") stateId: String): Call<ListResponse<City>>

    //  Employee Profile
    @GET("get_employee_profile.php")
    fun getEmployeeProfile(
        @Query("people_id") peopleId: String,
        @Query("org_id") orgId: String
    ): Call<EmployeeModel>

    //  Month-wise Payslip
    @GET("get_payslip.php")
    fun getPayslip(
        @Query("people_id") peopleId: String,
        @Query("org_id") orgId: String,
        @Query("month") month: Int,
        @Query("year") year: Int
    ): Call<PayslipModel>

    @FormUrlEncoded
    @POST("get_leave_types_for_user.php")
    fun getLeaveTypes(
        @Field("people_id") peopleId: String,
        @Field("org_id") orgId: String
    ): Call<LeaveTypeResponse>

    @FormUrlEncoded
    @POST("check_leave_quota.php")
    fun checkLeaveQuota(
        @Field("people_id") peopleId: String,
        @Field("org_id") orgId: String,
        @Field("leave_type_id") leaveTypeId: String,
        @Field("yearly_quota") yearlyQuota: String
    ): Call<LeaveQuotaResponse>

    @GET("get_leave_balance.php")
    fun getLeaveBalance(
        @Query("people_id") peopleId: String
    ): Call<LeaveBalanceResponse>

    @GET("get_profile_photo.php")
    fun getProfilePhoto(
        @Query("user_id") userId: String,
        @Query("org_id") orgId: String
    ): Call<ProfilePhotoResponse>

    @FormUrlEncoded
    @POST("cancel_leave.php")
    fun cancelLeave(
        @Field("request_id") requestId: String,
        @Field("people_id") userId: String
    ): Call<ApiResponse>

}
