Class: TrackerApi::Endpoints::Reviews

Inherits:
Object
  • Object
show all
Defined in:
lib/tracker_api/endpoints/reviews.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Reviews

Returns a new instance of Reviews.



6
7
8
# File 'lib/tracker_api/endpoints/reviews.rb', line 6

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/tracker_api/endpoints/reviews.rb', line 4

def client
  @client
end

Instance Method Details

#get(project_id, story_id, params = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/tracker_api/endpoints/reviews.rb', line 10

def get(project_id, story_id, params={})
  params[:fields] ||= ":default,review_type"
  data = client.paginate("/projects/#{project_id}/stories/#{story_id}/reviews", params: params)
  raise Errors::UnexpectedData, 'Successful responses to this request return an array containing zero or more instances of the review resource. This response was not an array.' unless data.is_a? Array

  data.map do |review|
    Resources::Review.new({ client: client, project_id: project_id }.merge(review))
  end
end