From 572f2bdf93041e9f30900765d253fbd195e8d2f9 Mon Sep 17 00:00:00 2001 From: Luka Bracanovic Date: Tue, 20 May 2014 12:17:11 +0200 Subject: [PATCH 1/3] Notifications modified; Conversation modified; --- .../com/podio/conversation/Conversation.java | 17 +++++ .../podio/conversation/ConversationAPI.java | 8 +++ .../com/podio/notification/Notification.java | 34 ++++++++++ .../podio/notification/NotificationAPI.java | 25 ++++--- .../notification/NotificationContext.java | 22 +++++++ .../podio/notification/NotificationData.java | 60 +++++++++++++++++ .../podio/notification/NotificationMini.java | 65 +++++++++++++++++++ .../podio/notification/NotificationRef.java | 38 +++++++++++ .../java/com/podio/status/StatusQuestion.java | 22 +++++++ src/main/java/com/podio/task/TaskAPI.java | 9 +++ 10 files changed, 292 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/podio/notification/Notification.java create mode 100644 src/main/java/com/podio/notification/NotificationContext.java create mode 100644 src/main/java/com/podio/notification/NotificationData.java create mode 100644 src/main/java/com/podio/notification/NotificationMini.java create mode 100644 src/main/java/com/podio/notification/NotificationRef.java create mode 100644 src/main/java/com/podio/status/StatusQuestion.java diff --git a/src/main/java/com/podio/conversation/Conversation.java b/src/main/java/com/podio/conversation/Conversation.java index bf5e262..88d8e7a 100644 --- a/src/main/java/com/podio/conversation/Conversation.java +++ b/src/main/java/com/podio/conversation/Conversation.java @@ -23,6 +23,16 @@ public class Conversation { */ private List participants; + private int unreadCount; + private String excerpt; + @JsonProperty("unread_count") + public int getUnreadCount() { + return unreadCount; + } + public String getExcerpt() { + return excerpt; + } + @JsonProperty("conversation_id") public int getId() { return id; @@ -32,6 +42,13 @@ public int getId() { public void setId(int id) { this.id = id; } + @JsonProperty("unread_count") + public void setUnreadCount(int unreadCount) { + this.unreadCount = unreadCount; + } + public void setExcerpt(String excerpt) { + this.excerpt =excerpt; + } public String getSubject() { return subject; diff --git a/src/main/java/com/podio/conversation/ConversationAPI.java b/src/main/java/com/podio/conversation/ConversationAPI.java index 1b0a6ec..f1609a0 100644 --- a/src/main/java/com/podio/conversation/ConversationAPI.java +++ b/src/main/java/com/podio/conversation/ConversationAPI.java @@ -94,6 +94,14 @@ public List getConversationsOnObject(Reference object) { }); } + + public List getConversations() { + WebResource resource = getResourceFactory().getApiResource( + "/conversation/"); + resource=resource.queryParam("limit","15"); + return resource.get(new GenericType>() {}); + } + /** * Creates a reply to the conversation. * diff --git a/src/main/java/com/podio/notification/Notification.java b/src/main/java/com/podio/notification/Notification.java new file mode 100644 index 0000000..6a233d9 --- /dev/null +++ b/src/main/java/com/podio/notification/Notification.java @@ -0,0 +1,34 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package com.podio.notification; + +import java.util.List; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Direktor + */ +public class Notification { + private List nots; + private NotificationContext context; + @JsonProperty("notifications") + public List getNotifications(){ + return this.nots; + } + public NotificationContext getContext(){ + return this.context; + } + public void setContext(NotificationContext context){ + this.context=context; + } + + @JsonProperty("notifications") + public void setNotifications(List nots){ + this.nots=nots; + } +} diff --git a/src/main/java/com/podio/notification/NotificationAPI.java b/src/main/java/com/podio/notification/NotificationAPI.java index cd0e880..24061df 100644 --- a/src/main/java/com/podio/notification/NotificationAPI.java +++ b/src/main/java/com/podio/notification/NotificationAPI.java @@ -1,19 +1,21 @@ package com.podio.notification; -import java.util.Collection; -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import org.joda.time.DateTime; - import com.podio.BaseAPI; import com.podio.ResourceFactory; import com.podio.common.CSVUtil; import com.podio.common.Empty; +import com.podio.conversation.Conversation; import com.podio.serialize.DateTimeUtil; import com.sun.jersey.api.client.GenericType; import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.core.util.MultivaluedMapImpl; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import org.joda.time.DateTime; /** * A notification is an information about an event that occured in Podio. A @@ -38,7 +40,14 @@ public int getInboxNewCount() { return resource.get(InboxNewCount.class).getNewNotifications(); } - + public List getUnviewedNotifications(MultivaluedMap filters) { + WebResource resource = getResourceFactory().getApiResource( + "/notification/"); +// MultivaluedMap filters=new MultivaluedMap(); + resource=resource.queryParams(filters); + return resource.get(new GenericType>() { + }); + } /** * Mark the notification as viewed. This will move the notification from the * inbox to the viewed archive. diff --git a/src/main/java/com/podio/notification/NotificationContext.java b/src/main/java/com/podio/notification/NotificationContext.java new file mode 100644 index 0000000..5905d25 --- /dev/null +++ b/src/main/java/com/podio/notification/NotificationContext.java @@ -0,0 +1,22 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package com.podio.notification; + +/** + * + * @author Direktor + */ +public class NotificationContext { + private String link; + public String getLink(){ + return this.link; + } + public void setLink(String link){ + this.link=link; + } + +} diff --git a/src/main/java/com/podio/notification/NotificationData.java b/src/main/java/com/podio/notification/NotificationData.java new file mode 100644 index 0000000..2f05cef --- /dev/null +++ b/src/main/java/com/podio/notification/NotificationData.java @@ -0,0 +1,60 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package com.podio.notification; + +import com.podio.status.StatusQuestion; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author MrBr + */ +public class NotificationData { + private String value; + private String text; + private String type; + private StatusQuestion questionOption; + public void setValue(String value){ + this.value=value; + } + public String getValue(){ + return this.value; + } + public void setText(String text){ + this.text=text; + } + public String getText(){ + return this.text; + } + public void setType(String type){ + this.type=type; + } + public String getType(){ + return this.type; + } + @JsonProperty("question_option") + public void setQuestionOption(StatusQuestion questionOption){ + this.questionOption=questionOption; + } + @JsonProperty("question_option") + public StatusQuestion getQuestionOption(){ + return this.questionOption; + } + public String getInfoText(){ + if("like".equals(type)){ + return "Liked"; + }else if(value!=null){ + return value; + }else if(text!=null){ + return text; + }else if(questionOption!=null){ + return questionOption.getText(); + }else{ + return ""; + } + } +} diff --git a/src/main/java/com/podio/notification/NotificationMini.java b/src/main/java/com/podio/notification/NotificationMini.java new file mode 100644 index 0000000..5bb8e65 --- /dev/null +++ b/src/main/java/com/podio/notification/NotificationMini.java @@ -0,0 +1,65 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package com.podio.notification; + +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author MrBr + */ +public class NotificationMini { + private int id;//notification_id + private String textShort; + private String text; + private NotificationData data; + private String viewedOn; + private Boolean starred; + @JsonProperty("notification_id") + public int getId(){ + return this.id; + } + @JsonProperty("viewed_on") + public String getViewedOn(){ + return this.viewedOn; + } + public Boolean getStarred(){ + return this.starred; + } + + public String getText(){ + return this.text; + } + public String getNotificationShortText(){ + return textShort; + } + @JsonProperty("notification_id") + public void setId(int id){ + this.id=id; + } + @JsonProperty("viewed_on") + public void setViewedOn(String viewedOn){ + this.viewedOn=viewedOn; + } + public void setStarred(Boolean starred){ + this.starred=starred; + } + + public void setText(String text){ + this.text=text; + } + @JsonProperty("text_short") + public void setNotificationShortText(String TextShort){ + textShort=TextShort; + } + public NotificationData getData(){ + return this.data; + } + public void setData(NotificationData data){ + this.data=data; + } +} diff --git a/src/main/java/com/podio/notification/NotificationRef.java b/src/main/java/com/podio/notification/NotificationRef.java new file mode 100644 index 0000000..dc89b64 --- /dev/null +++ b/src/main/java/com/podio/notification/NotificationRef.java @@ -0,0 +1,38 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package com.podio.notification; + +import com.podio.status.StatusQuestion; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author MrBr + */ +public class NotificationRef { + private int id; + private String type; + public void setValue(int id){ + this.id=id; + } + public int getValue(){ + return this.id; + } + public void setType(String type){ + this.type=type; + } + public String getType(){ + return this.type; + } + public String getInfoValue(){ + if("status".equals(type)){ + return "Liked"; + }else{ + return "UNKNOW TYPE"; + } + } +} diff --git a/src/main/java/com/podio/status/StatusQuestion.java b/src/main/java/com/podio/status/StatusQuestion.java new file mode 100644 index 0000000..fc5e66c --- /dev/null +++ b/src/main/java/com/podio/status/StatusQuestion.java @@ -0,0 +1,22 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package com.podio.status; + +/** + * + * @author Direktor + */ +public class StatusQuestion { + private String text; + public void setText(String text){ + this.text=text; + } + public String getText(){ + return this.text; + } + +} diff --git a/src/main/java/com/podio/task/TaskAPI.java b/src/main/java/com/podio/task/TaskAPI.java index 2532432..780f4ef 100644 --- a/src/main/java/com/podio/task/TaskAPI.java +++ b/src/main/java/com/podio/task/TaskAPI.java @@ -11,6 +11,7 @@ import com.podio.common.Empty; import com.podio.common.Reference; import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.WebResource; /** * Tasks are used to track what work has to be done. Tasks have the following @@ -236,4 +237,12 @@ public List getCompletedTasks() { new GenericType>() { }); } + public List getUncomletedTasks(int userId) { + WebResource resource= getResourceFactory().getApiResource("/task/"); + resource=resource.queryParam("completed", "0"); + resource=resource.queryParam("responsible", Integer.toString(userId)); + resource=resource.queryParam("limit", "25"); + return resource.get(new GenericType>() { + }); + } } From 9dbcc6e4646b0f41bb99c967c03ac370d593201f Mon Sep 17 00:00:00 2001 From: Luka Bracanovic Date: Wed, 4 Jun 2014 16:43:20 +0200 Subject: [PATCH 2/3] Init push to fork --- settings.xml | 9 +++++++++ .../java/com/podio/conversation/ConversationAPI.java | 6 ++++++ .../java/com/podio/notification/NotificationData.java | 2 +- .../java/com/podio/notification/NotificationRef.java | 3 --- 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 settings.xml diff --git a/settings.xml b/settings.xml new file mode 100644 index 0000000..c02de4d --- /dev/null +++ b/settings.xml @@ -0,0 +1,9 @@ + + ${user.home}/.m2/repository + true + false + false + \ No newline at end of file diff --git a/src/main/java/com/podio/conversation/ConversationAPI.java b/src/main/java/com/podio/conversation/ConversationAPI.java index f1609a0..4944c8c 100644 --- a/src/main/java/com/podio/conversation/ConversationAPI.java +++ b/src/main/java/com/podio/conversation/ConversationAPI.java @@ -118,4 +118,10 @@ public int addReply(int conversationId, String text) { MediaType.APPLICATION_JSON_TYPE) .get(MessageCreateResponse.class).getMessageId(); } + public void markRead(int conversationId) { + getResourceFactory() + .getApiResource("/conversation/" + conversationId + "/read") + .method("POST"); + } + } diff --git a/src/main/java/com/podio/notification/NotificationData.java b/src/main/java/com/podio/notification/NotificationData.java index 2f05cef..7db52af 100644 --- a/src/main/java/com/podio/notification/NotificationData.java +++ b/src/main/java/com/podio/notification/NotificationData.java @@ -54,7 +54,7 @@ public String getInfoText(){ }else if(questionOption!=null){ return questionOption.getText(); }else{ - return ""; + return null; } } } diff --git a/src/main/java/com/podio/notification/NotificationRef.java b/src/main/java/com/podio/notification/NotificationRef.java index dc89b64..d42439e 100644 --- a/src/main/java/com/podio/notification/NotificationRef.java +++ b/src/main/java/com/podio/notification/NotificationRef.java @@ -6,9 +6,6 @@ package com.podio.notification; -import com.podio.status.StatusQuestion; -import org.codehaus.jackson.annotate.JsonProperty; - /** * * @author MrBr From dc6b767ef3d9feadc4299625b0fed70a33130126 Mon Sep 17 00:00:00 2001 From: Luka Bracanovic Date: Wed, 4 Jun 2014 16:55:15 +0200 Subject: [PATCH 3/3] Nothing really --- src/main/java/com/podio/notification/Notification.java | 2 +- src/main/java/com/podio/notification/NotificationContext.java | 2 +- src/main/java/com/podio/status/StatusQuestion.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/podio/notification/Notification.java b/src/main/java/com/podio/notification/Notification.java index 6a233d9..7fbaff9 100644 --- a/src/main/java/com/podio/notification/Notification.java +++ b/src/main/java/com/podio/notification/Notification.java @@ -11,7 +11,7 @@ /** * - * @author Direktor + * @author MrBr */ public class Notification { private List nots; diff --git a/src/main/java/com/podio/notification/NotificationContext.java b/src/main/java/com/podio/notification/NotificationContext.java index 5905d25..5758881 100644 --- a/src/main/java/com/podio/notification/NotificationContext.java +++ b/src/main/java/com/podio/notification/NotificationContext.java @@ -8,7 +8,7 @@ /** * - * @author Direktor + * @author MrBr */ public class NotificationContext { private String link; diff --git a/src/main/java/com/podio/status/StatusQuestion.java b/src/main/java/com/podio/status/StatusQuestion.java index fc5e66c..937df14 100644 --- a/src/main/java/com/podio/status/StatusQuestion.java +++ b/src/main/java/com/podio/status/StatusQuestion.java @@ -8,7 +8,7 @@ /** * - * @author Direktor + * @author MrBr */ public class StatusQuestion { private String text;