Class: Appsignal::AuthCheck Private
Overview
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.
Class used to perform a Push API validation / authentication check against the AppSignal Push API.
Constant Summary collapse
- ACTION =
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.
Path used on the AppSignal Push API https://push.appsignal.com/1/auth
"auth".freeze
Instance Attribute Summary collapse
-
#config ⇒ Appsignal::Config
readonly
private
Config to use in the authentication request.
Instance Method Summary collapse
-
#initialize(config) ⇒ AuthCheck
constructor
private
A new instance of AuthCheck.
-
#perform ⇒ String
private
Perform push api validation request and return response status code.
-
#perform_with_result ⇒ Array<String/nil, String>
private
Perform push api validation request and return a descriptive response tuple.
Constructor Details
#initialize(config) ⇒ AuthCheck
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 AuthCheck.
25 26 27 |
# File 'lib/appsignal/auth_check.rb', line 25 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Appsignal::Config (readonly)
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 config to use in the authentication request.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/appsignal/auth_check.rb', line 18 class AuthCheck # Path used on the AppSignal Push API # https://push.appsignal.com/1/auth ACTION = "auth".freeze attr_reader :config def initialize(config) @config = config 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({}).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" "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 |
Instance Method Details
#perform ⇒ String
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.
Perform push api validation request and return response status code.
33 34 35 |
# File 'lib/appsignal/auth_check.rb', line 33 def perform Appsignal::Transmitter.new(ACTION, config).transmit({}).code end |
#perform_with_result ⇒ Array<String/nil, String>
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.
Perform push api validation request and return a descriptive response tuple.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/appsignal/auth_check.rb', line 44 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 |