lib/tracker_api/resources/story.rb in tracker_api-0.2.10 vs lib/tracker_api/resources/story.rb in tracker_api-0.2.11
- old
+ new
@@ -1,37 +1,39 @@
module TrackerApi
module Resources
class Story
- include Resources::Base
+ include Shared::HasId
attribute :client
attribute :accepted_at, DateTime
attribute :comment_ids, Array[Integer]
- attribute :comments, Array[Resources::Comment]
+ attribute :comments, Array[Comment], :default => []
attribute :created_at, DateTime
attribute :current_state, String # (accepted, delivered, finished, started, rejected, planned, unstarted, unscheduled)
attribute :deadline, DateTime
attribute :description, String
attribute :estimate, Float
attribute :external_id, String
attribute :follower_ids, Array[Integer]
+ attribute :followers, Array[Person]
attribute :integration_id, Integer
attribute :kind, String
attribute :label_ids, Array[Integer]
- attribute :labels, Array[Resources::Label]
+ attribute :labels, Array[Label], :default => []
attribute :name, String
attribute :owned_by_id, Integer # deprecated!
+ attribute :owned_by, Person
attribute :owner_ids, Array[Integer]
- attribute :owners, Array[Resources::Person]
+ attribute :owners, Array[Person], :default => []
attribute :planned_iteration_number, Integer
attribute :project_id, Integer
attribute :requested_by, Person
attribute :requested_by_id, Integer
attribute :story_type, String # (feature, bug, chore, release)
attribute :task_ids, Array[Integer]
- attribute :tasks, Array[Resources::Task]
+ attribute :tasks, Array[Task], :default => []
attribute :updated_at, DateTime
attribute :url, String
class UpdateRepresenter < Representable::Decorator
@@ -45,11 +47,11 @@
property :estimate
property :accepted_at
property :deadline
property :requested_by_id
property :owner_ids
- collection :labels, class: Resources::Label, decorator: Resources::Label::UpdateRepresenter, render_empty: true
+ collection :labels, class: Label, decorator: Label::UpdateRepresenter, render_empty: true
property :integration_id
property :external_id
end
# @return [String] Comma separated list of labels.
@@ -68,11 +70,11 @@
# Provides a list of all the comments on the story.
#
# @param [Hash] params
# @return [Array[Comment]]
def comments(params = {})
- if @comments && @comments.any?
+ if params.blank? && @comments.any?
@comments
else
@comments = Endpoints::Comments.new(client).get(project_id, id, params)
end
end
@@ -80,13 +82,25 @@
# Provides a list of all the tasks on the story.
#
# @param [Hash] params
# @return [Array[Task]]
def tasks(params = {})
- if @tasks && @tasks.any?
+ if params.blank? && @tasks.any?
@tasks
else
@tasks = Endpoints::Tasks.new(client).get(project_id, id, params)
+ end
+ end
+
+ # Provides a list of all the owners of the story.
+ #
+ # @param [Hash] params
+ # @return [Array[Person]]
+ def owners(params = {})
+ if params.blank? && @owners.any?
+ @owners
+ else
+ @owners = Endpoints::StoryOwners.new(client).get(project_id, id, params)
end
end
# @param [Hash] params attributes to create the task with
# @return [Task] newly created Task