Class: Contrast::Agent::Reporting::Response
- Defined in:
- lib/contrast/agent/reporting/reporting_utilities/response.rb
Overview
this class will hold the response from TS
Instance Attribute Summary collapse
-
#application_settings ⇒ Contrast::Agent::Reporting::Settings::ApplicationSettings?
All of the settings from TeamServer that apply at the application level.
-
#messages ⇒ Array<String>
Message with reasons for success or fail.
-
#server_features ⇒ Contrast::Agent::Reporting::Settings::ServerFeatures?
All of the feature server_features.
-
#success ⇒ Boolean
Success boolean message value.
Class Method Summary collapse
-
.build_application_response ⇒ Object
All of the settings from TeamServer that apply at the application level.
-
.build_server_response ⇒ Object
All of the settings from TeamServer that apply at the server level.
Instance Method Summary collapse
-
#reactions ⇒ Array<Contrast::Agent::Reporting::Settings::Reaction>
Reaction the agent should take based on a state in TS.
-
#reactions=(reaction_array) ⇒ Array<Contrast::Agent::Reporting::Settings::Reaction>
Set the reaction.
-
#to_controlled_hash ⇒ Object
This method is used only for testing with golden files.
Instance Attribute Details
#application_settings ⇒ Contrast::Agent::Reporting::Settings::ApplicationSettings?
All of the settings from TeamServer that apply at the application level. At least one, but not necessarily all, setting will differ from the agent’s current set. Agents are able to replace all application settings with those in this message.
18 19 20 |
# File 'lib/contrast/agent/reporting/reporting_utilities/response.rb', line 18 def application_settings @application_settings end |
#messages ⇒ Array<String>
Message with reasons for success or fail.
33 34 35 |
# File 'lib/contrast/agent/reporting/reporting_utilities/response.rb', line 33 def @messages end |
#server_features ⇒ Contrast::Agent::Reporting::Settings::ServerFeatures?
All of the feature server_features
23 24 25 |
# File 'lib/contrast/agent/reporting/reporting_utilities/response.rb', line 23 def server_features @server_features end |
#success ⇒ Boolean
Success boolean message value
28 29 30 |
# File 'lib/contrast/agent/reporting/reporting_utilities/response.rb', line 28 def success @success end |
Class Method Details
.build_application_response ⇒ Object
All of the settings from TeamServer that apply at the application level.
39 40 41 42 43 |
# File 'lib/contrast/agent/reporting/reporting_utilities/response.rb', line 39 def build_application_response res = new res.application_settings = Contrast::Agent::Reporting::Settings::ApplicationSettings.new res end |
.build_server_response ⇒ Object
All of the settings from TeamServer that apply at the server level.
48 49 50 51 52 |
# File 'lib/contrast/agent/reporting/reporting_utilities/response.rb', line 48 def build_server_response res = new res.server_features = Contrast::Agent::Reporting::Settings::ServerFeatures.new res end |
Instance Method Details
#reactions ⇒ Array<Contrast::Agent::Reporting::Settings::Reaction>
Reaction the agent should take based on a state in TS. This is moved one level up because the responses we receive for feature and settings from TS have different place to store these reactions:
body.reactions vs body.settings.reactions
63 64 65 |
# File 'lib/contrast/agent/reporting/reporting_utilities/response.rb', line 63 def reactions @_reactions ||= [] end |
#reactions=(reaction_array) ⇒ Array<Contrast::Agent::Reporting::Settings::Reaction>
Set the reaction
75 76 77 78 79 80 81 |
# File 'lib/contrast/agent/reporting/reporting_utilities/response.rb', line 75 def reactions= reaction_array return unless reaction_array.is_a?(Array) reaction_array.each do |r| reactions << Contrast::Agent::Reporting::Settings::Reaction.new(r[:level], r[:operation], r[:message]) end end |
#to_controlled_hash ⇒ Object
This method is used only for testing with golden files.
84 85 86 87 88 89 90 91 92 |
# File 'lib/contrast/agent/reporting/reporting_utilities/response.rb', line 84 def to_controlled_hash { success: success, messages: , features: server_features.nil? ? nil : server_features.to_controlled_hash, settings: application_settings.nil? ? nil : application_settings.to_controlled_hash, reactions: server_features.nil? ? nil : reactions.map(&:to_controlled_hash) }.compact end |