lib/appsignal/auth_check.rb in appsignal-2.1.2 vs lib/appsignal/auth_check.rb in appsignal-2.2.0.beta.1

- old
+ new

@@ -1,7 +1,23 @@ module Appsignal + # Class used to perform a Push API validation / authentication check against + # the AppSignal Push API. + # + # @example + # config = Appsignal::Config.new(Dir.pwd, "production") + # auth_check = Appsignal::AuthCheck.new(config) + # # Valid push_api_key + # auth_check.perform # => "200" + # # Invalid push_api_key + # auth_check.perform # => "401" + # + # @!attribute [r] config + # @return [Appsignal::Config] config to use in the authentication request. + # @api private class AuthCheck + # Path used on the AppSignal Push API + # https://push.appsignal.com/1/auth ACTION = "auth".freeze attr_reader :config, :logger def initialize(config, logger = nil) @@ -10,13 +26,24 @@ warn "Deprecated: `logger` argument will be removed in the next " \ "major version." end end + # Perform push api validation request and return response status code. + # + # @return [String] response status code. + # @raise [StandardError] see {Appsignal::Transmitter#transmit}. def perform - Appsignal::Transmitter.new(ACTION, config).transmit({}) + Appsignal::Transmitter.new(ACTION, config).transmit({}).code end + # Perform push api validation request and return a descriptive response + # tuple. + # + # @return [Array<String/nil, String>] response tuple. + # - First value is the response status code. + # - Second value is a description of the response and the exception error + # message if an exception occured. def perform_with_result status = perform result = case status when "200"