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:

  • owner (String)

    owner of mentioned repository

  • repository (String)

    repository name

  • 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.



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

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:



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

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