add getChecklists and postChecklist

- add class Checklist
- add class ChecklistPrototype
This commit is contained in:
Raffaele Mignone 2019-11-13 19:29:04 +01:00
parent 450c4503da
commit acd7724353
Signed by: norangebit
GPG Key ID: F5255658CB220573
3 changed files with 153 additions and 0 deletions

View File

@ -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<List<Checklist>> 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<Checklist> 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<Checklist> postChecklist(
@Path("boardId") String boardId,
@Path("cardId") String cardId,
@Body ChecklistPrototype checklistPrototype
);
}

View File

@ -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 +
'}';
}
}

View File

@ -0,0 +1,40 @@
package wekan.wrapper.entity;
import java.util.ArrayList;
import java.util.List;
public class ChecklistPrototype {
private String title;
private List<String> items;
private ChecklistPrototype(String title, List<String> items) {
this.title = title;
this.items = items;
}
public static class Builder {
private String title;
private List<String> 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;
}
}
}