Module: Bitlyr

Defined in:
lib/bitlyr.rb,
lib/bitlyr/day.rb,
lib/bitlyr/url.rb,
lib/bitlyr/user.rb,
lib/bitlyr/client.rb,
lib/bitlyr/country.rb,
lib/bitlyr/referrer.rb,
lib/bitlyr/response.rb,
lib/bitlyr/missing_url.rb,
lib/bitlyr/realtime_link.rb,
lib/bitlyr/strategy/base.rb,
lib/bitlyr/strategy/oauth.rb,
lib/bitlyr/referring_domain.rb,
lib/bitlyr/strategy/api_key.rb,
lib/bitlyr/strategy/access_token.rb

Defined Under Namespace

Modules: Strategy Classes: Client, Country, Day, MissingUrl, RealtimeLink, Referrer, ReferringDomain, Response, Url, User

Class Method Summary collapse

Class Method Details

.new(params = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bitlyr.rb', line 9

def self.new(params = {})
  params.symbolize_keys!
  if params.key?(:client_id) && params.key?(:client_secret)
    strategy = Bitlyr::Strategy::OAuth.new(params[:client_id], params[:client_secret])
    strategy.set_access_token_from_token!(params[:token]) if params[:token]
    Bitlyr::Client.new strategy
  elsif params.key?(:login) && params.key?(:api_key)
    Bitlyr::Client.new Bitlyr::Strategy::ApiKey.new(params[:login], params[:api_key])
  else
    raise "requires a login and apiKey or client id and client secret"
  end
end