philnash/bitly — pull request #26 by KentonWhite (2012-09-26 20:21:19+00:00)
Title: V3 API Link Class

According to the Bitly API page http://dev.bitly.com/deprecated.html most of the methods listed as accessible in the V3 api for the bitly gem are now deprecated. This includes the methods for accessing link click count.

I've created a new class Bitly::V3::Link, modeled on Bitly::V3::User, for accessing the link portion of the API (http://dev.bitly.com/link_metrics.html & http://dev.bitly.com/links.html) I've implemented one method, clicks. Clicks requires the short url and an optional hash with options detailed in the online API.

It returns the number of clicks if :rollup => true (the default) and an array of hashes { :time => time, :clicks => clicks} if :rollup => false

Usage:

link = Bitly::V3::Link.new(oauth2_token)

link.clicks(short_url, options = {})

Tests are available in test/test_link.rb

Before coding the entire API, would like to know if this addition is useful and if this is the correct approach for adding this functionality to the gem. Please let me know as I'm happy to add the rest of the link API in this manner.