Module: Googl

Includes:
HTTParty
Defined in:
lib/services/googl.rb

Constant Summary collapse

API_URL =
'https://www.googleapis.com/urlshortener/v1/url'

Class Method Summary collapse

Class Method Details

.encode(url) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/services/googl.rb', line 9

def self.encode(url)
  change_header 
  options = {"longUrl" => url}.inspect
  resp = self.post(API_URL, :body => options)
  if resp.code == 200
    resp['id']
  else
    resp.response
  end
end