class Pagerduty::HttpTransport
@api private
Constants
- HOST
- PATH
- PORT
Public Class Methods
new(options = {})
click to toggle source
# File lib/pagerduty/http_transport.rb, line 11 def initialize(options = {}) @options = options end
Public Instance Methods
send_payload(payload = {})
click to toggle source
# File lib/pagerduty/http_transport.rb, line 15 def send_payload(payload = {}) response = post payload.to_json response.error! unless transported?(response) JSON.parse(response.body) end
Private Instance Methods
http()
click to toggle source
# File lib/pagerduty/http_transport.rb, line 29 def http http = http_proxy.new(HOST, PORT) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.open_timeout = 60 http.read_timeout = 60 http end
http_proxy()
click to toggle source
# File lib/pagerduty/http_transport.rb, line 38 def http_proxy Net::HTTP.Proxy( @options[:proxy_host], @options[:proxy_port], @options[:proxy_username], @options[:proxy_password], ) end
post(payload)
click to toggle source
# File lib/pagerduty/http_transport.rb, line 23 def post(payload) post = Net::HTTP::Post.new(PATH) post.body = payload http.request(post) end
transported?(response)
click to toggle source
# File lib/pagerduty/http_transport.rb, line 47 def transported?(response) response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPRedirection) end