Class: Screenshot::Client
- Inherits:
-
Object
- Object
- Screenshot::Client
- Defined in:
- lib/screenshot/client.rb
Constant Summary collapse
- API =
"http://www.browserstack.com/screenshots"
Instance Method Summary collapse
- #generate_screenshots(configHash = {}) ⇒ Object
- #get_os_and_browsers ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #screenshots(job_id) ⇒ Object
- #screenshots_done?(job_id) ⇒ Boolean
- #screenshots_status(job_id) ⇒ Object
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(={}) = symbolize_keys unless [:username] && [:password] raise "Expecting Parameters: username and password in the options Hash!" end @authentication = "Basic " + Base64.encode64("#{[:username]}:#{[: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_browsers ⇒ Object
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
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 |