class Hubspot::HttpRequest
Constants
- BASE_URL
Attributes
http[RW]
uri[RW]
Public Class Methods
new(debug = true)
click to toggle source
# File lib/hubspot/http_request.rb, line 10 def initialize(debug = true) @uri = URI(BASE_URL) @http = Net::HTTP.new(uri.host, uri.port) if uri.scheme == "https" @http.use_ssl = true @http.verify_mode = OpenSSL::SSL::VERIFY_PEER end @http.set_debug_output($stdout) if debug end
Public Instance Methods
get(path, options = {})
click to toggle source
# File lib/hubspot/http_request.rb, line 22 def get(path, options = {}) raise ArgumentError, "Path Error" if path.blank? body = JSON.dump(options) request = Net::HTTP::Get.new(path, body) response = http.request(request) HttpResponse.call(response) end
post(path, options = {})
click to toggle source
# File lib/hubspot/http_request.rb, line 32 def post(path, options = {}) raise ArgumentError, "Path Error" if path.blank? body = JSON.dump(options) request = Net::HTTP::Post.new(path) # fyi: uri.path or just uri request.add_field("Content-Type", "application/json") request.body = body response = http.request(request) HttpResponse.call(response) end