class Clubhouse::Story
Public Class Methods
api_url()
click to toggle source
# File lib/clubhouse2/story.rb, line 12 def self.api_url 'stories' end
properties()
click to toggle source
# File lib/clubhouse2/story.rb, line 3 def self.properties [ :archived, :blocker, :blocked, :comment_ids, :completed, :completed_at, :completed_at_override, :created_at, :deadline, :entity_type, :epic_id, :estimate, :external_id, :file_ids, :follower_ids, :id, :linked_file_ids, :moved_at, :name, :owner_ids, :position, :project_id, :requested_by_id, :started, :started_at, :started_at_override, :story_type, :task_ids, :updated_at, :workflow_state_id, :app_url ] end
Public Instance Methods
branches(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 124 def branches(**args) @branches ||= begin full_story['branches'].collect do |branch_data| Branch.new(client: @client, object: branch_data) end end end
comment(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 138 def comment(**args); comments(args).first; end
comments(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 58 def comments(**args) @comments ||= @comment_ids.collect do |this_comment_id| comment_data = JSON.parse(@client.api_request(:get, @client.url("#{api_url}/comments/#{this_comment_id}"))) Storycomment.new(client: @client, object: comment_data) end @comments.reject { |s| args.collect { |k,v| s.send(k) != v }.reduce(:|) } end
commits(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 116 def commits(**args) @commits ||= begin full_story['commits'].collect do |commit_data| Commit.new(client: @client, object: commit_data) end end end
create_comment(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 132 def create_comment(**args) Task.validate(**args) @comments = nil JSON.parse(@client.api_request(:post, @client.url("#{api_url}/#{Storycomment.api_url}"), :json => args)) end
create_task(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 52 def create_task(**args) Task.validate(**args) @tasks = nil JSON.parse(@client.api_request(:post, @client.url("#{api_url}/#{Task.api_url}"), :json => args)) end
files(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 90 def files(**args) @client.files(story_ids: @id, **args) end
full_story(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 110 def full_story(**args) @full_story ||= begin JSON.parse(@client.api_request(:get, @client.url("#{Story.api_url}/#{id}"))) end end
labels(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 94 def labels(**args) @labels.collect { |l| @client.label(id: l['id'], **args) } end
linked_files(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 86 def linked_files(**args) @client.linked_files(story_ids: @id, **args) end
story_link(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 139 def story_link(**args); story_links(args).first; end
story_links(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 67 def story_links(**args) @story_link_objects ||= @story_links.collect do |this_story_link| link_data = JSON.parse(@client.api_request(:get, @client.url("#{Storylink.api_url}/#{this_story_link['id']}"))) link_data.reject { |k, v| v == @id} Storylink.new(client: @client, object: link_data) end @story_link_objects.reject { |s| args.collect { |k,v| s.send(k) != v }.reduce(:|) } end
task(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 140 def task(**args); tasks(args).first; end
tasks(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 77 def tasks(**args) @tasks ||= @task_ids.collect do |this_task_id| task_data = JSON.parse(@client.api_request(:get, @client.url("#{api_url}/tasks/#{this_task_id}"))) Task.new(client: @client, object: task_data) end @tasks.reject { |s| args.collect { |k,v| s.send(k) != v }.reduce(:|) } end
to_h()
click to toggle source
Calls superclass method
Clubhouse::ClubhouseResource#to_h
# File lib/clubhouse2/story.rb, line 98 def to_h super.merge({ comments: [ *comments ].collect(&:to_h), tasks: [ *tasks ].collect(&:to_h), files: [ *files ].collect(&:to_h), story_links: [ *story_links ].collect(&:to_h), labels: [ *labels ].collect(&:to_h), branches: [ *branches ].collect(&:to_h), commits: [ *commits ].collect(&:to_h), }) end
update(**args)
click to toggle source
Calls superclass method
Clubhouse::ClubhouseResource#update
# File lib/clubhouse2/story.rb, line 46 def update(**args) # The API won't let us try to update the project ID without changing it args.delete(:project_id) if args[:project_id] == @project_id super end
validate(**args)
click to toggle source
# File lib/clubhouse2/story.rb, line 16 def validate(**args) raise NoSuchEpic.new(args[:epic_id]) unless @client.epic(id: args[:epic_id]) if args[:epic_id] raise NoSuchProject.new(args[:project_id]) unless @client.project(id: args[:project_id]) if args[:project_id] raise NoSuchMember.new(args[:requested_by_id]) unless @client.member(id: args[:requested_by_id]) if args[:requested_by_id] (args[:follower_ids] || []).each do |this_member| raise NoSuchMember.new(this_member) unless @client.member(id: this_member) end (args[:owner_ids] || []).each do |this_member| raise NoSuchMember.new(this_member) unless @client.member(id: this_member) end (args[:file_ids] || []).each do |this_file| raise NoSuchFile.new(this_file) unless @client.file(id: this_file) end (args[:linked_file_ids] || []).each do |this_linked_file| raise NoSuchLinkedFile.new(this_linked_file) unless @client.linked_file(id: this_linked_file) end (args[:story_links] || []).each do |this_linked_story| raise NoSuchLinkedStory.new(this_linked_story) unless @client.story(id: this_linked_story['subject_id']) end (args[:labels] || []).collect! do |this_label| this_label.is_a? Label ? this_label : @client.label(id: this_label['name']) end end