Class: Shortly::Clients::Googl

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

Class Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Shortly::Client

method_missing

Class Attribute Details

.apiKeyObject

apiKey = “<your apiKey>”



31
32
33
# File 'lib/shortly/clients/googl.rb', line 31

def apiKey
  @apiKey
end

Class Method Details

.analytics(url, options = {}) ⇒ Object



49
50
51
52
# File 'lib/shortly/clients/googl.rb', line 49

def self.analytics(url, options ={})
  validate_uri!(url)
  info(options.merge(:shortUrl => url), true)
end

.expand(url, options = {}) ⇒ Object



44
45
46
47
# File 'lib/shortly/clients/googl.rb', line 44

def self.expand(url, options ={})
  validate_uri!(url)
  info(options.merge(:shortUrl => url))
end

.shorten(url, options = {}) ⇒ Object

shorts provided url by making call to goo.gl api with given options.



38
39
40
41
42
# File 'lib/shortly/clients/googl.rb', line 38

def self.shorten(url, options = {})
  validate_uri!(url)
  response = post(relative_path_with_key(options), post_params({:longUrl => url}.to_json))
  OpenStruct.new(response.merge(:shortUrl => response["id"]))
end