Class: TrackerApi::Endpoints::Comment
- Defined in:
- lib/tracker_api/endpoints/comment.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #create(project_id, story_id, params = {}) ⇒ Object
- #delete(comment) ⇒ Object
-
#initialize(client) ⇒ Comment
constructor
A new instance of Comment.
- #update(comment, params = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ Comment
Returns a new instance of Comment.
6 7 8 |
# File 'lib/tracker_api/endpoints/comment.rb', line 6 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/tracker_api/endpoints/comment.rb', line 4 def client @client end |
Instance Method Details
#create(project_id, story_id, params = {}) ⇒ Object
10 11 12 13 |
# File 'lib/tracker_api/endpoints/comment.rb', line 10 def create(project_id, story_id, params={}) data = client.post("/projects/#{project_id}/stories/#{story_id}/comments", params: params).body Resources::Comment.new({ client: client, project_id: project_id }.merge(data)) end |
#delete(comment) ⇒ Object
27 28 29 30 31 |
# File 'lib/tracker_api/endpoints/comment.rb', line 27 def delete(comment) raise ArgumentError, 'Valid comment required to update.' unless comment.instance_of?(Resources::Comment) client.delete("/projects/#{comment.project_id}/stories/#{comment.story_id}/comments/#{comment.id}").body end |
#update(comment, params = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tracker_api/endpoints/comment.rb', line 15 def update(comment, params={}) raise ArgumentError, 'Valid comment required to update.' unless comment.instance_of?(Resources::Comment) path = "/projects/#{comment.project_id}/stories/#{comment.story_id}/comments/#{comment.id}" path += "?fields=:default,file_attachments" if params.represented..present? || params.represented..present? data = client.put(path, params: params).body comment.attributes = data comment.clean! comment end |