Class: Shortly::Clients::Snim

Inherits:
Shortly::Client show all
Defined in:
lib/shortly/clients/snim.rb

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Methods inherited from Shortly::Client

method_missing

Class Attribute Details

+ (Object) apiKey

login = "<your login>" apiKey = "<your apiKey>"



33
34
35
# File 'lib/shortly/clients/snim.rb', line 33

def apiKey
  @apiKey
end

+ (Object) login

login = "<your login>" apiKey = "<your apiKey>"



33
34
35
# File 'lib/shortly/clients/snim.rb', line 33

def 
  @login
end

Class Method Details

+ (Object) analytics(short_id, options = {})

gets analytics



53
54
55
56
57
58
# File 'lib/shortly/clients/snim.rb', line 53

def self.analytics(short_id, options = {})
  options = {:snipapi => self.apiKey,:snipuser => self., :snipid => short_id}.merge(options)
  validate!(options)
  response = post("/getsnipdetails", post_params(options))
  OpenStruct.new(unescape_url(response)["snip"])
end

+ (Object) expand(short_url, options = {})

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.expand(short_url, options = {})
  analytics(short_url.gsub('http://sn.im/', ''), options)
end

+ (Object) shorten(url, options = {})

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, options = {})
  validate_uri!(url)
  options = {:snipapi => self.apiKey,:snipuser => self., :sniplink => url}.merge(options)
  validate!(options)
  response = post("/getsnip", post_params(options))
  OpenStruct.new(response["snip"].merge(:shortUrl => response["snip"]["id"]))
end