This repository has been archived by the owner on Dec 9, 2020. It is now read-only.
forked from octokit/octokit.rb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving ServiceHooks under PubSubHubBub module.
- Loading branch information
Showing
4 changed files
with
48 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Octokit | ||
class Client | ||
module PubSubHubBub | ||
module ServiceHooks | ||
|
||
# | ||
# Subscribe to a repository through pubsub | ||
# | ||
# @param owner [String] owner of mentioned repository | ||
# @param repository [String] repository name | ||
# @param service_name [String] service name owner | ||
# @param service_arguments [Hash] params that will be passed by subscibed hook. | ||
# List of services is available @ https://github.com/github/github-services/tree/master/docs. | ||
# Please refer Data node for complete list of arguments. | ||
# @example 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" }) | ||
def subscribe_service_hook(owner, repository, service_name, service_arguments = {}) | ||
topic = "https://github.com/#{owner}/#{repository}/events/push" | ||
callback = "github://#{service_name}?#{service_arguments.collect{ |k,v| [ k,v ].join("=") }.join("&") }" | ||
subscribe(topic, callback) | ||
true | ||
end | ||
|
||
# | ||
# Unsubscribe repository through pubsub | ||
# | ||
# @param owner [String] owner of mentioned repository | ||
# @param repository [String] repository name | ||
# @param service_name [String] service name owner | ||
# List of services is available @ https://github.com/github/github-services/tree/master/docs. | ||
# @example 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') | ||
def unsubscribe_service_hook(owner, repository, service_name) | ||
topic = "https://github.com/#{owner}/#{repository}/events/push" | ||
callback = "github://#{service_name}" | ||
unsubscribe(topic, callback) | ||
true | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
spec/octokit/client/service_hooks_spec.rb → ...ent/pub_sub_hub_bub/service_hooks_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters