Skip to content

Commit

Permalink
Implemented no_retweets/ids for API 1.1 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbon committed Jan 26, 2013
1 parent bb5617c commit cab8d6e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ version 3 are no longer available in version 4:
* `Twitter::API#disable_notifications`
* `Twitter::API#enable_notifications`
* `Twitter::API#end_session`
* `Twitter::API#no_retweet_ids`
* `Twitter::API#rate_limit_status`
* `Twitter::API#rate_limited?`
* `Twitter::API#recommendations`
Expand Down Expand Up @@ -318,6 +317,13 @@ Twitter.friends("gem")
Twitter.friends(213747670)
Twitter.friends
```

**Fetch a collection of user_ids that the currently authenticated user does not want to receive retweets from**

```ruby
Twitter.no_retweet_ids
````

**Fetch the timeline of Tweets by a user**

```ruby
Expand Down
16 changes: 16 additions & 0 deletions lib/twitter/api/friends_and_followers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,22 @@ def friends(*args)
end
alias following friends

# Returns a collection of user_ids that the currently authenticated user does not want to receive retweets from.
# =>
# @see https://dev.twitter.com/docs/api/1.1/get/friendships/no_retweets/ids
# @rate_limited Yes
# @authentication Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Integer>]
# @param options [Hash] A customizable set of options.
# @option options [Boolean] :stringify_ids Many programming environments will not consume our ids due to their size. Provide this option to have ids returned as strings instead. Read more about Twitter IDs, JSON and Snowflake.
# @example Enable rewteets and devise notifications for @sferik
# Twitter.no_retweet_ids
def no_retweet_ids(options={})
get("/1.1/friendships/no_retweets/ids.json", options)[:body].map(&:to_i)
end
alias no_retweets_ids no_retweet_ids

end
end
end
19 changes: 19 additions & 0 deletions spec/twitter/api/friends_and_followers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -668,4 +668,23 @@
end
end

describe "#no_retweet_ids" do
before do
stub_get("/1.1/friendships/no_retweets/ids.json").to_return(:body => fixture("ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.no_retweet_ids
expect(a_get("/1.1/friendships/no_retweets/ids.json")).to have_been_made
end
it "requests the correct resource when the alias is called" do
@client.no_retweets_ids
expect(a_get("/1.1/friendships/no_retweets/ids.json")).to have_been_made
end
it "returns users ids of those that do not wish to be retweeted" do
no_retweet_ids = @client.no_retweet_ids
expect(no_retweet_ids).to be_an Array
expect(no_retweet_ids.first).to be_an Integer
expect(no_retweet_ids.first).to eq 47
end
end
end

0 comments on commit cab8d6e

Please sign in to comment.