Sha256: 75246b256c023e0c48932d58818f64ae3d1ef1414581c278a10aa22723d5c84c

Contents?: true

Size: 1.73 KB

Versions: 21

Compression:

Stored size: 1.73 KB

Contents

module Octokit
  class Client
    module PubSubHubbub
      # Subscribe to a pubsub topic
      #
      # @param topic [String] A recoginized and supported pubsub topic
      # @param callback [String] A callback url to be posted to when the topic event is fired
      # @return [boolean] true if the subscribe was successful, otherwise an error is raised
      # @example Subscribe to push events from one of your repositories, having an email sent when fired
      #   client = Octokit::Client.new(:oauth_token = "token")
      #   client.subscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
      def subscribe(topic, callback)
        options = {
          :"hub.mode" => "subscribe",
          :"hub.topic" => topic,
          :"hub.callback" => callback,
        }
        post("/hub", options, 3, true, true, true)
        true
      end

      # Unsubscribe from a pubsub topic
      #
      # @param topic [String] A recoginized pubsub topic
      # @param callback [String] A callback url to be unsubscribed from
      # @return [boolean] true if the unsubscribe was successful, otherwise an error is raised
      # @example Unsubscribe to push events from one of your repositories, no longer having an email sent when fired
      #   client = Octokit::Client.new(:oauth_token = "token")
      #   client.unsubscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
      def unsubscribe(topic, callback)
        options = {
          :"hub.mode" => "unsubscribe",
          :"hub.topic" => topic,
          :"hub.callback" => callback,
        }
        post("/hub", options, 3, true, true, true)
        true
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
octokit-1.8.0 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.7.0 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.6.1 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.6.0 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.5.0 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.4.0 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.3.0 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.2.1 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.2.0 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.1.1 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.1.0 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.0.7 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.0.6 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.0.5 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.0.4 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.0.3 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.0.2 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.0.1 lib/octokit/client/pub_sub_hubbub.rb
octokit-1.0.0 lib/octokit/client/pub_sub_hubbub.rb
octokit-0.6.5 lib/octokit/client/pub_sub_hubbub.rb