Class: ZnyxSdk::EvaluationResponse
- Inherits:
-
Object
- Object
- ZnyxSdk::EvaluationResponse
- Defined in:
- lib/znyx_sdk/models.rb
Overview
Immutable value object returned by all evaluate methods.
Instance Attribute Summary collapse
-
#decision ⇒ Object
readonly
Returns the value of attribute decision.
-
#detector_results ⇒ Object
readonly
Returns the value of attribute detector_results.
-
#developer_message ⇒ Object
readonly
Returns the value of attribute developer_message.
-
#latency_ms ⇒ Object
readonly
Returns the value of attribute latency_ms.
-
#policy_version ⇒ Object
readonly
Returns the value of attribute policy_version.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#risk_score ⇒ Object
readonly
Returns the value of attribute risk_score.
-
#rule_hits ⇒ Object
readonly
Returns the value of attribute rule_hits.
-
#sanitized_text ⇒ Object
readonly
Returns the value of attribute sanitized_text.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
-
#trace_id ⇒ Object
readonly
Returns the value of attribute trace_id.
-
#user_message ⇒ Object
readonly
Returns the value of attribute user_message.
Instance Method Summary collapse
- #blocked? ⇒ Boolean
-
#initialize(data) ⇒ EvaluationResponse
constructor
A new instance of EvaluationResponse.
- #redacted? ⇒ Boolean
-
#safe_text(original) ⇒ Object
Returns sanitized_text if present, otherwise the original string.
Constructor Details
#initialize(data) ⇒ EvaluationResponse
Returns a new instance of EvaluationResponse.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/znyx_sdk/models.rb', line 11 def initialize(data) @request_id = data["request_id"] @decision = data["decision"] @risk_score = data["risk_score"].to_i @policy_version = data["policy_version"] @rule_hits = Array(data["rule_hits"]).map { |h| RuleHit.new(h) } @sanitized_text = data["sanitized_text"] @user_message = data["user_message"] @developer_message = data["developer_message"] @latency_ms = data["latency_ms"].to_i @trace_id = data["trace_id"] @session_id = data["session_id"] @detector_results = Array(data["detector_results"]).map { |d| DetectorResult.new(d) } end |
Instance Attribute Details
#decision ⇒ Object (readonly)
Returns the value of attribute decision.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def decision @decision end |
#detector_results ⇒ Object (readonly)
Returns the value of attribute detector_results.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def detector_results @detector_results end |
#developer_message ⇒ Object (readonly)
Returns the value of attribute developer_message.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def @developer_message end |
#latency_ms ⇒ Object (readonly)
Returns the value of attribute latency_ms.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def latency_ms @latency_ms end |
#policy_version ⇒ Object (readonly)
Returns the value of attribute policy_version.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def policy_version @policy_version end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def request_id @request_id end |
#risk_score ⇒ Object (readonly)
Returns the value of attribute risk_score.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def risk_score @risk_score end |
#rule_hits ⇒ Object (readonly)
Returns the value of attribute rule_hits.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def rule_hits @rule_hits end |
#sanitized_text ⇒ Object (readonly)
Returns the value of attribute sanitized_text.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def sanitized_text @sanitized_text end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def session_id @session_id end |
#trace_id ⇒ Object (readonly)
Returns the value of attribute trace_id.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def trace_id @trace_id end |
#user_message ⇒ Object (readonly)
Returns the value of attribute user_message.
6 7 8 |
# File 'lib/znyx_sdk/models.rb', line 6 def @user_message end |
Instance Method Details
#blocked? ⇒ Boolean
26 |
# File 'lib/znyx_sdk/models.rb', line 26 def blocked? = @decision == "BLOCK" |
#redacted? ⇒ Boolean
27 |
# File 'lib/znyx_sdk/models.rb', line 27 def redacted? = @decision == "REDACT" |
#safe_text(original) ⇒ Object
Returns sanitized_text if present, otherwise the original string.
30 31 32 |
# File 'lib/znyx_sdk/models.rb', line 30 def safe_text(original) sanitized_text.nil? || sanitized_text.empty? ? original : sanitized_text end |