Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Edits done for pTray #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this file from the PR? It shouldn't be part of the source.

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${user.home}/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<usePluginRegistry>false</usePluginRegistry>
<offline>false</offline>
</settings>
17 changes: 17 additions & 0 deletions src/main/java/com/podio/conversation/Conversation.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ public class Conversation {
*/
private List<ProfileMini> participants;

private int unreadCount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting is off here compared to the rest. You should also use spaces, not tabs.

private String excerpt;
@JsonProperty("unread_count")
public int getUnreadCount() {
return unreadCount;
}
public String getExcerpt() {
return excerpt;
}

@JsonProperty("conversation_id")
public int getId() {
return id;
Expand All @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/podio/conversation/ConversationAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ public List<Conversation> getConversationsOnObject(Reference object) {
});
}


public List<Conversation> getConversations() {
WebResource resource = getResourceFactory().getApiResource(
"/conversation/");
resource=resource.queryParam("limit","15");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This limit should at least be optional ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you should add a parameter to the method of type Integer, and add it to the resource if it is != null.

return resource.get(new GenericType<List<Conversation>>() {});
}

/**
* Creates a reply to the conversation.
*
Expand All @@ -110,4 +118,10 @@ public int addReply(int conversationId, String text) {
MediaType.APPLICATION_JSON_TYPE)
.get(MessageCreateResponse.class).getMessageId();
}
public void markRead(int conversationId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add a short javadoc and an extra line break to the method above.

getResourceFactory()
.getApiResource("/conversation/" + conversationId + "/read")
.method("POST");
}

}
34 changes: 34 additions & 0 deletions src/main/java/com/podio/notification/Notification.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you get rid of the license java doc?

* 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 MrBr
*/
public class Notification {
private List<NotificationMini> nots;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add line breaks between the methods and fields.

private NotificationContext context;
@JsonProperty("notifications")
public List<NotificationMini> getNotifications(){
return this.nots;
}
public NotificationContext getContext(){
return this.context;
}
public void setContext(NotificationContext context){
this.context=context;
}

@JsonProperty("notifications")
public void setNotifications(List<NotificationMini> nots){
this.nots=nots;
}
}
25 changes: 17 additions & 8 deletions src/main/java/com/podio/notification/NotificationAPI.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -38,7 +40,14 @@ public int getInboxNewCount() {

return resource.get(InboxNewCount.class).getNewNotifications();
}

public List<Notification> getUnviewedNotifications(MultivaluedMap<String,String> filters) {
WebResource resource = getResourceFactory().getApiResource(
"/notification/");
// MultivaluedMap<String,String> filters=new MultivaluedMap();
resource=resource.queryParams(filters);
return resource.get(new GenericType<List<Notification>>() {
});
}
/**
* Mark the notification as viewed. This will move the notification from the
* inbox to the viewed archive.
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/podio/notification/NotificationContext.java
Original file line number Diff line number Diff line change
@@ -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 MrBr
*/
public class NotificationContext {
private String link;
public String getLink(){
return this.link;
}
public void setLink(String link){
this.link=link;
}

}
60 changes: 60 additions & 0 deletions src/main/java/com/podio/notification/NotificationData.java
Original file line number Diff line number Diff line change
@@ -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(){
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this, it is useful to me for my app.

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 null;
}
}
}
65 changes: 65 additions & 0 deletions src/main/java/com/podio/notification/NotificationMini.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
35 changes: 35 additions & 0 deletions src/main/java/com/podio/notification/NotificationRef.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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 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(){
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this, was useful for my app.

if("status".equals(type)){
return "Liked";
}else{
return "UNKNOW TYPE";
}
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/podio/status/StatusQuestion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More license stuff

* 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 MrBr
*/
public class StatusQuestion {
private String text;
public void setText(String text){
this.text=text;
}
public String getText(){
return this.text;
}

}
9 changes: 9 additions & 0 deletions src/main/java/com/podio/task/TaskAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -236,4 +237,12 @@ public List<Task> getCompletedTasks() {
new GenericType<List<Task>>() {
});
}
public List<Task> getUncomletedTasks(int userId) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better create generic function ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it would be better to have a generic function. You can then add some helper functions that fill out with some default values.

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<List<Task>>() {
});
}
}