lib/tracker_api/endpoints/comments.rb in tracker_api-1.12.0 vs lib/tracker_api/endpoints/comments.rb in tracker_api-1.13.0
- old
+ new
@@ -5,17 +5,22 @@
def initialize(client)
@client = client
end
- def get(project_id, story_id, params={})
- data = client.paginate("/projects/#{project_id}/stories/#{story_id}/comments", params: params)
+ def get(project_id, story_id: nil, epic_id: nil, params: {})
+ raise ArgumentError, 'One of story id or epic id must be provided.' if story_id.nil? && epic_id.nil?
+
+ comment_target_slug = !story_id.nil? ? "stories/#{story_id}" : "epics/#{epic_id}"
+
+ data = client.paginate("/projects/#{project_id}/#{comment_target_slug}/comments", params: params)
raise Errors::UnexpectedData, 'Array of comments expected' unless data.is_a? Array
data.map do |comment|
- Resources::Comment.new({ client: client,
- project_id: project_id,
- story_id: story_id }.merge(comment))
+ Resources::Comment.new({
+ client: client,
+ project_id: project_id
+ }.merge(comment))
end
end
end
end
end