Module: Brainiac::Plugins::Basecamp::Webhook
- Defined in:
- lib/brainiac/plugins/basecamp/webhook.rb
Overview
Handles inbound Basecamp webhooks.
Webhook types we care about:
- todo_assignment_changed: A todo was assigned/unassigned
- todo_completed: A todo was marked complete
- todolist_created: A new todolist appeared (potential epic)
The trigger for epic orchestration:
When a todo inside a todolist (with "Epic:" prefix) is assigned to a bot account,
OR when any todo in an epic's todolist is assigned to the bot.
Class Method Summary collapse
-
.handle(payload) ⇒ Array(Integer, String)
Process a webhook payload from Basecamp.
Class Method Details
.handle(payload) ⇒ Array(Integer, String)
Process a webhook payload from Basecamp.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/brainiac/plugins/basecamp/webhook.rb', line 24 def handle(payload) kind = payload["kind"] recording = payload["recording"] || {} details = payload["details"] || {} LOG.info "[Basecamp:Webhook] Received event: #{kind}" if defined?(LOG) case kind when "todo_assignment_changed" handle_todo_assignment(payload, recording, details) when "todo_completed" handle_todo_completed(payload, recording) when "todolist_created" handle_todolist_created(payload, recording) when "comment_created" handle_comment(payload, recording) else LOG.debug "[Basecamp:Webhook] Ignoring event kind: #{kind}" if defined?(LOG) && LOG.debug? [200, { status: "ignored", kind: kind }.to_json] end end |