Class: TeamcityRestClient::HttpBasicAuthentication

Inherits:
Authentication show all
Defined in:
lib/teamcity-rest-client.rb

Instance Method Summary collapse

Methods inherited from Authentication

#get, #query_string_for

Constructor Details

#initialize(host, port, user, password, openuri_options = {}) ⇒ HttpBasicAuthentication

Returns a new instance of HttpBasicAuthentication.



119
120
121
122
# File 'lib/teamcity-rest-client.rb', line 119

def initialize host, port, user, password, openuri_options = {}
	super({:http_basic_authentication => [user, password]}.merge(openuri_options))
  @host, @port, @user, @password = host, port, user, password
end

Instance Method Details

#to_sObject



130
131
132
# File 'lib/teamcity-rest-client.rb', line 130

def to_s
  "HttpBasicAuthentication #{@user}:#{@password}"
end

#url(path, params = {}) ⇒ Object



124
125
126
127
128
# File 'lib/teamcity-rest-client.rb', line 124

def url path, params = {}
  auth_path = path.start_with?("/httpAuth/") ? path : "/httpAuth#{path}"
  query_string = !params.empty? ? "?#{query_string_for(params)}" : ""
  "http://#{@host}:#{@port}#{auth_path}#{query_string}"
end