class HerokuOneOff::HTTP
Attributes
body[R]
http[R]
uri[R]
Public Class Methods
new(url, body)
click to toggle source
# File lib/heroku-one-off/http.rb, line 5 def initialize(url, body) @uri = URI.parse(url) @body = body @http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true end
Public Instance Methods
headers()
click to toggle source
# File lib/heroku-one-off/http.rb, line 23 def headers { 'Content-Type': 'application/json', Accept: 'application/vnd.heroku+json; version=3', Authorization: "Bearer #{HerokuOneOff::Config.bearer_token}" } end
post()
click to toggle source
# File lib/heroku-one-off/http.rb, line 13 def post request = Net::HTTP::Post.new(uri, headers) request.body = body.to_json response = http.request(request) raise HerokuOneOff::HTTPError, response.body unless response.code == '201' end