package com.santamarta.chamado_gestao import com.google.gson.annotations.SerializedName import okhttp3.MultipartBody import okhttp3.RequestBody import retrofit2.http.Body import retrofit2.http.Field import retrofit2.http.FormUrlEncoded import retrofit2.http.GET import retrofit2.http.Headers import retrofit2.http.Multipart import retrofit2.http.POST import retrofit2.http.Part import retrofit2.http.Query interface ApiService { @POST("api/login_app.php") suspend fun login( @Body req: LoginRequest ): LoginResponse @FormUrlEncoded @POST("ping_app.php") suspend fun pingApp( @Field("user_id") userId: Int ): PingResponse @GET("chamados_list.php") suspend fun listChamados( @Query("status") status: String? = null, @Query("limit") limit: Int = 50 ): ChamadosListResponse @GET("api/chamado_detail.php") suspend fun detailChamado( @Query("id") id: Int ): RespostaDetalhe @FormUrlEncoded @POST("api/chamado_update.php") suspend fun updateChamado( @Field("id") id: Int, @Field("status") status: String, @Field("observacao") observacao: String, @Field("checklist_tecnico") checklistTecnico: String = "", @Field("pecas_trocadas") pecasTrocadas: String = "", @Field("geolocalizacao") geolocalizacao: String = "", @Field("motivo_encerramento") motivoEncerramento: String = "" ): ChamadoBaseResponse @Multipart @POST("api/upload_fotos.php") suspend fun uploadFotos( @Part("chamado_id") id: RequestBody, @Part("tipo") tipo: RequestBody, @Part foto: MultipartBody.Part ): ChamadoBaseResponse @Headers("Content-Type: application/json") @POST("api/salvar_assinatura.php") suspend fun salvarAssinatura( @Body body: AssinaturaPayload ): AssinaturaResponse @Headers("Content-Type: application/json") @POST("salvar_push_token.php") suspend fun salvarPushToken( @Body body: PushTokenRequest ): BasicResponse } // Mantive todas as suas models existentes e acrescentei só o bloco novo da FASE 3. data class PushTokenRequest( @SerializedName("login_name") val loginName: String, @SerializedName("device_token") val deviceToken: String, @SerializedName("platform") val platform: String = "android", @SerializedName("device_name") val deviceName: String? = null, @SerializedName("app_version") val appVersion: String? = null ) data class BasicResponse( @SerializedName("success") val success: Boolean, @SerializedName("message") val message: String? = null ) data class LoginRequest( @SerializedName("usuario") val usuario: String, @SerializedName("senha") val senha: String ) data class LoginResponse( @SerializedName("success") val success: Boolean, @SerializedName("token") val token: String? = null, @SerializedName("message") val message: String? = null, @SerializedName("userId") val userId: Int? = null, @SerializedName("name") val name: String? = null, @SerializedName("perfil") val perfil: String? = null ) data class PingResponse( @SerializedName("success") val success: Boolean? = null, @SerializedName("ok") val ok: Boolean? = null, @SerializedName("message") val message: String? = null, @SerializedName("msg") val msg: String? = null, @SerializedName("user_id") val userId: Int? = null, @SerializedName("server_time") val serverTime: String? = null ) { val isOk: Boolean get() = success == true || ok == true val resolvedMessage: String? get() = message ?: msg } data class AssinaturaPayload( @SerializedName("chamado_id") val chamadoId: Int, @SerializedName("nome_assinante") val nomeAssinante: String, @SerializedName("documento_assinante") val documentoAssinante: String? = null, @SerializedName("observacao") val observacao: String? = null, @SerializedName("assinatura_base64") val assinaturaBase64: String ) data class AssinaturaResponse( @SerializedName("success") val success: Boolean, @SerializedName("message") val message: String? = null, @SerializedName("arquivo") val arquivo: String? = null )