Class: Shortly::Clients::Snim
- Inherits:
-
Shortly::Client
- Object
- Shortly::Client
- Shortly::Clients::Snim
- Defined in:
- lib/shortly/clients/snim.rb
Class Attribute Summary collapse
-
.apiKey ⇒ Object
login = “<your login>” apiKey = “<your apiKey>”.
-
.login ⇒ Object
login = “<your login>” apiKey = “<your apiKey>”.
Class Method Summary collapse
-
.analytics(short_id, options = {}) ⇒ Object
gets analytics.
-
.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.
Methods inherited from Shortly::Client
Class Attribute Details
.apiKey ⇒ Object
login = “<your login>” apiKey = “<your apiKey>”
33 34 35 |
# File 'lib/shortly/clients/snim.rb', line 33 def apiKey @apiKey end |
.login ⇒ Object
login = “<your login>” apiKey = “<your apiKey>”
33 34 35 |
# File 'lib/shortly/clients/snim.rb', line 33 def login @login end |
Class Method Details
.analytics(short_id, options = {}) ⇒ Object
gets analytics
53 54 55 56 57 58 |
# File 'lib/shortly/clients/snim.rb', line 53 def self.analytics(short_id, = {}) = {:snipapi => self.apiKey,:snipuser => self.login, :snipid => short_id}.merge() validate!() response = post("/getsnipdetails", post_params()) OpenStruct.new(unescape_url(response)["snip"]) end |
.expand(short_url, options = {}) ⇒ Object
expands provided url by making call to bitly api with given options.
48 49 50 |
# File 'lib/shortly/clients/snim.rb', line 48 def self.(short_url, = {}) analytics(short_url.gsub('http://sn.im/', ''), ) 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/snim.rb', line 39 def self.shorten(url, = {}) validate_uri!(url) = {:snipapi => self.apiKey,:snipuser => self.login, :sniplink => url}.merge() validate!() response = post("/getsnip", post_params()) OpenStruct.new(response["snip"].merge(:shortUrl => response["snip"]["id"])) end |