Class: Scanii::ProcessingResult
- Inherits:
-
Object
- Object
- Scanii::ProcessingResult
- Defined in:
- lib/scanii/processing_result.rb
Overview
Result of a synchronous file scan returned by Client#process and Client#retrieve.
findings is always an Array. Empty array means the content is clean.
Instance Attribute Summary collapse
-
#checksum ⇒ Object
readonly
Returns the value of attribute checksum.
-
#content_length ⇒ Object
readonly
Returns the value of attribute content_length.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#creation_date ⇒ Object
readonly
Returns the value of attribute creation_date.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
-
#host_id ⇒ Object
readonly
Returns the value of attribute host_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#resource_location ⇒ Object
readonly
Returns the value of attribute resource_location.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, findings:, checksum:, content_length:, content_type:, metadata:, creation_date:, error:, request_id:, host_id:, resource_location:, raw_response:) ⇒ ProcessingResult
constructor
A new instance of ProcessingResult.
Constructor Details
#initialize(id:, findings:, checksum:, content_length:, content_type:, metadata:, creation_date:, error:, request_id:, host_id:, resource_location:, raw_response:) ⇒ ProcessingResult
Returns a new instance of ProcessingResult.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/scanii/processing_result.rb', line 15 def initialize(id:, findings:, checksum:, content_length:, content_type:, metadata:, creation_date:, error:, request_id:, host_id:, resource_location:, raw_response:) @id = id @findings = findings @checksum = checksum @content_length = content_length @content_type = content_type @metadata = @creation_date = creation_date @error = error @request_id = request_id @host_id = host_id @resource_location = resource_location @raw_response = raw_response end |
Instance Attribute Details
#checksum ⇒ Object (readonly)
Returns the value of attribute checksum.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def checksum @checksum end |
#content_length ⇒ Object (readonly)
Returns the value of attribute content_length.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def content_length @content_length end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def content_type @content_type end |
#creation_date ⇒ Object (readonly)
Returns the value of attribute creation_date.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def creation_date @creation_date end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def error @error end |
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def findings @findings end |
#host_id ⇒ Object (readonly)
Returns the value of attribute host_id.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def host_id @host_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def @metadata end |
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def raw_response @raw_response end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def request_id @request_id end |
#resource_location ⇒ Object (readonly)
Returns the value of attribute resource_location.
11 12 13 |
# File 'lib/scanii/processing_result.rb', line 11 def resource_location @resource_location end |
Class Method Details
.from_response(body, headers) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/scanii/processing_result.rb', line 32 def self.from_response(body, headers) json = body.nil? || body.empty? ? {} : JSON.parse(body) new( id: (json["id"] || "").to_s, findings: Array(json["findings"]).map(&:to_s), checksum: json["checksum"]&.to_s, content_length: json["content_length"]&.to_i, content_type: json["content_type"]&.to_s, metadata: (json["metadata"] || {}).transform_values(&:to_s), creation_date: json["creation_date"]&.to_s, error: json["error"]&.to_s, request_id: headers["x-scanii-request-id"], host_id: headers["x-scanii-host-id"], resource_location: headers["location"], raw_response: body ) end |