Class: VirustotalAPI::Base
- Inherits:
-
Object
- Object
- VirustotalAPI::Base
- Defined in:
- lib/virustotal_api/base.rb
Overview
The base class implementing the raw calls to Virustotal API V3.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
-
#report_url ⇒ Object
readonly
Returns the value of attribute report_url.
Class Method Summary collapse
-
.api_uri ⇒ String
String of API URI class method.
- .perform(path, api_key, method = :get, options = {}) ⇒ Object
- .perform_absolute(url, api_key, method = :get, options = {}) ⇒ Object
-
.url_identifier(url) ⇒ Object
Generate a URL identifier.
Instance Method Summary collapse
-
#api_uri ⇒ String
String of API URI instance method.
-
#exists? ⇒ Boolean
If report for resource exists.
-
#initialize(report) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(report) ⇒ Base
Returns a new instance of Base.
14 15 16 17 18 |
# File 'lib/virustotal_api/base.rb', line 14 def initialize(report) @report = report @report_url = report&.dig('data', 'links', 'self') @id = report&.dig('data', 'id') end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/virustotal_api/base.rb', line 12 def id @id end |
#report ⇒ Object (readonly)
Returns the value of attribute report.
12 13 14 |
# File 'lib/virustotal_api/base.rb', line 12 def report @report end |
#report_url ⇒ Object (readonly)
Returns the value of attribute report_url.
12 13 14 |
# File 'lib/virustotal_api/base.rb', line 12 def report_url @report_url end |
Class Method Details
.api_uri ⇒ String
Returns string of API URI class method.
21 22 23 |
# File 'lib/virustotal_api/base.rb', line 21 def self.api_uri VirustotalAPI::URI end |
.perform(path, api_key, method = :get, options = {}) ⇒ Object
25 26 27 |
# File 'lib/virustotal_api/base.rb', line 25 def self.perform(path, api_key, method = :get, = {}) base_perform(api_uri + path, api_key, method, ) end |
.perform_absolute(url, api_key, method = :get, options = {}) ⇒ Object
29 30 31 |
# File 'lib/virustotal_api/base.rb', line 29 def self.perform_absolute(url, api_key, method = :get, = {}) base_perform(url, api_key, method, ) end |
.url_identifier(url) ⇒ Object
Generate a URL identifier.
74 75 76 |
# File 'lib/virustotal_api/base.rb', line 74 def self.url_identifier(url) Base64.urlsafe_encode64(url).strip.gsub('=', '') end |
Instance Method Details
#api_uri ⇒ String
Returns string of API URI instance method.
63 64 65 |
# File 'lib/virustotal_api/base.rb', line 63 def api_uri self.class.api_uri end |
#exists? ⇒ Boolean
Returns if report for resource exists.
68 69 70 |
# File 'lib/virustotal_api/base.rb', line 68 def exists? !report.empty? end |