class Github::Repos::PubSubHubbub

def _merge_action!(action, topic, callback, params) # :nodoc:

:nodoc:
def _merge_action!(action, topic, callback, params) # :nodoc:
  options = {
    "hub.mode"     => action.to_s,
    "hub.topic"    => topic.to_s,
    "hub.callback" => callback,
    "hub.verify"   => params.delete('verify') || 'sync',
    "hub.secret"   => params.delete('secret') || ''
  }
  params.merge! options
end

def subscribe(topic, callback, params={})


:secret => '...'
:verify => 'sync',
'github://Email?address=peter-murach@gmail.com',
'https://github.com/:user/:repo/events/push',
github.repos.pubsubhubbub.subscribe
github = Github.new :oauth_token => '...'
= Examples

* callback - Required string - The URI to receive the updates to the topic.
* topic - Required string - The URI of the GitHub repository to subscribe to. The path must be in the format of /:user/:repo/events/:event.
= Parameters

Subscribe to existing topic/event through pubsubhubbub
def subscribe(topic, callback, params={})
  _validate_presence_of topic, callback
  normalize! params
  _merge_action!("subscribe", topic, callback, params)
  post_request("/hub", params)
end

def subscribe_service(user_name, repo_name, service_name, params={})


:event => 'watch'
:token => 'abc123',
:room => 'Commits',
:subdomain => 'github',
github.repos.pubsubhubbub.subscribe_service 'user-name', 'repo-name', 'campfire',
github = Github.new :oauth_token => '...'
= Examples

* :event - Required hash key for the type of event. The default event is push
* service-name - Required string
* repo-name - Required string,
= Parameters

Subscribe repository to service hook through pubsubhubbub
def subscribe_service(user_name, repo_name, service_name, params={})
  _validate_presence_of user_name, repo_name, service_name
  normalize! params
  event = params.delete('event') || 'push'
  topic = "https://github.com/#{user_name}/#{repo_name}/events/#{event}"
  callback = "github://#{service_name}?#{params.serialize}"
  subscribe(topic, callback)
end

def unsubscribe(topic, callback, params={})


:secret => '...'
:verify => 'sync',
'github://Email?address=peter-murach@gmail.com',
'https://github.com/:user/:repo/events/push',
github.repos.pubsubhubbub.unsubscribe
github = Github.new :oauth_token => '...'
= Examples

* callback - Required string - The URI to unsubscribe the topic from.
* topic - Required string - The URI of the GitHub repository to unsubscribe from. The path must be in the format of /:user/:repo/events/:event.
= Parameters

Unsubscribe from existing topic/event through pubsubhubbub
def unsubscribe(topic, callback, params={})
  _validate_presence_of topic, callback
  normalize! params
  _merge_action!("unsubscribe", topic, callback, params)
  post_request("/hub", params)
end

def unsubscribe_service(user_name, repo_name, service_name, params={})


github.repos.pubsubhubbub.unsubscribe_service 'user-name', 'repo-name', 'campfire'
github = Github.new :oauth_token => '...'
= Examples

* :event - Optional hash key for the type of event. The default event is push
* service-name - Required string
* repo-name - Required string,
= Parameters

Subscribe repository to service hook through pubsubhubbub
def unsubscribe_service(user_name, repo_name, service_name, params={})
  _validate_presence_of user_name, repo_name, service_name
  normalize! params
  event = params.delete('event') || 'push'
  topic = "https://github.com/#{user_name}/#{repo_name}/events/#{event}"
  callback = "github://#{service_name}"
  unsubscribe(topic, callback)
end