Class: Honeybadger::Backend::Server Private

Inherits:
Base
  • Object
show all
Defined in:
lib/honeybadger/backend/server.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

ENDPOINTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  notices: '/v1/notices'.freeze,
  deploys: '/v1/deploys'.freeze
}.freeze
CHECK_IN_ENDPOINT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'/v1/check_in'.freeze
HTTP_ERRORS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Util::HTTP::ERRORS

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Server

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Server


22
23
24
25
# File 'lib/honeybadger/backend/server.rb', line 22

def initialize(config)
  @http = Util::HTTP.new(config)
  super
end

Instance Method Details

#check_in(id) ⇒ Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Does a check in using the input id.


45
46
47
48
49
# File 'lib/honeybadger/backend/server.rb', line 45

def check_in(id)
  Response.new(@http.get("#{CHECK_IN_ENDPOINT}/#{id}"))
rescue *HTTP_ERRORS => e
  Response.new(:error, nil, "HTTP Error: #{e.class}")
end

#notify(feature, payload) ⇒ Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Post payload to endpoint for feature.


33
34
35
36
37
38
# File 'lib/honeybadger/backend/server.rb', line 33

def notify(feature, payload)
  ENDPOINTS[feature] or raise(BackendError, "Unknown feature: #{feature}")
  Response.new(@http.post(ENDPOINTS[feature], payload, payload_headers(payload)))
rescue *HTTP_ERRORS => e
  Response.new(:error, nil, "HTTP Error: #{e.class}")
end