Trello更新のフックURLを用意
WebHook登録のためGETに変更
TrelloのWebHook登録対応
レスポンスを修正
URL修正
[from now] 2014/06/18 13:32:38

diff --git a/app.rb b/app.rb
index 771b1d0..f81f934 100644
--- a/app.rb
+++ b/app.rb
@@ -58,3 +58,8 @@ head '/trello/post/:channel' do |channel|
   return 'ok'
 end

+post '/trello/post/:channel' do |channel|
+  puts params
+
+  return 'ok'
+end
[from now] 2014/06/18 13:35:13

diff --git a/app.rb b/app.rb
index f81f934..162b9f7 100644
--- a/app.rb
+++ b/app.rb
@@ -54,12 +54,14 @@ end
 #
 # Trello の更新を通知する
 #
-head '/trello/post/:channel' do |channel|
-  return 'ok'
-end
+#head '/trello/post/:channel' do |channel|
+#  return 'ok'
+#end

 post '/trello/post/:channel' do |channel|
+  puts '~~~~~~~~~~~~~~~~~~~~'
   puts params
-
+  puts '~~~~~~~~~~~~~~~~~~~~'
+
   return 'ok'
 end
[from now] 2014/06/18 13:45:19

diff --git a/app.rb b/app.rb
index 162b9f7..d79fb5b 100644
--- a/app.rb
+++ b/app.rb
@@ -60,7 +60,8 @@ end

 post '/trello/post/:channel' do |channel|
   puts '~~~~~~~~~~~~~~~~~~~~'
-  puts params
+  req = Rack::Request.new(env)
+  puts req.POST
   puts '~~~~~~~~~~~~~~~~~~~~'

   return 'ok'
[from now] 2014/06/18 13:54:22

diff --git a/app.rb b/app.rb
index d79fb5b..77e350b 100644
--- a/app.rb
+++ b/app.rb
@@ -60,8 +60,8 @@ end

 post '/trello/post/:channel' do |channel|
   puts '~~~~~~~~~~~~~~~~~~~~'
-  req = Rack::Request.new(env)
-  puts req.POST
+  request.body.rewind
+  puts request.body.read
   puts '~~~~~~~~~~~~~~~~~~~~'

   return 'ok'
[from now] 2014/06/18 14:04:11

diff --git a/app.rb b/app.rb
index 77e350b..73bfaab 100644
--- a/app.rb
+++ b/app.rb
@@ -61,7 +61,8 @@ end
 post '/trello/post/:channel' do |channel|
   puts '~~~~~~~~~~~~~~~~~~~~'
   request.body.rewind
-  puts request.body.read
+  body = ::MultiJson.load(request.body.read)
+  puts body
   puts '~~~~~~~~~~~~~~~~~~~~'

   return 'ok'
[from now] 2014/06/18 14:59:55

diff --git a/app.rb b/app.rb
index 73bfaab..32bdfab 100644
--- a/app.rb
+++ b/app.rb
@@ -60,10 +60,21 @@ end

 post '/trello/post/:channel' do |channel|
   puts '~~~~~~~~~~~~~~~~~~~~'
-  request.body.rewind
-  body = ::MultiJson.load(request.body.read)
-  puts body
+  req = TrelloRequest.new(request)
+  puts req.board
   puts '~~~~~~~~~~~~~~~~~~~~'

   return 'ok'
 end
+
+class TrelloRequest
+
+  def initialize(request)
+    request.body.rewind
+    @body = ::MultiJson.load(request.body.read)
+  end
+
+  def board
+    @body['action']['data']['board'] rescue nil
+  end
+end
[from now] 2014/06/18 15:01:04

diff --git a/app.rb b/app.rb
index 32bdfab..b324c63 100644
--- a/app.rb
+++ b/app.rb
@@ -75,6 +75,6 @@ class TrelloRequest
   end

   def board
-    @body['action']['data']['board'] rescue nil
+    @body['action']['data']['board']['name'] rescue nil
   end
 end
Deploy
Deploy
Deploy
Deploy
Deploy