Module: Octokit::Client::PubSubHubbub

Included in:
Octokit::Client
Defined in:
lib/octokit/client/pub_sub_hubbub.rb,
lib/octokit/client/pub_sub_hubbub/service_hooks.rb

Defined Under Namespace

Modules: ServiceHooks

Instance Method Summary collapse

Instance Method Details

#subscribe(topic, callback) ⇒ boolean

Subscribe to a pubsub topic

Examples:

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 protected]")

Parameters:

  • topic (String)

    A recoginized and supported pubsub topic

  • callback (String)

    A callback url to be posted to when the topic event is fired

Returns:

  • (boolean)

    true if the subscribe was successful, otherwise an error is raised



12
13
14
15
16
17
18
19
20
# File 'lib/octokit/client/pub_sub_hubbub.rb', line 12

def subscribe(topic, callback)
  options = {
    :"hub.mode" => "subscribe",
    :"hub.topic" => topic,
    :"hub.callback" => callback,
  }
  post("/hub", options, 3, true, true, true)
  true
end

#unsubscribe(topic, callback) ⇒ boolean

Unsubscribe from a pubsub topic

Examples:

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 protected]")

Parameters:

  • topic (String)

    A recoginized pubsub topic

  • callback (String)

    A callback url to be unsubscribed from

Returns:

  • (boolean)

    true if the unsubscribe was successful, otherwise an error is raised



30
31
32
33
34
35
36
37
38
# File 'lib/octokit/client/pub_sub_hubbub.rb', line 30

def unsubscribe(topic, callback)
  options = {
    :"hub.mode" => "unsubscribe",
    :"hub.topic" => topic,
    :"hub.callback" => callback,
  }
  post("/hub", options, 3, true, true, true)
  true
end