Class: Clubhouse::Epic
- Inherits:
-
ClubhouseResource
- Object
- ClubhouseResource
- Clubhouse::Epic
- Defined in:
- lib/clubhouse2/epic.rb
Class Method Summary collapse
Instance Method Summary collapse
- #comment(**args) ⇒ Object
- #comments(**args) ⇒ Object
- #create_comment(**args) ⇒ Object
- #stories ⇒ Object
- #to_h ⇒ Object
- #validate(args) ⇒ Object
Methods inherited from ClubhouseResource
#api_url, #delete!, #flush, inherited, #initialize, property_filter_create, property_filter_update, #resolve_to_ids, #set_properties, subclass, #update, validate, #value_format
Constructor Details
This class inherits a constructor from Clubhouse::ClubhouseResource
Class Method Details
.api_url ⇒ Object
11 12 13 |
# File 'lib/clubhouse2/epic.rb', line 11 def self.api_url 'epics' end |
.properties ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/clubhouse2/epic.rb', line 3 def self.properties [ :archived, :comments, :completed, :completed_at, :completed_at_override, :created_at, :deadline, :description, :entity_type, :external_id, :follower_ids, :id, :labels, :milestone_id, :name, :owner_ids, :position, :project_ids, :started, :started_at, :started_at_override, :state, :stats, :updated_at ] end |
Instance Method Details
#comment(**args) ⇒ Object
52 |
# File 'lib/clubhouse2/epic.rb', line 52 def comment(**args); comments(args).first; end |
#comments(**args) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/clubhouse2/epic.rb', line 31 def comments(**args) # The API is missing a parent epic ID property, so we need to fake it here args[:epic_id] = @id @comments ||= JSON.parse(@client.api_request(:get, @client.url("#{api_url}/#{Epiccomment.api_url}"))).collect { |task| Epiccomment.new(client: @client, object: comment) } @comments.reject { |s| args.collect { |k,v| s.send(k) != v }.reduce(:|) } end |
#create_comment(**args) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/clubhouse2/epic.rb', line 44 def create_comment(**args) Task.validate(args) response = JSON.parse(@client.api_request(:post, @client.url("#{api_url}/#{Epiccomment.api_url}"), :json => args)) raise ClubhouseAPIError.new(response) unless response.code == 201 @comments = nil response end |
#stories ⇒ Object
15 16 17 |
# File 'lib/clubhouse2/epic.rb', line 15 def stories @client.projects.collect(&:stories).reduce(:+).select { |s| s.epic_id == @id } end |
#to_h ⇒ Object
38 39 40 41 42 |
# File 'lib/clubhouse2/epic.rb', line 38 def to_h super.merge({ comments: @comments.collect(&:to_h) }) end |
#validate(args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/clubhouse2/epic.rb', line 19 def validate(args) raise NoSuchTeam.NoSuchTeam(args[:team_id]) unless @client.get_team(id: args[:team_id]) (args[:follower_ids] || []).each do |this_member| raise NoSuchMember.NoSuchMember(this_member) unless @client.get_member(id: this_member) end (args[:owner_ids] || []).each do |this_member| raise NoSuchMember.NoSuchMember(this_member) unless @client.get_member(id: this_member) end end |