Sha256: 5ff251f1bfbac3fdce85e8221e0b13b3dbd537ca6ab0534ecb2b03debff2d789

Contents?: true

Size: 862 Bytes

Versions: 189

Compression:

Stored size: 862 Bytes

Contents

module Appsignal
  class AuthCheck
    ACTION = 'auth'.freeze

    attr_reader :config, :logger

    def initialize(config, logger)
      @config = config
      @logger = logger
    end

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

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

Version data entries

189 entries across 189 versions & 1 rubygems

Version Path
appsignal-1.1.0.beta.12 lib/appsignal/auth_check.rb
appsignal-1.0.7 lib/appsignal/auth_check.rb
appsignal-1.0.6 lib/appsignal/auth_check.rb
appsignal-1.1.0.beta.11 lib/appsignal/auth_check.rb
appsignal-1.0.6.beta.4 lib/appsignal/auth_check.rb
appsignal-1.1.0.beta.10 lib/appsignal/auth_check.rb
appsignal-1.0.6.beta.3 lib/appsignal/auth_check.rb
appsignal-1.1.0.beta.9 lib/appsignal/auth_check.rb
appsignal-1.0.6.beta.2 lib/appsignal/auth_check.rb
appsignal-1.1.0.beta.8 lib/appsignal/auth_check.rb
appsignal-1.0.6.beta.1 lib/appsignal/auth_check.rb
appsignal-1.0.5 lib/appsignal/auth_check.rb
appsignal-1.1.0.beta.7 lib/appsignal/auth_check.rb
appsignal-1.0.5.beta.4 lib/appsignal/auth_check.rb
appsignal-1.0.5.beta.3 lib/appsignal/auth_check.rb
appsignal-1.0.5.beta.2 lib/appsignal/auth_check.rb
appsignal-1.0.5.beta.1 lib/appsignal/auth_check.rb
appsignal-1.0.4 lib/appsignal/auth_check.rb
appsignal-1.1.0.beta.6 lib/appsignal/auth_check.rb
appsignal-1.0.3 lib/appsignal/auth_check.rb