Module: Octokit::Client::PubSubHubbub::ServiceHooks

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

Instance Method Summary collapse

Instance Method Details

#subscribe_service_hook(repo, service_name, service_arguments = {}) ⇒ Object

Subscribe to a repository through pubsub

Examples:

Subscribe to push events to one of your repositories to Travis-CI

client = Octokit::Client.new(:oauth_token = "token")
client.subscribe_service_hook('joshk/device_imapable', 'Travis', { :token => "test", :domain => "domain", :user => "user" })

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • service_name (String)

    service name owner

  • service_arguments (Hash) (defaults to: {})

    params that will be passed by subscibed hook. List of services is available @ github.com/github/github-services/tree/master/docs. Please refer Data node for complete list of arguments.



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

def subscribe_service_hook(repo, service_name, service_arguments = {})
  topic = "https://github.com/#{Repository.new(repo)}/events/push"
  callback = "github://#{service_name}?#{service_arguments.collect{ |k,v| [ k,v ].join("=") }.join("&") }"
  subscribe(topic, callback)
  true
end

#unsubscribe_service_hook(repo, service_name) ⇒ Object

Unsubscribe repository through pubsub

Examples:

Subscribe to push events to one of your repositories to Travis-CI

client = Octokit::Client.new(:oauth_token = "token")
client.unsubscribe_service_hook('joshk/device_imapable', 'Travis')

Parameters:



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

def unsubscribe_service_hook(repo, service_name)
  topic = "https://github.com/#{Repository.new(repo)}/events/push"
  callback = "github://#{service_name}"
  unsubscribe(topic, callback)
  true
end