Sha256: fc857e8ae6ba62bcda412c08ebf710d3a7b6667e50a000ff07e14850172eb02b

Contents?: true

Size: 948 Bytes

Versions: 4

Compression:

Stored size: 948 Bytes

Contents

module Appsignal
  class AuthCheck
    ACTION = "auth".freeze

    attr_reader :config, :logger

    def initialize(config, logger = nil)
      @config = config
      if logger # rubocop:disable Style/GuardClause
        warn "Deprecated: `logger` argument will be removed in the next " \
          "major version."
      end
    end

    def perform
      Appsignal::Transmitter.new(ACTION, config).transmit({})
    end

    def perform_with_result
      status = perform
      result =
        case status
        when "200"
          "AppSignal has confirmed authorization!"
        when "401"
          "API key not valid with AppSignal..."
        else
          "Could not confirm authorization: " \
            "#{status.nil? ? "nil" : status}"
        end
      [status, result]
    rescue => e
      result = "Something went wrong while trying to "\
               "authenticate with AppSignal: #{e}"
      [nil, result]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appsignal-2.1.2 lib/appsignal/auth_check.rb
appsignal-2.1.1 lib/appsignal/auth_check.rb
appsignal-2.1.1.beta.1 lib/appsignal/auth_check.rb
appsignal-2.1.0 lib/appsignal/auth_check.rb