From acd77243537b5bafdd39566ec461bd36a2fbfed9 Mon Sep 17 00:00:00 2001 From: norangebit Date: Wed, 13 Nov 2019 19:29:04 +0100 Subject: [PATCH 1/4] add getChecklists and postChecklist - add class Checklist - add class ChecklistPrototype --- .../wekan/wrapper/api/ChecklistService.java | 56 ++++++++++++++++++ .../java/wekan/wrapper/entity/Checklist.java | 57 +++++++++++++++++++ .../wrapper/entity/ChecklistPrototype.java | 40 +++++++++++++ 3 files changed, 153 insertions(+) create mode 100644 wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java create mode 100644 wrapper/src/main/java/wekan/wrapper/entity/Checklist.java create mode 100644 wrapper/src/main/java/wekan/wrapper/entity/ChecklistPrototype.java diff --git a/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java b/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java new file mode 100644 index 0000000..d04a514 --- /dev/null +++ b/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java @@ -0,0 +1,56 @@ +package wekan.wrapper.api; + +import retrofit2.Call; +import retrofit2.http.*; +import wekan.wrapper.entity.Checklist; +import wekan.wrapper.entity.ChecklistPrototype; + +import java.util.List; + +public interface ChecklistService { + + /** + * Get all checklists attached on a card. + * + * @param boardId The ID of the board + * @param cardId The ID of the card + * @return The list with the checklists + */ + @GET("/api/boards/{boardId}/cards/{cardId}/checklists") + Call> getChecklists( + @Path("boardId") String boardId, + @Path("cardId") String cardId + ); + + /** + * Attach new empty checklist to a card. + * + * @param boardId The ID of the board + * @param cardId The ID of the card + * @param title The title of the new checklist + * @return The new checklist + */ + @FormUrlEncoded + @POST("/api/boards/{boardId}/cards/{cardId}/checklists") + Call postChecklist( + @Path("boardId") String boardId, + @Path("cardId") String cardId, + @Field("title") String title + ); + + /** + * Attach new checklist to a card. + * + * @param boardId The ID of the board + * @param cardId The ID of the card + * @param checklistPrototype The prototype of the checklist + * @return The new checklist + * @see ChecklistPrototype + */ + @POST("/api/boards/{boardId}/cards/{cardId}/checklists") + Call postChecklist( + @Path("boardId") String boardId, + @Path("cardId") String cardId, + @Body ChecklistPrototype checklistPrototype + ); +} diff --git a/wrapper/src/main/java/wekan/wrapper/entity/Checklist.java b/wrapper/src/main/java/wekan/wrapper/entity/Checklist.java new file mode 100644 index 0000000..4e01f86 --- /dev/null +++ b/wrapper/src/main/java/wekan/wrapper/entity/Checklist.java @@ -0,0 +1,57 @@ +package wekan.wrapper.entity; + +import com.google.gson.annotations.SerializedName; + +import java.util.Date; + +public class Checklist { + @SerializedName("_id") + private String id; + private String cardId; + private String title; + private Date finishedAt; + private Date createdAt; + private Date modifiedAt; + private int sort; + + public String getId() { + return id; + } + + public String getCardId() { + return cardId; + } + + public String getTitle() { + return title; + } + + public Date getFinishedAt() { + return finishedAt; + } + + public Date getCreatedAt() { + return createdAt; + } + + public Date getModifiedAt() { + return modifiedAt; + } + + public int getSort() { + return sort; + } + + @Override + public String toString() { + return "Checklist{" + + "id='" + id + '\'' + + ", cardId='" + cardId + '\'' + + ", title='" + title + '\'' + + ", finishedAt=" + finishedAt + + ", createdAt=" + createdAt + + ", modifiedAt=" + modifiedAt + + ", sort=" + sort + + '}'; + } +} diff --git a/wrapper/src/main/java/wekan/wrapper/entity/ChecklistPrototype.java b/wrapper/src/main/java/wekan/wrapper/entity/ChecklistPrototype.java new file mode 100644 index 0000000..07cb673 --- /dev/null +++ b/wrapper/src/main/java/wekan/wrapper/entity/ChecklistPrototype.java @@ -0,0 +1,40 @@ +package wekan.wrapper.entity; + +import java.util.ArrayList; +import java.util.List; + +public class ChecklistPrototype { + private String title; + private List items; + + private ChecklistPrototype(String title, List items) { + this.title = title; + this.items = items; + } + + public static class Builder { + private String title; + private List items; + + public Builder() { + items = new ArrayList<>(); + } + + public ChecklistPrototype build() { + return new ChecklistPrototype( + title, + items + ); + } + + public Builder setTitle(String title) { + this.title = title; + return this; + } + + public Builder addItems(String item) { + items.add(item); + return this; + } + } +} -- 2.45.2 From c22a8d78b44942699a0e8555f874bcdcc505eb4c Mon Sep 17 00:00:00 2001 From: norangebit Date: Wed, 13 Nov 2019 21:02:06 +0100 Subject: [PATCH 2/4] add getChecklist and deleteChecklist --- .../wekan/wrapper/api/ChecklistService.java | 54 +++-- .../java/wekan/wrapper/entity/Checklist.java | 7 + .../wekan/wrapper/entity/ChecklistItem.java | 32 +++ .../wrapper/entity/ChecklistPrototype.java | 17 ++ .../wrapper/api/ChecklistServiceTest.java | 188 ++++++++++++++++++ 5 files changed, 286 insertions(+), 12 deletions(-) create mode 100644 wrapper/src/main/java/wekan/wrapper/entity/ChecklistItem.java create mode 100644 wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java diff --git a/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java b/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java index d04a514..9e90d71 100644 --- a/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java +++ b/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java @@ -12,12 +12,12 @@ public interface ChecklistService { /** * Get all checklists attached on a card. * - * @param boardId The ID of the board - * @param cardId The ID of the card - * @return The list with the checklists + * @param boardId The ID of the board + * @param cardId The ID of the card + * @return The list with the checklists */ @GET("/api/boards/{boardId}/cards/{cardId}/checklists") - Call> getChecklists( + Call> getAllChecklists( @Path("boardId") String boardId, @Path("cardId") String cardId ); @@ -25,10 +25,10 @@ public interface ChecklistService { /** * Attach new empty checklist to a card. * - * @param boardId The ID of the board - * @param cardId The ID of the card - * @param title The title of the new checklist - * @return The new checklist + * @param boardId The ID of the board + * @param cardId The ID of the card + * @param title The title of the new checklist + * @return The new checklist */ @FormUrlEncoded @POST("/api/boards/{boardId}/cards/{cardId}/checklists") @@ -41,10 +41,10 @@ public interface ChecklistService { /** * Attach new checklist to a card. * - * @param boardId The ID of the board - * @param cardId The ID of the card - * @param checklistPrototype The prototype of the checklist - * @return The new checklist + * @param boardId The ID of the board + * @param cardId The ID of the card + * @param checklistPrototype The prototype of the checklist + * @return The new checklist * @see ChecklistPrototype */ @POST("/api/boards/{boardId}/cards/{cardId}/checklists") @@ -53,4 +53,34 @@ public interface ChecklistService { @Path("cardId") String cardId, @Body ChecklistPrototype checklistPrototype ); + + /** + * Get the checklist attached on a card. + * + * @param boardId The ID of the board + * @param cardId The ID of the card + * @param checklistId The ID of the checklist + * @return The checklist + */ + @GET("/api/boards/{boardId}/cards/{cardId}/checklists/{checklistId}") + Call getChecklist( + @Path("boardId") String boardId, + @Path("cardId") String cardId, + @Path("checklistId") String checklistId + ); + + /** + * Delete the checklist attached on a card. + * + * @param boardId The ID of the board + * @param cardId The ID of the card + * @param checklistId The ID of the checklist + * @return The id of the checklist + */ + @DELETE("/api/boards/{boardId}/cards/{cardId}/checklists/{checklistId}") + Call deleteChecklist( + @Path("boardId") String boardId, + @Path("cardId") String cardId, + @Path("checklistId") String checklistId + ); } diff --git a/wrapper/src/main/java/wekan/wrapper/entity/Checklist.java b/wrapper/src/main/java/wekan/wrapper/entity/Checklist.java index 4e01f86..dbd335d 100644 --- a/wrapper/src/main/java/wekan/wrapper/entity/Checklist.java +++ b/wrapper/src/main/java/wekan/wrapper/entity/Checklist.java @@ -3,12 +3,14 @@ package wekan.wrapper.entity; import com.google.gson.annotations.SerializedName; import java.util.Date; +import java.util.List; public class Checklist { @SerializedName("_id") private String id; private String cardId; private String title; + private List items; private Date finishedAt; private Date createdAt; private Date modifiedAt; @@ -26,6 +28,10 @@ public class Checklist { return title; } + public List getItems() { + return items; + } + public Date getFinishedAt() { return finishedAt; } @@ -48,6 +54,7 @@ public class Checklist { "id='" + id + '\'' + ", cardId='" + cardId + '\'' + ", title='" + title + '\'' + + ", items=" + items + ", finishedAt=" + finishedAt + ", createdAt=" + createdAt + ", modifiedAt=" + modifiedAt + diff --git a/wrapper/src/main/java/wekan/wrapper/entity/ChecklistItem.java b/wrapper/src/main/java/wekan/wrapper/entity/ChecklistItem.java new file mode 100644 index 0000000..af8ea97 --- /dev/null +++ b/wrapper/src/main/java/wekan/wrapper/entity/ChecklistItem.java @@ -0,0 +1,32 @@ +package wekan.wrapper.entity; + +import com.google.gson.annotations.SerializedName; + +public class ChecklistItem { + @SerializedName("_id") + private String id; + private String title; + private boolean isFinished; + + public String getId() { + return id; + } + + public String getTitle() { + return title; + } + + public boolean isFinished() { + return isFinished; + } + + @Override + public String toString() { + return "ChecklistItem{" + + "id='" + id + '\'' + + ", title='" + title + '\'' + + ", isFinished=" + isFinished + + '}'; + } +} + diff --git a/wrapper/src/main/java/wekan/wrapper/entity/ChecklistPrototype.java b/wrapper/src/main/java/wekan/wrapper/entity/ChecklistPrototype.java index 07cb673..1f36dce 100644 --- a/wrapper/src/main/java/wekan/wrapper/entity/ChecklistPrototype.java +++ b/wrapper/src/main/java/wekan/wrapper/entity/ChecklistPrototype.java @@ -20,6 +20,11 @@ public class ChecklistPrototype { items = new ArrayList<>(); } + /** + * Create a new ChecklistPrototype. + * + * @return The ChecklistPrototype + */ public ChecklistPrototype build() { return new ChecklistPrototype( title, @@ -27,11 +32,23 @@ public class ChecklistPrototype { ); } + /** + * Set the title of the new checklist + * + * @param title The title of the new board + * @return The builder + */ public Builder setTitle(String title) { this.title = title; return this; } + /** + * Add a new checklist item to the checklist + * + * @param item The item to add to the checklist + * @return The builder + */ public Builder addItems(String item) { items.add(item); return this; diff --git a/wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java b/wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java new file mode 100644 index 0000000..5ec72e4 --- /dev/null +++ b/wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java @@ -0,0 +1,188 @@ +package wekan.wrapper.api; + +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; +import wekan.wrapper.entity.*; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.util.List; + +import static org.junit.Assert.*; + +public class ChecklistServiceTest { + private MockWebServer mockWebServer = new MockWebServer(); + private ChecklistService service = null; + + @Before + public void setUp() { + try { + mockWebServer.start(); + service = new Retrofit.Builder() + .baseUrl(mockWebServer.url("/")) + .addConverterFactory(GsonConverterFactory.create()) + .build() + .create(ChecklistService.class); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + @After + public void teardown() { + try { + mockWebServer.shutdown(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void getAllChecklist() { + MockResponse response = new MockResponse() + .setResponseCode(HttpURLConnection.HTTP_OK) + .setBody( + "[ " + CHECKLIST_1 + ", " + CHECKLIST_2 + " ]" + ); + + mockWebServer.enqueue(response); + + try { + List checklists = service.getAllChecklists( + "board id", "card id" + ). + execute().body(); + + assertNotNull(checklists); + assertEquals(2, checklists.size()); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void postChecklist() { + MockResponse response = new MockResponse() + .setResponseCode(HttpURLConnection.HTTP_OK) + .setBody( + CHECKLIST_2 + ); + + mockWebServer.enqueue(response); + + try { + Checklist checklist = service.postChecklist( + "board id", + "card id", + "title" + ) + .execute().body(); + + assertNotNull(checklist); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void postChecklistChecklistPrototype() { + MockResponse response = new MockResponse() + .setResponseCode(HttpURLConnection.HTTP_OK) + .setBody( + CHECKLIST_2 + ); + + mockWebServer.enqueue(response); + + try { + Checklist checklist = service.postChecklist( + "board id", + "card id", + new ChecklistPrototype.Builder() + .setTitle("title") + .addItems("item 1") + .addItems("item 2") + .build() + ) + .execute().body(); + + assertNotNull(checklist); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void getChecklist() { + MockResponse response = new MockResponse() + .setResponseCode(HttpURLConnection.HTTP_OK) + .setBody( + CHECKLIST_1 + ); + + mockWebServer.enqueue(response); + + try { + Checklist checklist = service.getChecklist( + "board id", + "card id", + "checklist id" + ) + .execute().body(); + + assertNotNull(checklist); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void deleteChecklist() { + MockResponse response = new MockResponse() + .setResponseCode(HttpURLConnection.HTTP_OK) + .setBody( + "{ \"_id\": \"jdisfoSIkf0\" }" + ); + + mockWebServer.enqueue(response); + + try { + Checklist checklist = service.deleteChecklist( + "board id", + "card id", + "checklist id" + ) + .execute().body(); + + assertNotNull(checklist); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static final String CHECKLIST_1 = "{" + + "\"_id\":\"Tv6FuHLWaDR4Z3ig2\"," + + "\"title\":\"clist 1\"," + + "\"cardId\":\"bndtZCrJ9kshcFuw8\"," + + "\"sort\":0," + + "\"createdAt\":\"2019-11-13T18:22:59.987Z\"," + + "\"modifiedAt\":\"2019-11-13T19:34:48.650Z\"," + + "\"items\":[" + + "{\"_id\":\"9J8n6d6u3TkCAGvhw\",\"title\":\"item 1\",\"isFinished\":false}," + + "{\"_id\":\"iehKbi7qFruCyMRNQ\",\"title\":\"item 2\",\"isFinished\":false}" + + "]" + + "}"; + + private static final String CHECKLIST_2 = "{" + + "\"_id\":\"Tv6FuHLWaDR4Z3ig2\"," + + "\"title\":\"clist 1\"" + + "}"; +} -- 2.45.2 From 9ce3629bbc894a8dc68d031f520b2eed7a67ab80 Mon Sep 17 00:00:00 2001 From: norangebit Date: Thu, 14 Nov 2019 18:53:50 +0100 Subject: [PATCH 3/4] add checklist item - add class ChecklistItem - add API for checklist item --- .../wekan/wrapper/api/ChecklistService.java | 85 ++++++++++++++ .../wekan/wrapper/entity/ChecklistItem.java | 38 +++++++ .../java/wekan/wrapper/entity/TestBody.java | 9 ++ .../wrapper/api/ChecklistServiceTest.java | 106 ++++++++++++++++++ 4 files changed, 238 insertions(+) create mode 100644 wrapper/src/main/java/wekan/wrapper/entity/TestBody.java diff --git a/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java b/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java index 9e90d71..009044a 100644 --- a/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java +++ b/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java @@ -3,7 +3,9 @@ package wekan.wrapper.api; import retrofit2.Call; import retrofit2.http.*; import wekan.wrapper.entity.Checklist; +import wekan.wrapper.entity.ChecklistItem; import wekan.wrapper.entity.ChecklistPrototype; +import wekan.wrapper.entity.TestBody; import java.util.List; @@ -83,4 +85,87 @@ public interface ChecklistService { @Path("cardId") String cardId, @Path("checklistId") String checklistId ); + + /** + * Get the checklist item attached on a checklist. + * + * @param boardId The ID of the board + * @param cardId The ID of the card + * @param checklistId The ID of the checklist + * @param itemId The ID of the item + * @return The checklist item + */ + @GET("/api/boards/{boardId}/cards/{cardId}/checklists/{checklistId}/items/{itemId}") + Call getChecklistItem( + @Path("boardId") String boardId, + @Path("cardId") String cardId, + @Path("checklistId") String checklistId, + @Path("itemId") String itemId + ); + + /** + * Change the title of the checklist item. + * + * @param boardId The ID of the board + * @param cardId The ID of the card + * @param checklistId The ID of the checklist + * @param itemId The ID of the item + * @param title The new title + * @return The ID of the checklist item + */ + @FormUrlEncoded + @PUT("/api/boards/{boardId}/cards/{cardId}/checklists/{checklistId}/items/{itemId}") + Call editChecklistItem( + @Path("boardId") String boardId, + @Path("cardId") String cardId, + @Path("checklistId") String checklistId, + @Path("itemId") String itemId, + @Field("title") String title + ); + + /** + * Change the state of the checklist item. + * + * @param boardId The ID of the board + * @param cardId The ID of the card + * @param checklistId The ID of the checklist + * @param itemId The ID of the item + * @param isFinished True if the item is done + * @return The ID of the checklist item + */ + @FormUrlEncoded + @PUT("/api/boards/{boardId}/cards/{cardId}/checklists/{checklistId}/items/{itemId}") + Call editChecklistItem( + @Path("boardId") String boardId, + @Path("cardId") String cardId, + @Path("checklistId") String checklistId, + @Path("itemId") String itemId, + @Field("isFinished") boolean isFinished + ); + + /** + * Delete a checklist item from the checklist. + * + * @param boardId The ID of the board + * @param cardId The ID of the card + * @param checklistId The ID of the checklist + * @param itemId The ID of the item + * @return The ID of the checklist item + */ + @DELETE("/api/boards/{boardId}/cards/{cardId}/checklists/{checklistId}/items/{itemId}") + Call deleteChecklistItem( + @Path("boardId") String boardId, + @Path("cardId") String cardId, + @Path("checklistId") String checklistId, + @Path("itemId") String itemId + ); + + @PUT("/api/boards/{boardId}/cards/{cardId}/checklists/{checklistId}/items/{itemId}") + Call editChecklistItem( + @Path("boardId") String boardId, + @Path("cardId") String cardId, + @Path("checklistId") String checklistId, + @Path("itemId") String itemId, + @Body TestBody isFinished + ); } diff --git a/wrapper/src/main/java/wekan/wrapper/entity/ChecklistItem.java b/wrapper/src/main/java/wekan/wrapper/entity/ChecklistItem.java index af8ea97..bc43118 100644 --- a/wrapper/src/main/java/wekan/wrapper/entity/ChecklistItem.java +++ b/wrapper/src/main/java/wekan/wrapper/entity/ChecklistItem.java @@ -2,10 +2,18 @@ package wekan.wrapper.entity; import com.google.gson.annotations.SerializedName; +import java.util.Date; + public class ChecklistItem { @SerializedName("_id") private String id; private String title; + private String checklistId; + private String cardId; + private String userId; + private int sort; + private Date createdAt; + private Date modifiedAt; private boolean isFinished; public String getId() { @@ -16,6 +24,30 @@ public class ChecklistItem { return title; } + public String getChecklistId() { + return checklistId; + } + + public String getCardId() { + return cardId; + } + + public String getUserId() { + return userId; + } + + public int getSort() { + return sort; + } + + public Date getCreatedAt() { + return createdAt; + } + + public Date getModifiedAt() { + return modifiedAt; + } + public boolean isFinished() { return isFinished; } @@ -25,6 +57,12 @@ public class ChecklistItem { return "ChecklistItem{" + "id='" + id + '\'' + ", title='" + title + '\'' + + ", checklistId='" + checklistId + '\'' + + ", cardId='" + cardId + '\'' + + ", userId='" + userId + '\'' + + ", sort=" + sort + + ", createdAt=" + createdAt + + ", modifiedAt=" + modifiedAt + ", isFinished=" + isFinished + '}'; } diff --git a/wrapper/src/main/java/wekan/wrapper/entity/TestBody.java b/wrapper/src/main/java/wekan/wrapper/entity/TestBody.java new file mode 100644 index 0000000..c403f1c --- /dev/null +++ b/wrapper/src/main/java/wekan/wrapper/entity/TestBody.java @@ -0,0 +1,9 @@ +package wekan.wrapper.entity; + +public class TestBody { + private boolean isFinished; + + public TestBody(boolean isFinished) { + this.isFinished = isFinished; + } +} diff --git a/wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java b/wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java index 5ec72e4..a6ee073 100644 --- a/wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java +++ b/wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java @@ -168,6 +168,100 @@ public class ChecklistServiceTest { } } + @Test + public void getChecklistItem() { + MockResponse response = new MockResponse() + .setResponseCode(HttpURLConnection.HTTP_OK) + .setBody(ITEM); + + mockWebServer.enqueue(response); + + try { + ChecklistItem item = service.getChecklistItem( + "board id", + "card id", + "checklist id", + "item id" + ) + .execute().body(); + + assertNotNull(item); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void editChecklistItemTitle() { + MockResponse response = new MockResponse() + .setResponseCode(HttpURLConnection.HTTP_OK) + .setBody("{ \"_id\": \"id\" }"); + + mockWebServer.enqueue(response); + + try { + ChecklistItem item = service.editChecklistItem( + "board id", + "card id", + "checklist id", + "item id", + "new title" + ) + .execute().body(); + + assertNotNull(item); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void editChecklistItemState() { + MockResponse response = new MockResponse() + .setResponseCode(HttpURLConnection.HTTP_OK) + .setBody("{ \"_id\": \"id\" }"); + + mockWebServer.enqueue(response); + + try { + ChecklistItem item = service.editChecklistItem( + "board id", + "card id", + "checklist id", + "item id", + true + ) + .execute().body(); + + assertNotNull(item); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void deleteChecklistItem() { + MockResponse response = new MockResponse() + .setResponseCode(HttpURLConnection.HTTP_OK) + .setBody("{ \"_id\": \"id\" }"); + + mockWebServer.enqueue(response); + + try { + ChecklistItem item = service.deleteChecklistItem( + "board id", + "card id", + "checklist id", + "item id" + ) + .execute().body(); + + assertNotNull(item); + } catch (IOException e) { + e.printStackTrace(); + } + } + private static final String CHECKLIST_1 = "{" + "\"_id\":\"Tv6FuHLWaDR4Z3ig2\"," + "\"title\":\"clist 1\"," + @@ -185,4 +279,16 @@ public class ChecklistServiceTest { "\"_id\":\"Tv6FuHLWaDR4Z3ig2\"," + "\"title\":\"clist 1\"" + "}"; + + private static final String ITEM = "{" + + "\"_id\":\"3HhzyoYBYGSr4mLdY\"," + + "\"title\":\"cosa da fare 1\"," + + "\"checklistId\":\"LyE7odMhtqZrgrXL9\"," + + "\"cardId\":\"bndtZCrJ9kshcFuw8\"," + + "\"sort\":0," + + "\"isFinished\":true," + + "\"createdAt\":\"2019-11-14T16:12:46.672Z\"," + + "\"modifiedAt\":\"2019-11-14T16:17:16.159Z\"," + + "\"userId\":\"Si69gNgkJfQuk6uiJ\"" + + "}"; } -- 2.45.2 From cf59f3b325f69dbfb0f4923fc060edd0ce8b9db6 Mon Sep 17 00:00:00 2001 From: norangebit Date: Fri, 15 Nov 2019 16:14:39 +0100 Subject: [PATCH 4/4] add ChecklistItemStatus Use ChecklistItemStatus to avoid #12 --- .../wekan/wrapper/api/ChecklistService.java | 17 ++++------------- .../{TestBody.java => ChecklistItemStatus.java} | 4 ++-- .../wekan/wrapper/api/ChecklistServiceTest.java | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) rename wrapper/src/main/java/wekan/wrapper/entity/{TestBody.java => ChecklistItemStatus.java} (55%) diff --git a/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java b/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java index 009044a..ca0047d 100644 --- a/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java +++ b/wrapper/src/main/java/wekan/wrapper/api/ChecklistService.java @@ -5,7 +5,7 @@ import retrofit2.http.*; import wekan.wrapper.entity.Checklist; import wekan.wrapper.entity.ChecklistItem; import wekan.wrapper.entity.ChecklistPrototype; -import wekan.wrapper.entity.TestBody; +import wekan.wrapper.entity.ChecklistItemStatus; import java.util.List; @@ -130,17 +130,17 @@ public interface ChecklistService { * @param cardId The ID of the card * @param checklistId The ID of the checklist * @param itemId The ID of the item - * @param isFinished True if the item is done + * @param itemStatus The status of the item * @return The ID of the checklist item + * @see ChecklistItemStatus */ - @FormUrlEncoded @PUT("/api/boards/{boardId}/cards/{cardId}/checklists/{checklistId}/items/{itemId}") Call editChecklistItem( @Path("boardId") String boardId, @Path("cardId") String cardId, @Path("checklistId") String checklistId, @Path("itemId") String itemId, - @Field("isFinished") boolean isFinished + @Body ChecklistItemStatus itemStatus ); /** @@ -159,13 +159,4 @@ public interface ChecklistService { @Path("checklistId") String checklistId, @Path("itemId") String itemId ); - - @PUT("/api/boards/{boardId}/cards/{cardId}/checklists/{checklistId}/items/{itemId}") - Call editChecklistItem( - @Path("boardId") String boardId, - @Path("cardId") String cardId, - @Path("checklistId") String checklistId, - @Path("itemId") String itemId, - @Body TestBody isFinished - ); } diff --git a/wrapper/src/main/java/wekan/wrapper/entity/TestBody.java b/wrapper/src/main/java/wekan/wrapper/entity/ChecklistItemStatus.java similarity index 55% rename from wrapper/src/main/java/wekan/wrapper/entity/TestBody.java rename to wrapper/src/main/java/wekan/wrapper/entity/ChecklistItemStatus.java index c403f1c..f7f9cdb 100644 --- a/wrapper/src/main/java/wekan/wrapper/entity/TestBody.java +++ b/wrapper/src/main/java/wekan/wrapper/entity/ChecklistItemStatus.java @@ -1,9 +1,9 @@ package wekan.wrapper.entity; -public class TestBody { +public class ChecklistItemStatus { private boolean isFinished; - public TestBody(boolean isFinished) { + public ChecklistItemStatus(boolean isFinished) { this.isFinished = isFinished; } } diff --git a/wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java b/wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java index a6ee073..99d9784 100644 --- a/wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java +++ b/wrapper/src/test/java/wekan/wrapper/api/ChecklistServiceTest.java @@ -229,7 +229,7 @@ public class ChecklistServiceTest { "card id", "checklist id", "item id", - true + new ChecklistItemStatus(true) ) .execute().body(); -- 2.45.2