Class: Shortly::Clients::Bitly

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

Direct Known Subclasses

Jmp

Class Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Shortly::Client

method_missing

Class Attribute Details

.apiKeyObject

apiKey = “<your apiKey>” login = “<your login>”



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

def apiKey
  @apiKey
end

.loginObject

apiKey = “<your apiKey>” login = “<your login>”



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

def 
  @login
end

Class Method Details

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

expands provided url by making call to bitly api with given options.



48
49
50
51
52
53
54
# File 'lib/shortly/clients/bitly.rb', line 48

def self.expand(short_url, options = {})
  validate_uri!(short_url)
  options = {:login => self., :apiKey => self.apiKey, :shortUrl => short_url, :format => "json"}.merge(options)
  validate!(options) 
  response = get("/v3/expand", get_params(options))
  OpenStruct.new(response["data"]["expand"].first)
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/bitly.rb', line 39

def self.shorten(url, options = {})
  validate_uri!(url)
  options = {:login => self., :apiKey => self.apiKey,:longUrl => url, :format => "json"}.merge(options)
  validate!(options)
  response = get("/v3/shorten", get_params(options))
  OpenStruct.new(response["data"])
end

.validate(options = {}) ⇒ Object

validates given login(as x_login) and apiKey (as x_api_key) options = => xlogin, :x_api_key => x_api_key, :apiKey => apiKey, :login => login, :format => “json”



58
59
60
61
# File 'lib/shortly/clients/bitly.rb', line 58

def self.validate(options = {})
  response = get("/v3/validate", get_params(options))
  OpenStruct.new(response["data"])
end