8000 use version 3 by default and provide option to change version · browserstack/ruby-browserstack@df9e1ad · GitHub
[go: up one dir, main page]

Skip to content

Commit df9e1ad

Browse files
committed
use version 3 by default and provide option to change version
1 parent 94fb213 commit df9e1ad

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/browserstack/client.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
module Browserstack
22
HOSTNAME = "api.browserstack.com"
33
class Client
4-
attr_reader :browsers, :version
4+
attr_reader :browsers
5+
attr_accessor :version, :home
6+
alias_method :api_version, :version
7+
alias_method "api_version=", "version="
58

69
def initialize(params)
710
params ||= {}
811

12+
#File.read(`$HOME/browserstack.yml`)
913
raise ArgumentError, "Username is required" unless params[:username]
1014
raise ArgumentError, "Password is required" unless params[:password]
1115

1216
@authentication = "Basic " + Base64.encode64("#{params[:username]}:#{params[:password]}").strip
1317

14-
@version = 2
18+
validate_version(version) if version = params[:api_version] || params[:version]
19+
@version = version || 3
1520
end
1621

1722
def get_browsers(os = nil)
@@ -95,5 +100,9 @@ def update_cache?
95100
def return_with_os(os)
96101
os ? @browsers[os.to_sym] : @browsers
97102
end
103+
104+
def validate_version(version)
105+
raise "Invalid Version" unless ["1", "2", "3"].include?(version.to_s)
106+
end
98107
end
99108
end

0 commit comments

Comments
 (0)
0