class AusPostAPI::UriHandler
Public Class Methods
call(uri, headers={})
click to toggle source
# File lib/aus_post_api/uri_handler.rb, line 7 def self.call(uri, headers={}) self.new(uri, headers).call end
new(uri, headers)
click to toggle source
# File lib/aus_post_api/uri_handler.rb, line 11 def initialize(uri, headers) @headers = headers @uri = URI.parse(uri) end
Public Instance Methods
call()
click to toggle source
# File lib/aus_post_api/uri_handler.rb, line 16 def call http.request(request) end
Private Instance Methods
http()
click to toggle source
# File lib/aus_post_api/uri_handler.rb, line 22 def http @http ||= Net::HTTP.new(@uri.host, @uri.port).tap do |h| h.use_ssl = true h.verify_mode = OpenSSL::SSL::VERIFY_PEER end end
request()
click to toggle source
# File lib/aus_post_api/uri_handler.rb, line 29 def request @request ||= Net::HTTP::Get.new(@uri).tap do |r| @headers.each { |key, val| r.add_field(key, val) } end end