Class: JIRA::HttpClient
- Inherits:
-
RequestClient
- Object
- RequestClient
- JIRA::HttpClient
- Defined in:
- lib/jira/http_client.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :username => '', :password => '' }
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #basic_auth_http_conn ⇒ Object
- #http_conn(uri) ⇒ Object
-
#initialize(options) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #make_request(http_method, path, body = '', headers = {}) ⇒ Object
- #uri ⇒ Object
Methods inherited from RequestClient
Constructor Details
#initialize(options) ⇒ HttpClient
Returns a new instance of HttpClient.
14 15 16 |
# File 'lib/jira/http_client.rb', line 14 def initialize() @options = DEFAULT_OPTIONS.merge() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/jira/http_client.rb', line 12 def @options end |
Instance Method Details
#basic_auth_http_conn ⇒ Object
26 27 28 |
# File 'lib/jira/http_client.rb', line 26 def basic_auth_http_conn http_conn(uri) end |
#http_conn(uri) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/jira/http_client.rb', line 30 def http_conn(uri) http_conn = Net::HTTP.new(uri.host, uri.port) http_conn.use_ssl = @options[:use_ssl] http_conn.verify_mode = @options[:ssl_verify_mode] http_conn end |
#make_request(http_method, path, body = '', headers = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/jira/http_client.rb', line 18 def make_request(http_method, path, body='', headers={}) request = Net::HTTP.const_get(http_method.to_s.capitalize).new(path, headers) request.body = body unless body.nil? request.basic_auth(@options[:username], @options[:password]) response = basic_auth_http_conn.request(request) response end |
#uri ⇒ Object
37 38 39 |
# File 'lib/jira/http_client.rb', line 37 def uri uri = URI.parse(@options[:site]) end |