Class: Checkend::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/checkend/client.rb

Overview

HTTP client for sending error notices to the Checkend API.

Uses Net::HTTP from Ruby stdlib with no external dependencies.

Constant Summary collapse

INGEST_PATH =
'/ingest/v1/errors'
USER_AGENT =
"checkend-ruby/#{VERSION} Ruby/#{RUBY_VERSION}"

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Client

Returns a new instance of Client.



17
18
19
20
# File 'lib/checkend/client.rb', line 17

def initialize(config)
  @config = config
  @uri = URI.parse("#{config.endpoint}#{INGEST_PATH}")
end

Instance Method Details

#send_notice(notice) ⇒ Hash?

Send a notice to the Checkend API

Parameters:

  • notice (Notice) —

    the notice to send

Returns:

  • (Hash, nil) —

    the response body on success, nil on failure



26
27
28
29
30
31
32
# File 'lib/checkend/client.rb', line 26

def send_notice(notice)
  response = post(notice.to_json)
  handle_response(response)
rescue StandardError => e
  log_error("Failed to send notice: #{e.class} - #{e.message}")
  nil
end