Class: UserAccount
- Inherits:
-
Object
- Object
- UserAccount
- Defined in:
- lib/user_account.rb
Instance Attribute Summary collapse
-
#access_key ⇒ Object
Returns the value of attribute access_key.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #create_worker(options) ⇒ Object
- #get_api_status ⇒ Object
- #get_browsers(options) ⇒ Object
- #get_worker_screen_shot(options) ⇒ Object
- #get_worker_status(options) ⇒ Object
-
#initialize(username, access_key) ⇒ UserAccount
constructor
A new instance of UserAccount.
Constructor Details
#initialize(username, access_key) ⇒ UserAccount
Returns a new instance of UserAccount.
4 5 6 7 8 9 10 11 |
# File 'lib/user_account.rb', line 4 def initialize username, access_key if validate_params username, access_key @username = username @access_key = access_key else raise Exception, "Invalid username/accesskey" end end |
Instance Attribute Details
#access_key ⇒ Object
Returns the value of attribute access_key.
2 3 4 |
# File 'lib/user_account.rb', line 2 def access_key @access_key end |
#username ⇒ Object
Returns the value of attribute username.
2 3 4 |
# File 'lib/user_account.rb', line 2 def username @username end |
Instance Method Details
#create_worker(options) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/user_account.rb', line 22 def create_worker require_params = %w(os os_version browser device browser_version timeout url name) optional_params = %w(build project) .reject! { |o| !require_params.include?(o) && !optional_params.include?(o) } require_params.each { |param| raise Exception, "Parameter #{param} is required." if !.include?(param) } uri = "http://api.browserstack.com/3/worker" response= post_at_browser_stack(uri, ) return JSON.parse(response.body) end |
#get_api_status ⇒ Object
53 54 55 56 57 |
# File 'lib/user_account.rb', line 53 def get_api_status uri = "http://api.browserstack.com/3/status" response = get_from_browser_stack uri return JSON.parse(response.body) end |
#get_browsers(options) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/user_account.rb', line 14 def get_browsers uri = "http://api.browserstack.com/3/browsers?" uri = uri + "flat=true" if [:flat] uri = uri + "all=true" if [:all] response = get_from_browser_stack uri return JSON.parse(response.body) end |
#get_worker_screen_shot(options) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/user_account.rb', line 32 def get_worker_screen_shot require_params =%w(format worker_id) optional_params = %w() .reject! { |o| !require_params.include?(o) && !optional_params.include?(o) } require_params.each { |param| raise Exception, "Parameter #{param} is required." if !.include?(param) } uri = "http://api.browserstack.com/3/worker/#{["worker_id"]}/screenshot.#{["format"]}" response = get_from_browser_stack uri return JSON.parse(response.body) end |
#get_worker_status(options) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/user_account.rb', line 43 def get_worker_status required_params = %w(worker_id) optional_params = [] .reject! { |o| !required_params.include?(o) && !optional_params.include?(o) } required_params.each { |param| raise Exception, "Parameter #{param} is required." if !.include?(param) } uri = "http://api.browserstack.com/3/worker/#{["worker_id"]}" response = get_from_browser_stack uri return JSON.parse(response.body) end |