class TrackerApi::Resources::Story

Public Instance Methods

activity(params = {}) click to toggle source

Provides a list of all the activity performed on the story.

@param [Hash] params @return [Array]

# File lib/tracker_api/resources/story.rb, line 119
def activity(params = {})
  Endpoints::Activity.new(client).get_story(project_id, id, params)
end
add_label(label) click to toggle source

Adds a new label to the story.

@param [Label|Hash|String] label

# File lib/tracker_api/resources/story.rb, line 89
def add_label(label)
  new_label = if label.kind_of?(String)
    Label.new(name: label)
  else
    label
  end

  # Use attribute writer to get coercion and dirty tracking.
  self.labels = (labels ? labels.dup : []).push(new_label).uniq
end
add_owner(owner) click to toggle source

Adds a new owner to the story.

@param [Person|Fixnum] owner

# File lib/tracker_api/resources/story.rb, line 103
def add_owner(owner)
  owner_id = if owner.kind_of?(Integer)
    owner_id = owner
  else
    raise ArgumentError, 'Valid Person expected.' unless owner.instance_of?(Resources::Person)
    owner_id = owner.id
  end

  # Use attribute writer to get coercion and dirty tracking.
  self.owner_ids = (owner_ids ? owner_ids.dup : []).push(owner_id).uniq
end
blockers(params = {}) click to toggle source
# File lib/tracker_api/resources/story.rb, line 123
def blockers(params = {})
  Endpoints::Blockers.new(client).get(project_id, id, params)
end
comments(reload: false) click to toggle source

Provides a list of all the comments on the story.

@param [Hash] params @return [Array]

# File lib/tracker_api/resources/story.rb, line 131
def comments(reload: false)
  if !reload && @comments.present?
    @comments
  else
    @comments = Endpoints::Comments.new(client).get(project_id, story_id: id)
  end
end
create_comment(params) click to toggle source

@param [Hash] params attributes to create the comment with @return [Comment] newly created Comment

# File lib/tracker_api/resources/story.rb, line 194
def create_comment(params)
  files = params.delete(:files)
  comment = Endpoints::Comment.new(client).create(project_id, story_id: id, params: params)
  comment.create_attachments(files: files) if files.present?
  comment
end
create_task(params) click to toggle source

@param [Hash] params attributes to create the task with @return [Task] newly created Task

# File lib/tracker_api/resources/story.rb, line 188
def create_task(params)
  Endpoints::Task.new(client).create(project_id, id, params)
end
label_list() click to toggle source

@return [String] Comma separated list of labels.

# File lib/tracker_api/resources/story.rb, line 79
def label_list
  @label_list ||= begin
    return if labels.nil?
    labels.collect(&:name).join(',')
  end
end
owners(params = {}) click to toggle source

Provides a list of all the owners of the story.

@param [Hash] params @return [Array]

# File lib/tracker_api/resources/story.rb, line 155
def owners(params = {})
  if params.blank? && @owners.present?
    @owners
  else
    @owners = Endpoints::StoryOwners.new(client).get(project_id, id, params)
  end
end
project_id() click to toggle source

Returns the story's original (“undirtied”) project_id

@return Integer

# File lib/tracker_api/resources/story.rb, line 178
def project_id
  if dirty_attributes.key?(:project_id)
    original_attributes[:project_id]
  else
    @project_id
  end
end
reviews(params = {}) click to toggle source
# File lib/tracker_api/resources/story.rb, line 209
def reviews(params = {})
    if params.blank? && @reviews.present?
      @reviews
    else
      @reviews = Endpoints::Reviews.new(client).get(project_id, id, params)
    end
end
save() click to toggle source

Save changes to an existing Story.

# File lib/tracker_api/resources/story.rb, line 202
def save
  raise ArgumentError, 'Can not update a story with an unknown project_id.' if project_id.nil?
  return self unless dirty?

  Endpoints::Story.new(client).update(self, UpdateRepresenter.new(Story.new(self.dirty_attributes)))
end
tasks(params = {}) click to toggle source

Provides a list of all the tasks on the story.

@param [Hash] params @return [Array]

# File lib/tracker_api/resources/story.rb, line 143
def tasks(params = {})
  if params.blank? && @tasks.present?
    @tasks
  else
    @tasks = Endpoints::Tasks.new(client).get(project_id, id, params)
  end
end
transitions(params = {}) click to toggle source

Provides a list of all the transitions of the story.

@param [Hash] params @return [Array]

# File lib/tracker_api/resources/story.rb, line 167
def transitions(params = {})
  if params.blank? && @transitions.present?
    @transitions
  else
    @transitions = Endpoints::StoryTransitions.new(client).get(project_id, id, params)
  end
end