feat(categoryCreate): Add API patch request logic

This commit is contained in:
Peter Vacho 2025-01-05 00:04:28 +01:00
parent cc1f4b0628
commit 03e7021c1a
Signed by: school
GPG key ID: 8CFC3837052871B4
2 changed files with 10 additions and 0 deletions

View file

@ -20,4 +20,9 @@ data class CategoryResponse(
data class CategoryRequest( data class CategoryRequest(
val name: String, val name: String,
val color: Color, val color: Color,
)
data class PartialCategoryRequest(
val name: String?,
val color: Color?,
) )

View file

@ -2,9 +2,11 @@ package com.p_vacho.neat_calendar.api.services
import com.p_vacho.neat_calendar.api.models.CategoryRequest import com.p_vacho.neat_calendar.api.models.CategoryRequest
import com.p_vacho.neat_calendar.api.models.CategoryResponse import com.p_vacho.neat_calendar.api.models.CategoryResponse
import com.p_vacho.neat_calendar.api.models.PartialCategoryRequest
import retrofit2.http.Body import retrofit2.http.Body
import retrofit2.http.DELETE import retrofit2.http.DELETE
import retrofit2.http.GET import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST import retrofit2.http.POST
import retrofit2.http.Path import retrofit2.http.Path
@ -21,6 +23,9 @@ interface CategoryService {
@POST("/categories") @POST("/categories")
suspend fun createCategory(@Body categoryData: CategoryRequest): CategoryResponse suspend fun createCategory(@Body categoryData: CategoryRequest): CategoryResponse
@PATCH("/categories/{category_id}")
suspend fun createCategory(@Path("category_id") categoryId: String, @Body categoryData: PartialCategoryRequest): CategoryResponse
@DELETE("/categories/{category_id}") @DELETE("/categories/{category_id}")
suspend fun deleteCategory(@Path("category_id") categoryId: String): Unit suspend fun deleteCategory(@Path("category_id") categoryId: String): Unit
} }