Module: ActiveProject::Adapters::Trello::Comments

Included in:
ActiveProject::Adapters::TrelloAdapter
Defined in:
lib/active_project/adapters/trello/comments.rb

Instance Method Summary collapse

Instance Method Details

#add_comment(card_id, comment_body, _context = {}) ⇒ ActiveProject::Resources::Comment

Adds a comment to a Card in Trello.

Parameters:

  • card_id (String)

    The ID of the Trello Card.

  • comment_body (String)

    The comment text (Markdown).

  • context (Hash)

    Optional context (ignored).

Returns:



12
13
14
15
16
17
# File 'lib/active_project/adapters/trello/comments.rb', line 12

def add_comment(card_id, comment_body, _context = {})
  path = "cards/#{card_id}/actions/comments"
  query_params = { text: comment_body }
  comment_data = make_request(:post, path, nil, query_params)
  map_comment_action_data(comment_data, card_id)
end

#delete_comment(comment_id, context = {}) ⇒ Boolean

Deletes a comment from a Card in Trello.

Parameters:

  • comment_id (String)

    The ID of the comment action to delete.

  • context (Hash) (defaults to: {})

    Required context: { card_id: ‘…’ }.

Returns:

  • (Boolean)

    True if successfully deleted.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/active_project/adapters/trello/comments.rb', line 41

def delete_comment(comment_id, context = {})
  card_id = context[:card_id]
  unless card_id
    raise ArgumentError,
          "Missing required context: :card_id must be provided for TrelloAdapter#delete_comment"
  end

  path = "cards/#{card_id}/actions/#{comment_id}/comments"
  make_request(:delete, path)
  true
end

#update_comment(comment_id, body, context = {}) ⇒ ActiveProject::Resources::Comment

Updates a comment on a Card in Trello.

Parameters:

  • comment_id (String)

    The ID of the comment action.

  • body (String)

    The new comment text (Markdown).

  • context (Hash) (defaults to: {})

    Required context: { card_id: ‘…’ }.

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/active_project/adapters/trello/comments.rb', line 24

def update_comment(comment_id, body, context = {})
  card_id = context[:card_id]
  unless card_id
    raise ArgumentError,
          "Missing required context: :card_id must be provided for TrelloAdapter#update_comment"
  end

  path = "cards/#{card_id}/actions/#{comment_id}/comments"
  query_params = { text: body }
  comment_data = make_request(:put, path, nil, query_params)
  map_comment_action_data(comment_data, card_id)
end