From cc1f4b0628f91ff795072e9e0d2a79602381e786 Mon Sep 17 00:00:00 2001 From: Peter Vacho Date: Sat, 4 Jan 2025 23:45:10 +0100 Subject: [PATCH] feat(categoryCreate): Add API post request logic --- .../com/p_vacho/neat_calendar/api/models/CategoryModels.kt | 7 ++++++- .../p_vacho/neat_calendar/api/services/CategoryService.kt | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/p_vacho/neat_calendar/api/models/CategoryModels.kt b/app/src/main/java/com/p_vacho/neat_calendar/api/models/CategoryModels.kt index 9d9fcc6..859c546 100644 --- a/app/src/main/java/com/p_vacho/neat_calendar/api/models/CategoryModels.kt +++ b/app/src/main/java/com/p_vacho/neat_calendar/api/models/CategoryModels.kt @@ -15,4 +15,9 @@ data class CategoryResponse( val color: Color, val owner_user_id: String, val created_at: OffsetDateTime -): Parcelable \ No newline at end of file +): Parcelable + +data class CategoryRequest( + val name: String, + val color: Color, +) \ No newline at end of file diff --git a/app/src/main/java/com/p_vacho/neat_calendar/api/services/CategoryService.kt b/app/src/main/java/com/p_vacho/neat_calendar/api/services/CategoryService.kt index 2b2374d..338a9a2 100644 --- a/app/src/main/java/com/p_vacho/neat_calendar/api/services/CategoryService.kt +++ b/app/src/main/java/com/p_vacho/neat_calendar/api/services/CategoryService.kt @@ -1,8 +1,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.CategoryResponse +import retrofit2.http.Body import retrofit2.http.DELETE import retrofit2.http.GET +import retrofit2.http.POST import retrofit2.http.Path interface CategoryService { @@ -15,6 +18,9 @@ interface CategoryService { @GET("/categories/{category_id}") suspend fun getCategory(@Path("category_id") categoryId: String): CategoryResponse + @POST("/categories") + suspend fun createCategory(@Body categoryData: CategoryRequest): CategoryResponse + @DELETE("/categories/{category_id}") suspend fun deleteCategory(@Path("category_id") categoryId: String): Unit } \ No newline at end of file