diff --git a/lib/angellist_api/client/messages.rb b/lib/angellist_api/client/messages.rb index f2c5363..a6e30c9 100644 --- a/lib/angellist_api/client/messages.rb +++ b/lib/angellist_api/client/messages.rb @@ -41,6 +41,20 @@ def get_messages(options={}) def post_messages(options={}) post("1/messages", options) end + + # Marks all messages for the current user in the given thread_ids as viewed. + # Returns an array of all affected thread_ids on success. Requires scope "message". + # + # @requires_authentication Yes + # + # @param ids [Array] IDs of the startups to fetch. + # + # @example Mark threads 1, 2, and 3 as read for the current user. + # AngellistApi.post_mark_messages([1, 2, 3]) + def post_mark_messages(thread_ids) + params = { :ids => thread_ids.join(',') } + post("1/messages/mark", params) + end end end end diff --git a/spec/integration/messages_spec.rb b/spec/integration/messages_spec.rb index fc2ff36..2f7e3c6 100644 --- a/spec/integration/messages_spec.rb +++ b/spec/integration/messages_spec.rb @@ -15,5 +15,10 @@ thread.should have_key field end end + + it 'marks messages as read for a user' do + read_messages = client.post_mark_messages([1, 2, 3]) + read_messages.should include(1, 2, 3) + end end diff --git a/spec/unit/lib/angellist_api/client/messages_spec.rb b/spec/unit/lib/angellist_api/client/messages_spec.rb index 574b334..f82bffc 100644 --- a/spec/unit/lib/angellist_api/client/messages_spec.rb +++ b/spec/unit/lib/angellist_api/client/messages_spec.rb @@ -18,6 +18,14 @@ client.post_messages(options).should == "success" end end - + + describe "#post_mark_messages" do + it "posts to 1/messages/mark" do + options = { :some => "options" } + client.should_receive(:post).with("1/messages/mark", options).and_return("success") + client.post_mark_messages(options).should == "success" + end + end + end