Class: Shortly::Clients::Bitly
- Inherits:
-
Shortly::Client
- Object
- Shortly::Client
- Shortly::Clients::Bitly
- Defined in:
- lib/shortly/clients/bitly.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.apiKey ⇒ Object
apiKey = “<your apiKey>” login = “<your login>”.
-
.login ⇒ Object
apiKey = “<your apiKey>” login = “<your login>”.
Class Method Summary collapse
-
.expand(short_url, options = {}) ⇒ Object
expands provided url by making call to bitly api with given options.
-
.shorten(url, options = {}) ⇒ Object
shorts provided url by making call to bitly api with given options.
-
.validate(options = {}) ⇒ Object
validates given login(as x_login) and apiKey (as x_api_key) options = => xlogin, :x_api_key => x_api_key, :apiKey => apiKey, :login => login, :format => “json”.
Methods inherited from Shortly::Client
Class Attribute Details
.apiKey ⇒ Object
apiKey = “<your apiKey>” login = “<your login>”
33 34 35 |
# File 'lib/shortly/clients/bitly.rb', line 33 def apiKey @apiKey end |
.login ⇒ Object
apiKey = “<your apiKey>” login = “<your login>”
33 34 35 |
# File 'lib/shortly/clients/bitly.rb', line 33 def login @login end |
Class Method Details
.expand(short_url, options = {}) ⇒ Object
expands provided url by making call to bitly api with given options.
48 49 50 51 52 53 54 |
# File 'lib/shortly/clients/bitly.rb', line 48 def self.(short_url, = {}) validate_uri!(short_url) = {:login => self.login, :apiKey => self.apiKey, :shortUrl => short_url, :format => "json"}.merge() validate!() response = get("/v3/expand", get_params()) OpenStruct.new(response["data"]["expand"].first) end |
.shorten(url, options = {}) ⇒ Object
shorts provided url by making call to bitly api with given options.
39 40 41 42 43 44 45 |
# File 'lib/shortly/clients/bitly.rb', line 39 def self.shorten(url, = {}) validate_uri!(url) = {:login => self.login, :apiKey => self.apiKey,:longUrl => url, :format => "json"}.merge() validate!() response = get("/v3/shorten", get_params()) OpenStruct.new(response["data"]) end |
.validate(options = {}) ⇒ Object
validates given login(as x_login) and apiKey (as x_api_key) options = => xlogin, :x_api_key => x_api_key, :apiKey => apiKey, :login => login, :format => “json”
58 59 60 61 |
# File 'lib/shortly/clients/bitly.rb', line 58 def self.validate( = {}) response = get("/v3/validate", get_params()) OpenStruct.new(response["data"]) end |