Skip to content

Commit d0a019c

Browse files
committed
Merge pull request taskadapter#15 from gusehr/feature-addCommentToCard
Add comment to card
2 parents 579c0c9 + 9dceeac commit d0a019c

6 files changed

Lines changed: 88 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ If you are missing some fonctionnalities, you can easily contribute and propose
188188
| PUT /1/cards/[card id or shortlink]/subscribed
189189
| PUT /1/cards/[card id or shortlink]/warnWhenUpcoming
190190
| POST /1/cards | ![](http://icdn.pro/images/fr/v/e/verifier-vert-ok-icone-8505-48.png)
191-
| POST /1/cards/[card id or shortlink]/actions/comments
191+
| POST /1/cards/[card id or shortlink]/actions/comments | ![](http://icdn.pro/images/fr/v/e/verifier-vert-ok-icone-8505-48.png)
192192
| POST /1/cards/[card id or shortlink]/attachments
193193
| POST /1/cards/[card id or shortlink]/checklist/[idChecklist]/checkItem
194194
| POST /1/cards/[card id or shortlink]/checklist/[idChecklist]/checkItem/[idCheckItem]/convertToCard

src/main/java/com/julienvey/trello/Trello.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ List<CardWithActions> getBoardMemberActivity(String boardId, String memberId,
8282

8383
void addLabelsToCard(String idCard, String[] labels);
8484

85+
void addCommentToCard(String idCard, String comment);
86+
8587
Card updateCard(Card card);
8688

8789
//FIXME Remove this method

src/main/java/com/julienvey/trello/domain/Card.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public void addLabels(String... labels) {
3636
trelloService.addLabelsToCard(id, labels);
3737
}
3838

39+
public void addComment(String comment) {
40+
trelloService.addCommentToCard(id, comment);
41+
}
42+
3943
public List<Action> getActions(Argument... filters) {
4044
return trelloService.getCardActions(id, filters);
4145
}

src/main/java/com/julienvey/trello/impl/TrelloImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.julienvey.trello.Trello;
44
import com.julienvey.trello.TrelloHttpClient;
55
import com.julienvey.trello.domain.*;
6+
import com.julienvey.trello.impl.domaininternal.Comment;
67
import com.julienvey.trello.impl.domaininternal.Label;
78
import com.julienvey.trello.impl.http.RestTemplateHttpClient;
89
import org.slf4j.Logger;
@@ -312,12 +313,18 @@ public Member getMemberInformation(String username) {
312313
return member;
313314
}
314315

316+
@Override
315317
public void addLabelsToCard(String idCard, String[] labels) {
316318
for (String label : labels) {
317319
postForLocation(createUrl(ADD_LABEL_TO_CARD).asString(), new Label(label), idCard);
318320
}
319321
}
320322

323+
@Override
324+
public void addCommentToCard(String idCard, String comment) {
325+
postForObject(createUrl(ADD_COMMENT_TO_CARD).asString(), new Comment(comment), Comment.class, idCard);
326+
}
327+
321328
@Override
322329
public Card updateCard(Card card) {
323330
Card put = put(createUrl(UPDATE_CARD).asString(), card, Card.class, card.getId());

src/main/java/com/julienvey/trello/impl/TrelloUrl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class TrelloUrl {
4343
public static final String CREATE_CARD = "/cards?pos=top&";
4444
public static final String GET_MEMBER = "/members/{username}?";
4545
public static final String ADD_LABEL_TO_CARD = "/cards/{cardId}/labels?";
46+
public static final String ADD_COMMENT_TO_CARD = "/cards/{cardId}/actions/comments?";
4647

4748
public static final String UPDATE_CARD = "/cards/{cardId}?";
4849

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package com.julienvey.trello.impl.domaininternal;
2+
3+
import java.util.Date;
4+
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6+
import com.julienvey.trello.domain.Action.MemberShort;
7+
8+
@JsonIgnoreProperties(ignoreUnknown = true)
9+
public class Comment {
10+
private String id;
11+
private String text;
12+
private String idMemberCreator;
13+
private Date date;
14+
private MemberShort memberCreator;
15+
private MemberShort member;
16+
17+
public Comment() {
18+
}
19+
20+
public Comment(String text) {
21+
super();
22+
this.text = text;
23+
}
24+
25+
public String getId() {
26+
return id;
27+
}
28+
29+
public void setId(String id) {
30+
this.id = id;
31+
}
32+
33+
public String getText() {
34+
return text;
35+
}
36+
37+
public void setText(String text) {
38+
this.text = text;
39+
}
40+
41+
public String getIdMemberCreator() {
42+
return idMemberCreator;
43+
}
44+
45+
public void setIdMemberCreator(String idMemberCreator) {
46+
this.idMemberCreator = idMemberCreator;
47+
}
48+
49+
public Date getDate() {
50+
return date;
51+
}
52+
53+
public void setDate(Date date) {
54+
this.date = date;
55+
}
56+
57+
public MemberShort getMemberCreator() {
58+
return memberCreator;
59+
}
60+
61+
public void setMemberCreator(MemberShort memberCreator) {
62+
this.memberCreator = memberCreator;
63+
}
64+
65+
public MemberShort getMember() {
66+
return member;
67+
}
68+
69+
public void setMember(MemberShort member) {
70+
this.member = member;
71+
}
72+
73+
}

0 commit comments

Comments
 (0)