Class: Mush::Services::Bitly
- Inherits:
-
AuthenticatedService
- Object
- Mush::Service
- AuthenticatedService
- Mush::Services::Bitly
- Defined in:
- lib/mush/services/bitly.rb
Overview
bit.ly and j.mp login=bitlyapidemo apiKey=R_0da49e0a9118ff35f52f629d2d71bf07 longUrl=http%3A%2F%2Fbetaworks.com%2F format=json domain=j.mp
Instance Attribute Summary
Attributes inherited from AuthenticatedService
Instance Method Summary collapse
Methods inherited from AuthenticatedService
Methods inherited from Mush::Service
Constructor Details
This class inherits a constructor from Mush::AuthenticatedService
Instance Method Details
#shorten(url) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mush/services/bitly.rb', line 15 def shorten(url) invalid_uri_msg = "Please provide a valid URI, including http://" invalid_auth_msg = "Invalid Authorization Data, please provide both login and apikey" raise InvalidURI.new invalid_uri_msg if url.empty? raise InvalidAuthorizationData.new(invalid_auth_msg) if login.empty? or apikey.empty? = {} [:query] = {:login => self.login, :apiKey => self.apikey, :longUrl => url} response = get('/shorten', ) response["status_code"] == 200 ? response["data"]["url"].chomp : response["status_txt"] end |