Sha256: b939bb6464c58430d9b2c0fe0617a07edbba30a6cab79d60ad4ed52910aaf72a
Contents?: true
Size: 852 Bytes
Versions: 1
Compression:
Stored size: 852 Bytes
Contents
# encoding: utf-8 require 'json' require 'net/http' require 'net/https' module Pagerduty::HttpTransport class << self HOST = "events.pagerduty.com" PORT = 443 PATH = "/generic/2010-04-15/create_event.json" def send(payload = {}) response = post payload.to_json response.error! unless transported?(response) JSON.parse(response.body) end private def post(payload) post = Net::HTTP::Post.new(PATH) post.body = payload http.request(post) end def http http = Net::HTTP.new(HOST, PORT) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.open_timeout = 60 http.read_timeout = 60 http end def transported?(response) response.kind_of? Net::HTTPSuccess or response.kind_of? Net::HTTPRedirection end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pagerduty-1.4.1 | lib/pagerduty/http_transport.rb |