Method: DiscourseApi::API::Topics#topic_posts

Defined in:
lib/discourse_api/api/topics.rb

#topic_posts(topic_id, post_ids = [], params = {}) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/discourse_api/api/topics.rb', line 77

def topic_posts(topic_id, post_ids = [], params = {})
  params = API.params(params)
    .optional(:asc,
      :filter,
      :include_raw,
      :include_suggested,
      :post_number,
      :username_filters,
    )

  url = ["/t/#{topic_id}/posts.json"]
  if post_ids.count > 0
    url.push('?')
    url.push(post_ids.map { |id| "post_ids[]=#{id}" }.join('&'))
  end
  response = get(url.join, params)
  response[:body]
end