Sha256: 0abf76b179ca67d19e1a4c0d246723819b151e2fed2397fe8f41c09665e9ef69

Contents?: true

Size: 812 Bytes

Versions: 4

Compression:

Stored size: 812 Bytes

Contents

module TrackerApi
  module Endpoints
    class Comments
      attr_accessor :client

      def initialize(client)
        @client = client
      end

      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
          }.merge(comment))
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tracker_api-1.16.0 lib/tracker_api/endpoints/comments.rb
tracker_api-1.15.0 lib/tracker_api/endpoints/comments.rb
tracker_api-1.14.0 lib/tracker_api/endpoints/comments.rb
tracker_api-1.13.0 lib/tracker_api/endpoints/comments.rb