Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #232 from chrispotter/master
Browse files Browse the repository at this point in the history
Hook functionality for Organizations
  • Loading branch information
pksunkara committed Mar 12, 2016
2 parents 93944cb + 9c51302 commit 20738a7
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 9 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,33 @@ ghorg.createTeam({
}, callback);
```

#### Get the hooks for a Organization (GET /orgs/flatiron/hooks)

This query supports [pagination](#pagination).

```js
ghorg.hooks(callback); //array of hooks
```

#### Create a hook (POST /orgs/flatiron/hooks)

```js
ghorg.hook({
"name": "web",
"active": true,
"events": ["push", "pull_request"],
"config": {
"url": "http://myawesomesite.com/github/events"
}
}, callback); // hook
```

#### Delete a hook (DELETE /orgs/flatiron/hooks/37)

```js
ghorg.deleteHook(37, callback);
```

## Github issues api

#### Get a single issue (GET /repos/pksunkara/hub/issues/37)
Expand Down
41 changes: 41 additions & 0 deletions lib/octonode/org.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions lib/octonode/repo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions src/octonode/org.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,26 @@ class Org
return cb(err) if err
if s isnt 204 then cb(new Error('Org addTeamRepo error')) else cb null, b, h

# List hooks
# '/orgs/flatiron/hub/hooks' GET
hooks: (params..., cb) ->
@client.get "/orgs/#{@name}/hooks", params..., (err, s, b, h) ->
return cb(err) if (err)
if s isnt 200 then cb(new Error("Org hooks error")) else cb null, b, h

# Create a hook
# '/orgs/flatiron/hub/hooks' POST
hook: (hook, cb) ->
@client.post "/orgs/#{@name}/hooks", hook, (err, s, b, h) ->
return cb(err) if err
if s isnt 201 then cb(new Error("Org createHook error")) else cb null, b, h

# Delete a hook
# '/orgs/flatiron/hub/hooks/37' DELETE
deleteHook: (id, cb) ->
@client.del "/orgs/#{@name}/hooks/#{id}", {}, (err, s, b, h) ->
return cb(err) if err
if s isnt 204 then cb(new Error("Org deleteHook error")) else cb null, b, h

# Export module
module.exports = Org
8 changes: 4 additions & 4 deletions src/octonode/repo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,15 @@ class Repo

# List hooks
# '/repos/pksunkara/hub/hooks' GET
hooks: (cb) ->
@client.get "/repos/#{@name}/hooks", (err, s, b, h) ->
hooks: (params..., cb) ->
@client.get "/repos/#{@name}/hooks",params..., (err, s, b, h) ->
return cb(err) if (err)
if s isnt 200 then cb(new Error("Repo hooks error")) else cb null, b, h

# Create a hook
# '/repos/pksunkara/hub/hooks' POST
hook: (hookInfo, cb) ->
@client.post "/repos/#{@name}/hooks", hookInfo, (err, s, b, h) ->
hook: (hook, cb) ->
@client.post "/repos/#{@name}/hooks", hook, (err, s, b, h) ->
return cb(err) if err
if s isnt 201 then cb(new Error("Repo createHook error")) else cb null, b, h

Expand Down

0 comments on commit 20738a7

Please sign in to comment.