-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.rb
42 lines (37 loc) · 927 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require "roda"
require "./.env" if File.exist?(".env.rb")
require "./notion"
class App < Roda
plugin :h
plugin :json
plugin :json_parser
route do |r|
r.post do
r.is "issues" do
params = issue_params(r)
send_to_notion(params)
params[:title]
end
end
end
private
def issue_params(r)
{
title: "#{r.params.dig("data", "issue", "metadata", "type")}",
message: r.params.dig("data", "issue", "metadata", "value"),
issue_id: r.params.dig("data", "issue", "id"),
app_id: r.params.dig("data", "issue", "project", "id"),
app_slug: r.params.dig("data", "issue", "project", "slug"),
action: r.params.dig("action")
}
end
def send_to_notion(params)
if params[:action] == "resolved"
p "Mark as done"
Notion::UpdatePage.new(params)
else
p "Create issue"
Notion::CreatePage.new(params)
end
end
end