Class: VtApi::Versions::ApiV2
- Inherits:
-
ApiVersion
- Object
- ApiVersion
- VtApi::Versions::ApiV2
- Defined in:
- lib/vt_api/internal/versions/api_v2.rb
Overview
VirusTotal Public API 2.0 singleton interface. Describes all available API methods (endpoints).
Constant Summary collapse
- BASE_URI =
Root URI for all endpoints.
'https://virustotal.com/vtapi/v2/'
- ENDPOINTS =
VirusTotal Public API v2.0 interface description.
{ 'file.report': Endpoint.new('file/report', :get, apikey: true, resource: true), 'file.scan': Endpoint.new('file/scan', :post, apikey: true, file: true), 'file.rescan': Endpoint.new('file/rescan', :post, apikey: true, resource: true), 'url.report': Endpoint.new('url/report', :get, apikey: true, resource: true, schedule_scan: false), 'url.scan': Endpoint.new('url/scan', :post, apikey: true, url: true), 'domain.report': Endpoint.new('domain/report', :get, apikey: true, domain: true), 'ip-address.report': Endpoint.new('ip-address/report', :get, apikey: true, domain: true), 'comments.get': Endpoint.new('comments/get', :get, apikey: true, resource: true, before: false), 'comments.put': Endpoint.new('comments/put', :post, apikey: true, resource: true, comment: true) }.freeze
- ERRORS =
List of possible HTTP error codes with descriptions
{ 204 => 'Request rate limit exceeded.', 400 => 'Invalid arguments.', 403 => 'Access denied.', 404 => 'Endpoint not found.' }.freeze
Class Method Summary collapse
-
.instance ⇒ VtApi::Versions::ApiV2
Get interface instance.
Instance Method Summary collapse
-
#base_url ⇒ String
API base URL.
-
#endpoint(method) ⇒ VtApi::Endpoint
Get API method endpoint interface.
-
#endpoint?(method) ⇒ Boolean
Check whether given method is defined in interface.
-
#error(http_code) ⇒ String
Get API HTTP-code description.
-
#error?(http_code) ⇒ Boolean
Check whether API HTTP-code means error.
-
#version ⇒ String
API interface name/version.
Class Method Details
.instance ⇒ VtApi::Versions::ApiV2
Get interface instance.
60 61 62 |
# File 'lib/vt_api/internal/versions/api_v2.rb', line 60 def instance @instance ||= new end |
Instance Method Details
#base_url ⇒ String
API base URL.
100 101 102 |
# File 'lib/vt_api/internal/versions/api_v2.rb', line 100 def base_url BASE_URI end |
#endpoint(method) ⇒ VtApi::Endpoint
Get API method endpoint interface.
69 70 71 |
# File 'lib/vt_api/internal/versions/api_v2.rb', line 69 def endpoint(method) ENDPOINTS[method.to_sym] unless ENDPOINTS[method.to_sym].nil? end |
#endpoint?(method) ⇒ Boolean
Check whether given method is defined in interface.
77 78 79 |
# File 'lib/vt_api/internal/versions/api_v2.rb', line 77 def endpoint?(method) !endpoint(method).nil? end |
#error(http_code) ⇒ String
Get API HTTP-code description.
85 86 87 |
# File 'lib/vt_api/internal/versions/api_v2.rb', line 85 def error(http_code) ERRORS[http_code] unless ERRORS[http_code].nil? end |
#error?(http_code) ⇒ Boolean
Check whether API HTTP-code means error.
93 94 95 |
# File 'lib/vt_api/internal/versions/api_v2.rb', line 93 def error?(http_code) !error(http_code).nil? end |
#version ⇒ String
API interface name/version.
107 108 109 |
# File 'lib/vt_api/internal/versions/api_v2.rb', line 107 def version 'VTAPI-2.0' end |