Sha256: 8e7c801c068e0b8844ac9a12e9f0cf9db75c78ea6209aa1b0e83f1f2f95d3156

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

module Errplane
  class Transmitter
    def initialize(params = {})
    end

    def relay(black_box)
      http = initialize_http_connection
      data = black_box.to_json
      response = begin
                   url = "/api/v1/applications/#{Errplane.configuration.application_id}/exceptions/#{Errplane.configuration.environment_name}?api_key=#{Errplane.configuration.api_key}"
                   ::Rails.logger.info(url)
                   http.post("/api/v1/applications/#{Errplane.configuration.application_id}/exceptions/#{Errplane.configuration.environment_name}?api_key=#{Errplane.configuration.api_key}", data)
                 rescue Exception => e
                   e
                 end
      ::Rails.logger.info("Exception Data: #{data}")
      ::Rails.logger.info("Exception Body: #{response.body}")
      ::Rails.logger.info("Exception Response: #{response.inspect}")

      case response
      when Net::HTTPSuccess
        # Success
      else
        # Failure
      end
    end

    private
    def initialize_http_connection
      connection = Net::HTTP.new(API_HOST, "80")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
errplane-0.0.2 lib/errplane/transmitter.rb
errplane-0.0.1 lib/errplane/transmitter.rb