Class: Shortly::Clients::ShortSwitch

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

Class Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Shortly::Client

method_missing

Class Attribute Details

.apiKeyObject

Returns the value of attribute apiKey.



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

def apiKey
  @apiKey
end

Class Method Details

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

shorts provided url by making call to is.gd api with given options.



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

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