Class: Fogbugz::Adapter::HTTP::NetHttp
- Inherits:
-
Object
- Object
- Fogbugz::Adapter::HTTP::NetHttp
- Defined in:
- lib/ruby_fogbugz/adapters/http/net_http.rb
Instance Attribute Summary collapse
-
#requester ⇒ Object
Returns the value of attribute requester.
-
#root_url ⇒ Object
Returns the value of attribute root_url.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ NetHttp
constructor
A new instance of NetHttp.
- #request(action, options) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ NetHttp
Returns a new instance of NetHttp.
10 11 12 |
# File 'lib/ruby_fogbugz/adapters/http/net_http.rb', line 10 def initialize( = {}) @root_url = [:uri] end |
Instance Attribute Details
#requester ⇒ Object
Returns the value of attribute requester.
8 9 10 |
# File 'lib/ruby_fogbugz/adapters/http/net_http.rb', line 8 def requester @requester end |
#root_url ⇒ Object
Returns the value of attribute root_url.
8 9 10 |
# File 'lib/ruby_fogbugz/adapters/http/net_http.rb', line 8 def root_url @root_url end |
Instance Method Details
#request(action, options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ruby_fogbugz/adapters/http/net_http.rb', line 14 def request(action, ) # Convert the hash key/values to key=value&key2=value2 strings - CGI escaping along the way = [:params].map{ |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&') url_string = "#{@root_url}/api.asp?cmd=#{action}&#{options_string}" url = URI.parse(url_string) request = Net::HTTP::Get.new(url_string, {"Content-Type"=>"text/xml"}) http = Net::HTTP.new(url.host, url.port) http.use_ssl = @root_url.start_with? 'https' response = http.start {|http| http.request(request) } response.body end |