module VtApi::ApiV2::Comments

VT API 2.0 for comments

Public Class Methods

get(resource:, before:) click to toggle source

@see developers.virustotal.com/v2.0/reference#comments-get @see Comment#date_token

@param [String] resource @param [String] before Must be in format of date_token. Refer to API docs for more info. @return [Array<Comment>] Array of parsed comments.

# File lib/vt_api/api/v2/comments.rb, line 36
def self.get(resource:, before:)
        resp = ApiV2.provider.request 'comments.get', apikey: VtApi.options.token, resource: resource, before: before

        parse_comments resp
end
parse_comments(api_resp) click to toggle source
# File lib/vt_api/api/v2/comments.rb, line 53
def self.parse_comments(api_resp)
        # noinspection RubyResolve
        if api_resp.response_code.nil? || (api_resp.response_code != 1)
                []
        else
                api_resp.comments.map { |comment| Comment.new comment.date, comment.text }
        end
end
put(resource:, text:) click to toggle source

@see developers.virustotal.com/v2.0/reference#comments-put

@param [String] resource @param [String] text Comment text string. @return [Boolean] True if comment put successfully ('response_code' equals 1), false otherwise.

# File lib/vt_api/api/v2/comments.rb, line 47
def self.put(resource:, text:)
        resp = ApiV2.provider.request 'comments.put', apikey: VtApi.options.token, resource: resource, text: text

        resp.response_code == 1
end