Class: ShortURL::Services::Bitly

Inherits:
ShortURL::Service show all
Defined in:
lib/shorturl/services/bitly.rb

Instance Attribute Summary

Attributes inherited from ShortURL::Service

#action, #block, #code, #field, #method, #port, #response_block, #ssl

Instance Method Summary collapse

Methods inherited from ShortURL::Service

#call, #on_response

Constructor Details

#initializeBitly

Returns a new instance of Bitly.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/shorturl/services/bitly.rb', line 7

def initialize
  super("api-ssl.bitly.com")

  @method = :get
  @port = 443
  @ssl = true
  @action = "/v3/shorten/"

  creds = ShortURL.credentials_for('bitly')
  username = creds['username'] 
  key = creds['key'] 

  @field = "format=txt&login=#{username}&apiKey=#{key}&longUrl"
end

Instance Method Details

#on_body(body) ⇒ Object



22
23
24
# File 'lib/shorturl/services/bitly.rb', line 22

def on_body(body)
  body
end