-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Twitter | ||
class Client | ||
# Defines methods related to URLs | ||
module Urls | ||
# Returns the canonical version of a URL shortened by Twitter | ||
# | ||
# @note Undocumented | ||
# @rate_limited Yes | ||
# @requires_authentication Yes | ||
# @response_format `json` | ||
# @param urls [String] A list of shortened URLs | ||
# @param options [Hash] A customizable set of options. | ||
# @return [Hashie::Mash] A hash of URLs with the shortened URLs as the key | ||
# @example Return the canonical version of a URL shortened by Twitter | ||
# Twitter.resolve('http://t.co/uw5bn1w', 'http://t.co/dXvMz9i') | ||
# Twitter.resolve(['http://t.co/uw5bn1w', 'http://t.co/dXvMz9i']) # Same as above | ||
def resolve(*args) | ||
options = args.last.is_a?(Hash) ? args.pop : {} | ||
get("urls/resolve", options.merge("urls[]" => args), :json) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"http:\/\/t.co\/uw5bn1w":"http:\/\/www.jeanniejeannie.com\/2011\/08\/29\/the-art-of-clean-up-sorting-and-stacking-everyday-objects\/"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'helper' | ||
|
||
describe Twitter::Client do | ||
context ".new" do | ||
before do | ||
@client = Twitter::Client.new | ||
end | ||
|
||
describe ".resolve" do | ||
|
||
before do | ||
stub_get("urls/resolve.json"). | ||
with(:query => {:urls => ["http://t.co/uw5bn1w"]}). | ||
to_return(:body => fixture("resolve.json"), :headers => {:content_type => "application/json; charset=utf-8"}) | ||
end | ||
|
||
it "should get the correct resource" do | ||
@client.resolve('http://t.co/uw5bn1w') | ||
a_get("urls/resolve.json"). | ||
with(:query => {:urls => ["http://t.co/uw5bn1w"]}). | ||
should have_been_made | ||
end | ||
|
||
it "should return the canonical version of a URL shortened by Twitter" do | ||
resolve = @client.resolve('http://t.co/uw5bn1w') | ||
resolve.should be_a Hash | ||
resolve["http://t.co/uw5bn1w"].should == "http://www.jeanniejeannie.com/2011/08/29/the-art-of-clean-up-sorting-and-stacking-everyday-objects/" | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters