package com.dxb.app.urbanmop.network

import com.dxb.app.urbanmop.data.master.cms.GetPageResponse
import com.dxb.app.urbanmop.models.CommonResponse
import com.dxb.app.urbanmop.models.NormalResponse
import com.dxb.app.urbanmop.models.cities.CitiesResponse
import com.dxb.app.urbanmop.models.cities.LocalityResponse
import com.dxb.app.urbanmop.models.home.HomeAPIResponse
import com.dxb.app.urbanmop.models.home.HomeSettingsResponse
import com.dxb.app.urbanmop.models.jobDetails.JobDetailsResponse
import com.dxb.app.urbanmop.models.login.LoginResponse
import com.dxb.app.urbanmop.models.myJobs.MyJobsResponse
import com.dxb.app.urbanmop.models.newJobs.NewJobsResponse
import com.dxb.app.urbanmop.models.payout.PaymentHistory
import com.dxb.app.urbanmop.models.payout.PayoutResponse
import com.dxb.app.urbanmop.models.profile.ProfileResponse
import com.dxb.app.urbanmop.models.register.RegisterResponse
import com.dxb.app.urbanmop.models.services.ServicesResponse
import com.dxb.app.urbanmop.models.staffs.StaffsResponse
import com.dxb.app.urbanmop.utils.Constants
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.Response
import retrofit2.http.*

interface ApiService {

    @POST("cms/page")
    @FormUrlEncoded
    suspend fun getPage(
        @Header("Accept") jsonHeader: String="application/json",
        @Field("id") page_id: String,
    ): Response<GetPageResponse>


    @POST("login/seller")
    @FormUrlEncoded
    suspend fun login(
        @Header("Accept") jsonHeader: String="application/json",
        @Field("phone") phone: String,
        @Field("dial_code") dial_code: String,
    ): Response<LoginResponse>

    @Multipart
    @POST("seller_register")
    suspend fun register(
        @Part image: MultipartBody.Part?,
        @Part("phone") phone: RequestBody?,
        @Part("email") email: RequestBody?,
        @Part("name") name: RequestBody?,
        @Part("dial_code") dial_code: RequestBody?,
        @Part("company_name") company_name: RequestBody?,
        @Part("city_id") city_id: RequestBody?,
        @Part("locality") locality: RequestBody?,
        @Part("landline_number") landline_number: RequestBody?,
        @Part("l_dial_code") l_dial_code: RequestBody?,
    ): Response<RegisterResponse>

    @Multipart
    @POST("store/business_information")
    suspend fun updateBusinessInformation(
        @Header("Authorization") token: String,

        @Part image: MultipartBody.Part?,
        @Part("phone") phone: RequestBody?,
        @Part("email") email: RequestBody?,
        @Part("name") name: RequestBody?,
        @Part("dial_code") dial_code: RequestBody?,
        @Part("company_name") company_name: RequestBody?,
        @Part("city_id") city_id: RequestBody?,
        @Part("locality") locality: RequestBody?,
        @Part("landline_number") landline_number: RequestBody?,
        @Part("landline_no") landline_no: RequestBody?,
        @Part("l_dial_code") l_dial_code: RequestBody?,
        @Part("address") address: RequestBody?,
    ): Response<CommonResponse>

    @Multipart
    @POST("update/license")
    suspend fun addDetailsLicenses(
        @Header("Authorization") token: String,
        @Part licence_file: MultipartBody.Part?,
        @Part("address") address: RequestBody?,
        @Part("services") services: RequestBody?,
    ): Response<NormalResponse>

    @POST("seller_verify_otp")
    @Multipart
    suspend fun verifyOtp(
        @Part("phone") phone: RequestBody,
        @Part("dial_code") dial_code: RequestBody,
        @Part("otp") otp: RequestBody,
        @Part("user_device_token") user_device_token: RequestBody,
        @Part("user_device_type") user_device_type: RequestBody,
        @Part("device_cart_id") device_cart_id: RequestBody?,
    ): Response<RegisterResponse>
    @POST("resend_otp")
    @FormUrlEncoded
    suspend fun resendOtp(@Field("phone") phone: String): Response<CommonResponse>

    @GET("get/my/jobs")
    suspend fun getMyJobs(
        @Header("Authorization") token: String,
        @Query("page") page: String,
        @Query("limit") limit: String,
    ): Response<MyJobsResponse>

    @GET("get/completed/booking")
    suspend fun getCompletedJobs(
        @Header("Authorization") token: String,
        @Query("page") page: String,
        @Query("limit") limit: String=Constants.PageLimit.toString(),
    ): Response<MyJobsResponse>

    @POST("get/active/booking")
    @FormUrlEncoded
    suspend fun getActiveJobs(
        @Header("Authorization") token: String,
        @Field("page") page: String,
        @Field("limit") limit: String=Constants.PageLimit.toString(),
        @Field("date") date: String?
    ): Response<MyJobsResponse>

    @POST("get/all/bookings")
    @FormUrlEncoded
    suspend fun getNewJobs(
        @Header("Authorization") token: String,
        @Field("page") page: String,
        @Field("limit") limit: String=Constants.PageLimit.toString(),
        @Field("date") date: String?
        ): Response<NewJobsResponse>

    @POST("user_info")
    suspend fun myProfile(
        @Header("Authorization") token: String,
    ): Response<ProfileResponse>

