Skip to content

Commit

Permalink
Remove more deprecated methods
Browse files Browse the repository at this point in the history
* Twitter::API#accept
* Twitter::API#deny
* Twitter::API#related_results
* Twitter::API#recommendations
  • Loading branch information
sferik committed Sep 17, 2012
1 parent ffebee6 commit e4bcec1
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 189 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Here are some fun facts about the 3.0 release:

* The entire library is implemented in just 2,000 lines of code
* With over 5,000 lines of specs, the spec-to-code ratio is over 2.5:1
* The spec suite contains 644 examples and runs in under 2 seconds on a MacBook
* The spec suite contains 634 examples and runs in under 2 seconds on a MacBook
* This project has 100% C0 code coverage (the tests execute every line of
source code at least once)
* At the time of release, this library is comprehensive: you can request all
Expand Down
85 changes: 0 additions & 85 deletions lib/twitter/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -567,42 +567,6 @@ def friendship_update(user, options={})
object_from_response(Twitter::Relationship, :post, "/1.1/friendships/update.json", options)
end

# Allows the authenticating user to accept the specified users' follow requests
#
# @note Undocumented
# @rate_limited No
# @authentication_required Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::User>] The accepted users.
# @overload accept(*users)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @example Accept @sferik's follow request
# Twitter.accept('sferik')
# @overload accept(*users, options)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @param options [Hash] A customizable set of options.
def accept(*args)
threaded_users_from_response(:post, "/1.1/friendships/accept.json", args)
end

# Allows the authenticating user to deny the specified users' follow requests
#
# @note Undocumented
# @rate_limited No
# @authentication_required Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::User>] The denied users.
# @overload deny(*users)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @example Deny @sferik's follow request
# Twitter.deny('sferik')
# @overload deny(*users, options)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @param options [Hash] A customizable set of options.
def deny(*args)
threaded_users_from_response(:post, "/1.1/friendships/deny.json", args)
end

# Search for places that can be attached to a {Twitter::API::Statuses#update}
#
# @see https://dev.twitter.com/docs/api/1.1/get/geo/search
Expand Down Expand Up @@ -1750,24 +1714,6 @@ def statuses(*args)
threaded_tweets_from_response(:get, "/1.1/statuses/show", args)
end

# Returns tweets related to a given Tweet
#
# @note {https://dev.twitter.com/discussions/293 Undocumented}
# @rate_limited Yes
# @authentication_required Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::Tweet>]
# @param id [Integer] A Tweet ID.
# @param options [Hash] A customizable set of options.
# @example Returns tweets related to the Tweet with the ID 25938088801
# Twitter.related_results(25938088801)
def related_results(id, options={})
array = get("/1.1/related_results/show/#{id}.json")[:body][0][:results].select{|result| result[:kind].capitalize == "Tweet"}.map{|result| result[:value]}
collection_from_array(Twitter::Tweet, array)
end
alias related_statuses related_results
alias related_tweets related_results

# Returns activity summary for a Tweet
#
# @note Undocumented
Expand Down Expand Up @@ -2269,37 +2215,6 @@ def contributors(*args)
users_from_response(:get, "/1.1/users/contributors.json", args)
end

# Returns recommended users for the authenticated user
#
# @note {https://dev.twitter.com/discussions/1120 Undocumented}
# @rate_limited Yes
# @authentication_required Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::User>]
# @overload recommendations(options={})
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :limit (20) Specifies the number of records to retrieve.
# @option options [String] :excluded Comma-separated list of user IDs to exclude.
# @example Return recommended users for the authenticated user
# Twitter.recommendations
# @overload recommendations(user, options={})
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :limit (20) Specifies the number of records to retrieve.
# @option options [String] :excluded Comma-separated list of user IDs to exclude.
# @example Return recommended users for the authenticated user
# Twitter.recommendations("sferik")
def recommendations(*args)
options = args.extract_options!
options.merge_user!(args.pop || screen_name)
options[:excluded] = options[:excluded].join(',') if options[:excluded].is_a?(Array)
response = get("/1.1/users/recommendations.json", options)
response[:body].map do |recommendation|
Twitter::User.fetch_or_new(recommendation[:user])
end
end

# @note Undocumented
# @rate_limited Yes
# @authentication_required Requires user context
Expand Down
40 changes: 0 additions & 40 deletions spec/twitter/api/friendships_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -564,44 +564,4 @@
end
end

describe "#accept" do
before do
stub_post("/1.1/friendships/accept.json").
with(:body => {:screen_name => "sferik"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.accept("sferik")
a_post("/1.1/friendships/accept.json").
with(:body => {:screen_name => "sferik"}).
should have_been_made
end
it "returns an array of accepted users" do
users = @client.accept("sferik")
users.should be_an Array
users.first.should be_a Twitter::User
users.first.id.should eq 7505382
end
end

describe "#deny" do
before do
stub_post("/1.1/friendships/deny.json").
with(:body => {:screen_name => "sferik"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.deny("sferik")
a_post("/1.1/friendships/deny.json").
with(:body => {:screen_name => "sferik"}).
should have_been_made
end
it "returns an array of denied users" do
users = @client.deny("sferik")
users.should be_an Array
users.first.should be_a Twitter::User
users.first.id.should eq 7505382
end
end

end
18 changes: 0 additions & 18 deletions spec/twitter/api/statuses_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,24 +398,6 @@
end
end

describe "#related_results" do
before do
stub_get("/1.1/related_results/show/233338791128096768.json").
to_return(:body => fixture("related_results.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.related_results(233338791128096768)
a_get("/1.1/related_results/show/233338791128096768.json").
should have_been_made
end
it "returns Tweets related to a given tweet" do
tweets = @client.related_results(233338791128096768)
tweets.should be_an Array
tweets.last.should be_a Twitter::Tweet
tweets.last.text.should eq "@sferik @al3x @eurucamp awesome, let's grab beers &amp; kebabs :)"
end
end

describe "#status_activity" do
before do
stub_get("/i/statuses/25938088801/activity/summary.json").
Expand Down
45 changes: 0 additions & 45 deletions spec/twitter/api/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -371,51 +371,6 @@
end
end

describe "#recommendations" do
context "with a screen name passed" do
before do
stub_get("/1.1/users/recommendations.json").
with(:query => {:screen_name => "sferik"}).
to_return(:body => fixture("recommendations.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.recommendations("sferik")
a_get("/1.1/users/recommendations.json").
with(:query => {:screen_name => "sferik"}).
should have_been_made
end
it "returns recommended users for the authenticated user" do
recommendations = @client.recommendations("sferik")
recommendations.should be_an Array
recommendations.first.should be_a Twitter::User
recommendations.first.name.should eq "John Trupiano"
end
end
context "without arguments passed" do
before do
stub_get("/1.1/account/verify_credentials.json").
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
stub_get("/1.1/users/recommendations.json").
with(:query => {:screen_name => "sferik"}).
to_return(:body => fixture("recommendations.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.recommendations
a_get("/1.1/account/verify_credentials.json").
should have_been_made
a_get("/1.1/users/recommendations.json").
with(:query => {:screen_name => "sferik"}).
should have_been_made
end
it "returns recommended users for the authenticated user" do
recommendations = @client.recommendations
recommendations.should be_an Array
recommendations.first.should be_a Twitter::User
recommendations.first.name.should eq "John Trupiano"
end
end
end

describe "#following_followers_of" do
context "with a screen_name passed" do
before do
Expand Down

0 comments on commit e4bcec1

Please sign in to comment.