Skip to content

Commit e586800

Browse files
authored
Add support for getting a single expanded message/thread (#84)
This PR enables support for getting a message or thread by ID with an expanded view.
1 parent 2605698 commit e586800

4 files changed

Lines changed: 39 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This section contains changes that have been committed but not yet released.
66

77
### Added
88

9+
* Add support for getting a single expanded message and thread
10+
911
### Changed
1012

1113
### Deprecated

src/main/java/com/nylas/Messages.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,26 @@ public RemoteCollection<Message> list(MessageQuery query) throws IOException, Re
2626
return super.list(query);
2727
}
2828

29+
/**
30+
* Get a single message by ID
31+
* @param id The message ID
32+
* @return The requested message
33+
*/
2934
@Override
3035
public Message get(String id) throws IOException, RequestFailedException {
36+
return get(id, false);
37+
}
38+
39+
/**
40+
* Get a single message by ID
41+
* @param id The message ID
42+
* @param expanded If true, the message will return with additional RFC2822 headers
43+
* @return The requested message
44+
*/
45+
public Message get(String id, boolean expanded) throws IOException, RequestFailedException {
46+
if(expanded) {
47+
setView(getCollectionUrl(), "expanded");
48+
}
3149
return super.get(id);
3250
}
3351

src/main/java/com/nylas/RestfulDAO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private static void setQuery(HttpUrl.Builder url, RestfulQuery<?> query) {
175175
}
176176
}
177177

178-
private static void setView(HttpUrl.Builder url, String view) {
178+
protected static void setView(HttpUrl.Builder url, String view) {
179179
url.addQueryParameter("view", view);
180180
}
181181

src/main/java/com/nylas/Threads.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,26 @@ public RemoteCollection<Thread> list(ThreadQuery query) throws IOException, Requ
2121
return super.list(query);
2222
}
2323

24+
/**
25+
* Get a single thread by ID
26+
* @param id The thread ID
27+
* @return The requested thread
28+
*/
2429
@Override
2530
public Thread get(String id) throws IOException, RequestFailedException {
31+
return get(id, false);
32+
}
33+
34+
/**
35+
* Get a single thread by ID
36+
* @param id The thread ID
37+
* @param expanded If true, the thread will return with a message and draft object as opposed to IDs
38+
* @return The requested thread
39+
*/
40+
public Thread get(String id, boolean expanded) throws IOException, RequestFailedException {
41+
if(expanded) {
42+
setView(getCollectionUrl(), "expanded");
43+
}
2644
return super.get(id);
2745
}
2846

0 commit comments

Comments
 (0)