Class: ScreenshotsCloud

Inherits:
Object
  • Object
show all
Defined in:
lib/screenshotscloud.rb

Instance Method Summary collapse

Constructor Details

#initialize(apiKey, apiSecret) ⇒ ScreenshotsCloud

Returns a new instance of ScreenshotsCloud.


5
6
7
8
# File 'lib/screenshotscloud.rb', line 5

def initialize(apiKey, apiSecret)
	  @apiKey = apiKey
	  @apiSecret = apiSecret
end

Instance Method Details

#screenshotUrl(options = {}) ⇒ Object


10
11
12
13
14
15
16
# File 'lib/screenshotscloud.rb', line 10

def screenshotUrl(options={})
  parameters = options.map {|option| option.map {|value| URI.escape(value.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) }.join('=') }.join('&')

  token = OpenSSL::HMAC.hexdigest('sha1', @apiSecret, parameters)

  "https://api.screenshots.cloud/v1/screenshot/#{@apiKey}/#{token}?#{parameters}"
end