Class: Screenshot::Client

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

Constant Summary collapse

API =
"http://www.browserstack.com/screenshots"

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
12
13
14
# File 'lib/screenshot/client.rb', line 6

def initialize(options={})
  options = symbolize_keys options
  unless options[:username] && options[:password]
    raise "Expecting Parameters: username and password in the options Hash!"
  end
  @authentication = "Basic " + Base64.encode64("#{options[:username]}:#{options[:password]}").strip
  #authenticate options, AUTH_URI
  self
end

Instance Method Details

#generate_screenshots(configHash = {}) ⇒ Object



21
22
23
24
25
# File 'lib/screenshot/client.rb', line 21

def generate_screenshots configHash={}
  res = http_post_request :data => Yajl::Encoder.encode(configHash)
  responseJson = parse res
  request = responseJson[:job_id]
end

#get_os_and_browsersObject



16
17
18
19
# File 'lib/screenshot/client.rb', line 16

def get_os_and_browsers
  res = http_get_request :extend_uri => "browsers.json"
  parse res
end

#screenshots(job_id) ⇒ Object



37
38
39
40
41
# File 'lib/screenshot/client.rb', line 37

def screenshots job_id
  res = http_get_request :extend_uri => "#{job_id}.json"
  responseJson = parse res
  responseJson[:screenshots]
end

#screenshots_done?(job_id) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/screenshot/client.rb', line 27

def screenshots_done? job_id
  (screenshots_status job_id) == "done" ? true : false
end

#screenshots_status(job_id) ⇒ Object



31
32
33
34
35
# File 'lib/screenshot/client.rb', line 31

def screenshots_status job_id
  res = http_get_request :extend_uri => "#{job_id}.json"
  responseJson = parse res
  responseJson[:state]
end