Module: VtApi::ApiV2::Comments

Defined in:
lib/vt_api/api/v2/comments.rb

Overview

VT API 2.0 for comments

Defined Under Namespace

Classes: Comment

Class Method Summary collapse

Class Method Details

.get(resource:, before:) ⇒ Array<Comment>

Returns Array of parsed comments.

Parameters:

  • resource (String)
  • before (String)

    Must be in format of date_token. Refer to API docs for more info.

Returns:

  • (Array<Comment>)

    Array of parsed comments.

See Also:



36
37
38
39
40
# 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) ⇒ Object



53
54
55
56
57
58
59
60
# 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:) ⇒ Boolean

Returns True if comment put successfully (‘response_code’ equals 1), false otherwise.

Parameters:

  • resource (String)
  • text (String)

    Comment text string.

Returns:

  • (Boolean)

    True if comment put successfully (‘response_code’ equals 1), false otherwise.

See Also:



47
48
49
50
51
# 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