diff --git a/wrapper/build.gradle.kts b/wrapper/build.gradle.kts index 5efabc9..94cb0da 100644 --- a/wrapper/build.gradle.kts +++ b/wrapper/build.gradle.kts @@ -9,6 +9,8 @@ dependencies { implementation("com.squareup.retrofit2:retrofit:$retrofitVersion") implementation("com.squareup.retrofit2:converter-gson:$retrofitVersion") + // mock server response + testImplementation("com.squareup.okhttp3:mockwebserver:4.2.1") // use JUnit test framework testImplementation("junit:junit:4.12") } diff --git a/wrapper/src/main/java/wekan/wrapper/api/BoardService.java b/wrapper/src/main/java/wekan/wrapper/api/BoardService.java new file mode 100644 index 0000000..78d7f27 --- /dev/null +++ b/wrapper/src/main/java/wekan/wrapper/api/BoardService.java @@ -0,0 +1,86 @@ +package wekan.wrapper.api; + +import retrofit2.Call; +import retrofit2.http.*; +import wekan.wrapper.entity.Board; +import wekan.wrapper.entity.LabelPrototype; +import wekan.wrapper.entity.MemberPermission; +import wekan.wrapper.entity.BoardPrototype; + +import java.util.List; + +public interface BoardService { + + /** + * Get all public boards. + * + * @return the list with all public boards + */ + @GET("api/boards") + Call> getPublicBoards(); + + /** + * Create a board. + * + * @param boardPrototype the prototype of the new board + * @return the new board + * @see BoardPrototype + */ + @POST("api/boards") + Call newBoard(@Body BoardPrototype boardPrototype); + + /** + * Get the board with that particular ID. + * + * @param boardId The ID of the board + * @return The board with the matching ID + */ + @GET("api/boards/{boardId}") + Call getBoard(@Path("boardId") String boardId); + + /** + * Delete the board with that particular ID + * + * @param boardId The ID of the board + */ + @DELETE("api/boards/{boardId}") + Call deleteBoard(@Path("boardId") String boardId); + + /** + * Add a label to a board. + * + * @param boardId The ID of the board + * @param labelPrototype The prototype of new label + * @return The ID of new label + * @see LabelPrototype + */ + @PUT("/api/boards/{boardId}/labels") + Call addLabel( + @Path("boardId") String boardId, + @Body LabelPrototype labelPrototype + ); + + /** + * Change the permission of a member of a board. + * + * @param boardId The ID of the board + * @param memberId The ID of the member + * @param memberPermission The new role of the member + * @see MemberPermission + */ + @POST("/api/boards/{boardId}/members/{memberId}") + Call setMemberPermission( + @Path("boardId") String boardId, + @Path("memberId") String memberId, + @Body MemberPermission memberPermission + ); + + /** + * Get all boards attached to a user. + * + * @param userId The ID of the user + * @return The list with all user's boards + */ + @GET("api/users/{userId}/boards") + Call> getBoardsFromUser(@Path("userId") String userId); +} diff --git a/wrapper/src/main/java/wekan/wrapper/api/ExampleApi.java b/wrapper/src/main/java/wekan/wrapper/api/ExampleApi.java deleted file mode 100644 index 3e139bd..0000000 --- a/wrapper/src/main/java/wekan/wrapper/api/ExampleApi.java +++ /dev/null @@ -1,4 +0,0 @@ -package wekan.wrapper.api; - -public interface ExampleApi { -} diff --git a/wrapper/src/main/java/wekan/wrapper/entity/Board.java b/wrapper/src/main/java/wekan/wrapper/entity/Board.java new file mode 100644 index 0000000..175afdf --- /dev/null +++ b/wrapper/src/main/java/wekan/wrapper/entity/Board.java @@ -0,0 +1,155 @@ +package wekan.wrapper.entity; + +import com.google.gson.annotations.SerializedName; + +import java.util.Date; +import java.util.List; + +public class Board { + @SerializedName("_id") + private String id; + private String title; + private String slug; + private boolean archived; + private Date createdAt; + private Date modifiedAt; + private int starts; + private List