Class: Forem::Services::CommentService

Inherits:
BaseService show all
Defined in:
lib/forem/services/comment_service.rb

Overview

Service for interacting with the Forem Comments API.

Access via Client#comments. All methods inject the client's requestor automatically so no additional configuration is required.

Examples:

client = Forem::Client.new("your-api-key")
comments = client.comments.list(a_id: 12345)
comment  = client.comments.retrieve("abc123")

See Also:

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Forem::Services::BaseService

Instance Method Details

#list(params = {}, opts = {}) ⇒ Array<Comment>

List comments for an article or podcast episode.

Examples:

Fetch comments for an article

client.comments.list(a_id: 12345)

Fetch comments for a podcast episode

client.comments.list(p_id: 67)

Parameters:

  • params (Hash) (defaults to: {})

    query parameters

  • opts (Hash) (defaults to: {})

    per-request options

Options Hash (params):

  • :a_id (Integer)

    article ID to fetch comments for

  • :p_id (Integer)

    podcast episode ID to fetch comments for

Returns:

  • (Array<Comment>)

    top-level comments (with nested replies)

See Also:



31
32
33
# File 'lib/forem/services/comment_service.rb', line 31

def list(params = {}, opts = {})
  Comment.list(params, opts_with_requestor(opts))
end

#retrieve(id, opts = {}) ⇒ Comment

Retrieve a single comment by its ID.

Examples:

client.comments.retrieve("abc123")

Parameters:

  • id (String)

    the comment ID (alphanumeric string as returned by the API)

  • opts (Hash) (defaults to: {})

    per-request options

Returns:

  • (Comment)

    the comment with the given ID

See Also:



46
47
48
# File 'lib/forem/services/comment_service.rb', line 46

def retrieve(id, opts = {})
  Comment.retrieve(id, opts_with_requestor(opts))
end