Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds POST /messages/mark endpoint #28

Open
wants to merge 1 commit 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
14 changes: 14 additions & 0 deletions lib/angellist_api/client/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions spec/integration/messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might want additional tests to test for:

  • Threads don't exist
  • Invalid permission (ie don't have the messages scope)

read_messages.should include(1, 2, 3)
end
end

10 changes: 9 additions & 1 deletion spec/unit/lib/angellist_api/client/messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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