class Shortly::Clients::Bitly
Attributes
apiKey[RW]
apiKey = “<your apiKey>” login = “<your login>”
login[RW]
apiKey = “<your apiKey>” login = “<your login>”
Public Class Methods
expand(short_url, options = {})
click to toggle source
expands provided url by making call to bitly api with given options.
# File lib/shortly/clients/bitly.rb, line 48 def self.expand(short_url, options = {}) validate_uri!(short_url) options = {:login => self.login, :apiKey => self.apiKey, :shortUrl => short_url, :format => "json"}.merge(options) validate!(options) response = get("/v3/expand", get_params(options)) OpenStruct.new(response["data"]["expand"].first) end
shorten(url, options = {})
click to toggle source
shorts provided url by making call to bitly api with given options.
# File lib/shortly/clients/bitly.rb, line 39 def self.shorten(url, options = {}) validate_uri!(url) options = {:login => self.login, :apiKey => self.apiKey,:longUrl => url, :format => "json"}.merge(options) validate!(options) response = get("/v3/shorten", get_params(options)) OpenStruct.new(response["data"]) end
validate(options = {})
click to toggle source
validates given login(as x_login) and apiKey (as x_api_key) options = {:x_login => xlogin, :x_api_key => x_api_key, :apiKey => apiKey, :login => login, :format => “json”}
# File lib/shortly/clients/bitly.rb, line 58 def self.validate(options = {}) response = get("/v3/validate", get_params(options)) OpenStruct.new(response["data"]) end
Private Class Methods
validate!(options)
click to toggle source
# File lib/shortly/clients/bitly.rb, line 65 def self.validate!(options) raise NotAuthorizedError.new("Credentials required(login and apiKey)") unless options.authenticable?(:login, :apiKey) end