Skip to content

Commit b09f3d4

Browse files
authored
Merge pull request #152 from ryanhertz/unread-messages
added unread and unread_count methods to Message
2 parents 7851212 + 8f4427c commit b09f3d4

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v1.4.26
2+
- added `unread` and `unread_count` methods to `Message`
3+
14
v1.4.25
25
- add request_id reader to error and response classes
36
- log request_id on successful requests (debug level)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.25
1+
1.4.26

lib/spark_api/models/message.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ def replies(args = {})
2525
Message.collect(connection.get("#{self.class.path}/#{self.Id}/replies", arguments))
2626
end
2727

28+
def self.unread(args={})
29+
collect(connection.get("#{path}/unread", args))
30+
end
31+
32+
def self.unread_count
33+
unread _pagination: 'count'
34+
end
35+
2836
end
2937
end
3038
end

spec/fixtures/messages/count.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"D": {
3+
"Success": true,
4+
"Results": [],
5+
"Pagination": {
6+
"TotalRows": 78,
7+
"PageSize": 25,
8+
"TotalPages": 4,
9+
"CurrentPage": 1
10+
}
11+
}
12+
}

spec/unit/spark_api/models/message_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,20 @@
6262

6363
end
6464

65+
context "/messages/unread", :support do
66+
67+
on_get_it "gets unread messages" do
68+
stub_api_get("/messages/unread", 'messages/get.json', {})
69+
messages = Message.unread
70+
messages.size.should == 2
71+
messages.first.should be_a Message
72+
end
73+
74+
on_get_it "gets unread messages count" do
75+
stub_api_get("/messages/unread", 'messages/count.json', _pagination: 'count')
76+
Message.unread_count.should == 78
77+
end
78+
79+
end
80+
6581
end

0 commit comments

Comments
 (0)