Module: HubSpot::HTTP
- Defined in:
- lib/hub_spot/http.rb
Constant Summary collapse
- DEFAULT_HEADERS =
{ "accept" => "application/json", "content_type" => "application/x-www-form-urlencoded;charset=utf-8", }.freeze
- AUTHORIZATION =
Authentication credentials for HTTP authentication.
"Authorization"
Class Method Summary collapse
Class Method Details
.post(url:, post_body: nil, headers: DEFAULT_HEADERS) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hub_spot/http.rb', line 17 def post(url:, post_body: nil, headers: DEFAULT_HEADERS) uri = URI(url) Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| request = Net::HTTP::Post.new(uri.request_uri, headers) request.body = post_body.to_json unless post_body.nil? # Send the request http.request(request) end end |