Permalink
Browse files

covering all api methods

  • Loading branch information...
1 parent d5547ad commit a3356828a8e8dccdfce5bef26bf78354d73251f4 @oleriesenberg committed Jul 8, 2009
Showing with 30 additions and 7 deletions.
  1. +6 −2 History.txt
  2. +1 −1 lib/bitly-api.rb
  3. +23 −4 lib/bitly-api/bitly-api.rb
View
@@ -1,4 +1,8 @@
+== 0.1.0 2009-07-07
+
+* Covering all api methods
+
+
== 0.0.1 2009-07-05
-* 1 major enhancement:
- * Initial release
+* Initial release
View
@@ -8,5 +8,5 @@
require 'bitly-api/bitly-api'
module BitlyApi
- VERSION = '0.0.1'
+ VERSION = '0.1.0'
end
View
@@ -20,16 +20,35 @@ def shorten(long_url)
http_response = open(build_url("shorten", "longUrl=#{long_url}")).read
data = JSON.parse(http_response)
raise BitlyError.new(data["errorMessage"]) unless data["statusCode"] == "OK"
- results = data["results"][long_url]
- results
+ data["results"][long_url]
end
def expand(short_url)
http_response = open(build_url("expand", "shortUrl=#{short_url}")).read
data = JSON.parse(http_response)
raise BitlyError.new(data["errorMessage"]) unless data["statusCode"] == "OK"
- results = data["results"][short_url]
- results
+ data["results"][short_url]
+ end
+
+ def info(short_url)
+ http_response = open(build_url("info", "shortUrl=#{short_url}")).read
+ data = JSON.parse(http_response)
+ raise BitlyError.new(data["errorMessage"]) unless data["statusCode"] == "OK"
+ data["results"][short_url.split(/\//)[-1]]
+ end
+
+ def stats(short_url)
+ http_response = open(build_url("stats", "shortUrl=#{short_url}")).read
+ data = JSON.parse(http_response)
+ raise BitlyError.new(data["errorMessage"]) unless data["statusCode"] == "OK"
+ data["results"]
+ end
+
+ def errors
+ http_response = open("http://api.bit.ly/errors?version=#{api_version}&login=#{login}&apiKey=#{api_key}").read
+ data = JSON.parse(http_response)
+ raise BitlyError.new(data["errorMessage"]) unless data["statusCode"] == "OK"
+ data["results"]
end
private

0 comments on commit a335682

Please sign in to comment.