Method: ThreeScale::API::HttpClient#initialize
- Defined in:
- lib/3scale/api/http_client.rb
#initialize(endpoint:, provider_key:, format: :json, verify_ssl: true) ⇒ HttpClient
Returns a new instance of HttpClient.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/3scale/api/http_client.rb', line 11 def initialize(endpoint:, provider_key:, format: :json, verify_ssl: true) @endpoint = URI(endpoint).freeze @admin_domain = @endpoint.host.freeze @provider_key = provider_key.freeze @http = Net::HTTP.new(admin_domain, @endpoint.port) @http.use_ssl = @endpoint.is_a?(URI::HTTPS) @http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless verify_ssl @headers = { 'Accept' => "application/#{format}", 'Content-Type' => "application/#{format}", 'Authorization' => 'Basic ' + [":#{@provider_key}"].pack('m').delete("\r\n") } if debug? @http.set_debug_output($stdout) @headers['Accept-Encoding'] = 'identity' end @headers.freeze @format = format end |