    @GET("get/card/info/{id}")
    suspend fun getJobDetails(
        @Header("Authorization") token: String,
        @Path("id") id: String
    ): Response<JobDetailsResponse>
    @POST("assign_job")
    @FormUrlEncoded
    suspend fun assignJob(
        @Header("Authorization") token: String,
        @Field("card_id") card_id: String,
        @Field("staff_id") staff_id: String,
        @Field("staff_replace_by") staff_replace_by: String?=null,
    ): Response<CommonResponse>
    @POST("assign_session_job_staff")
    @FormUrlEncoded
    suspend fun assignSessionJob(
        @Header("Authorization") token: String,
        @Field("session_id") session_id: String,
        @Field("staff_id") staff_id: String,
        @Field("staff_replace_by") staff_replace_by: String?=null,
    ): Response<CommonResponse>

    @POST("accept/booking")
    @FormUrlEncoded
    suspend fun acceptJob(
        @Header("Authorization") token: String,
        @Field("booking_id") booking_id: String
    ): Response<CommonResponse>

    @POST("started/booking")
    @FormUrlEncoded
    suspend fun startWork(
        @Header("Authorization") token: String,
        @Field("booking_id") booking_id: String,
        @Field("session_id") sessionId: String?,
    ): Response<CommonResponse>


    @POST("booking/canceled")
    @FormUrlEncoded
    suspend fun cancelBooking(
        @Header("Authorization") token: String,
        @Field("booking_id") booking_id: String
    ): Response<CommonResponse>
    @POST("mark-as-arrived")
    @FormUrlEncoded
    suspend fun markAsArrived(
        @Header("Authorization") token: String,
        @Field("booking_id") booking_id: String,
        @Field("session_id") sessionId: String?,
    ): Response<CommonResponse>

    @POST("service/completed")
    @FormUrlEncoded
    suspend fun completeBooking(
        @Header("Authorization") token: String,
        @Field("booking_id") booking_id: String,
        @Field("session_id") sessionId: String?,
    ): Response<CommonResponse>

    @POST("mute/booking")
    @FormUrlEncoded
    suspend fun muteSingleOrder(
        @Header("Authorization") token: String,
        @Field("booking_id") booking_id: String
    ): Response<CommonResponse>
    @POST("mute/all/booking")
    suspend fun muteAllOrder(
        @Header("Authorization") token: String,
    ): Response<CommonResponse>
    @POST("toggle/availability")
    suspend fun toggleAvailability(
        @Header("Authorization") token: String,
    ): Response<CommonResponse>

    @GET("staff_list")
    suspend fun getStaffList(
        @Header("Authorization") token: String,
    ): Response<StaffsResponse>


    @POST("staff_added")
    @FormUrlEncoded
    suspend fun addStaff(
        @Header("Authorization") token: String,
        @Field("first_name") first_name: String,
        @Field("last_name") last_name: String,
        @Field("dial_code") dial_code: String,
        @Field("phone") phone: String,
    ): Response<NormalResponse>

    @POST("staff_updated/{id}")
    @FormUrlEncoded
    suspend fun updateStaff(
        @Header("Authorization") token: String,
        @Path("id") id: String,
        @Field("first_name") first_name: String,
        @Field("last_name") last_name: String,
        @Field("dial_code") dial_code: String,
        @Field("phone") phone: String,
    ): Response<NormalResponse>

    @POST("staff_deleted/{id}")
    suspend fun deleteStaff(
        @Header("Authorization") token: String,
        @Path("id") id: String,
    ): Response<NormalResponse>

    @GET("get/city")
    suspend fun getCities(
    ): Response<CitiesResponse>

    @GET("get/home")
    suspend fun getHomeAPI(
        @Header("Authorization") token: String,
    ): Response<HomeAPIResponse>

    @GET("home/setting")
    suspend fun homeSettings(): Response<HomeSettingsResponse>

    @POST("get/locality")
    @FormUrlEncoded
    suspend fun locality(
        @Field("city_id") city_id: String,
    ): Response<LocalityResponse>


    @POST("update/bank")
    @FormUrlEncoded
    suspend fun updateBankInfo(
        @Header("Authorization") token: String,
        @Field("bank_name") bank_name: String,
        @Field("ac_holder_name") ac_holder_name: String,
        @Field("ac_number") ac_number: String,
    ): Response<NormalResponse>


    @POST("payout/history")
    @FormUrlEncoded
    suspend fun getPayoutHistory(
        @Header("Authorization") token: String,
        @Field("page") page: String,
        @Field("limit") limit: String=Constants.PageLimit.toString(),
        ): Response<PayoutResponse>

    @POST("payments")
    @FormUrlEncoded
    suspend fun getPaymentHistory(
        @Header("Authorization") token: String,
        @Field("page") page: String,
        @Field("limit") limit: String=Constants.PageLimit.toString(),
    ): Response<PaymentHistory>

    @GET("all/service/name")
    suspend fun getServices(
    ): Response<ServicesResponse>


    @POST("contacts")
    @FormUrlEncoded
    suspend fun contacts(
        @Header("Authorization") token: String,
        @Field("name") name: String,
        @Field("email") email: String,
        @Field("message") message: String,
    ): Response<CommonResponse>

    @POST("send/notification")
    @FormUrlEncoded
    suspend fun sendNotification(
        @Header("Authorization") token: String,
        @Field("title") title: String,
        @Field("body") body: String,
        @Field("data") data: String,
        @Field("user_id") user_id: String,
    ):Response<CommonResponse>
}
