Permalink
Browse files

Added some general WebHook docs

  • Loading branch information...
1 parent b2255eb commit f5ae66f957e3a2584e9052b11a7fa017e85fb3c9 @mloughran mloughran committed Jan 25, 2012
Showing with 25 additions and 0 deletions.
  1. +5 −0 README.md
  2. +20 −0 lib/pusher/webhook.rb
View
@@ -66,6 +66,11 @@ The Pusher Gem also deals with signing requests for authenticated private channe
Read more about private channels in [the docs](http://pusher.com/docs/client_api_guide/client_channels#subscribe-private-channels) and under {Pusher::Channel#authenticate}.
+WebHooks
+--------
+
+See {Pusher::WebHook}
+
Developing
----------
View
@@ -2,6 +2,26 @@
require 'hmac-sha2'
module Pusher
+ # Used to parse and authenticate WebHooks
+ #
+ # @example
+ # post '/webhooks' do
+ # webhook = Pusher::WebHook.new(request)
+ # if webhook.valid?
+ # webhook.events.each do |event|
+ # case event["name"]
+ # when 'channel_occupied'
+ # puts "Channel occupied: #{event["channel"]}"
+ # when 'channel_vacated'
+ # puts "Channel vacated: #{event["channel"]}"
+ # end
+ # end
+ # else
+ # status 401
+ # end
+ # return
+ # end
+ #
class WebHook
attr_reader :key, :signature

0 comments on commit f5ae66f

Please sign in to comment.