-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more/better examples. Minor styling update
- Loading branch information
1 parent
8c277bd
commit 727d405
Showing
9 changed files
with
150 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,3 +73,12 @@ a { | |
a:visited { | ||
color: darken($salmon, 10%); | ||
} | ||
|
||
ul { | ||
li { | ||
margin-bottom: 0; | ||
p { | ||
margin: 0; | ||
} | ||
} | ||
} |
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
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,23 @@ | ||
--- | ||
layout: default | ||
--- | ||
|
||
## Checking the ratelimit | ||
|
||
```javascript | ||
var GitHub = require('github-api'); | ||
|
||
var gh = new GitHub(); | ||
|
||
// check our rate-limit status | ||
// since we're unauthenticated the limit is 60 requests per hour | ||
gh.getRateLimit().getRateLimit() | ||
.then(function(resp) { | ||
console.log('Limit remaining: ' + resp.data.rate.remaining); | ||
// date constructor takes epoch milliseconds and we get epoch seconds | ||
console.log('Reset date: ' + new Date(resp.data.rate.reset * 1000)); | ||
}).catch(function(error) { | ||
console.log('Error fetching rate limit', error.message); | ||
}); | ||
|
||
``` |
This file was deleted.
Oops, something went wrong.
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,71 @@ | ||
--- | ||
layout: default | ||
--- | ||
|
||
## List the webhooks for a user's repositories | ||
```javascript | ||
var GitHub = require("github-api"); | ||
var Promise = require("es6-promise").Promise; | ||
|
||
var gh = new GitHub({ | ||
username: 'foo', | ||
password: 'bar' | ||
}); | ||
|
||
var user = 'slunk32'; | ||
gh.getUser(user).getRepos() | ||
// turn the json objects we fetched into `Repository`s | ||
.then(function(httpPromise) { | ||
return httpPromise.data.map(function(repoJson) { | ||
// console.log('repo ' repoJson.name); | ||
return gh.getRepo(user, repoJson.name); | ||
}); | ||
}) | ||
// Curry promises to fetch webhooks | ||
.then(function(repos) { | ||
console.log(repos); | ||
return Promise.all(repos.map(function(repo) { | ||
return repo.listHooks(); | ||
})); | ||
}) | ||
// Fetch the webhooks json | ||
.then(function(listOfListOfHooks) { | ||
listOfListOfHooks = listOfListOfHooks || []; // monkey-patch for non-authenticated users | ||
listOfListOfHooks.forEach(function(hooksHttpResonse) { | ||
console.log('hooks for ' hooksHttpResonse.config.url); | ||
console.log(hooksHttpResonse.data); | ||
}); | ||
}) | ||
.catch(function(error) { | ||
console.log('an error occurred fetching the webhooks', error); | ||
}); | ||
``` | ||
|
||
## Create a new webhook | ||
```javascript | ||
var GitHub = require("github-api"); | ||
var Promise = require("es6-promise").Promise; | ||
|
||
var gh = new GitHub({ | ||
username: 'foo', | ||
password: 'bar' | ||
}); | ||
|
||
var fork = gh.getRepository('user', 'repo'); | ||
|
||
var hookDef = { | ||
"name" : "travis", | ||
"config" : { | ||
"user" : "your-Username", | ||
"token" : "00000000000000000000000000", | ||
"domain" : "http://notify.travis-ci.org", | ||
"content_type": "json" | ||
}, | ||
"events" : ["push", "pull_request"], | ||
"active" : true | ||
} | ||
fork.createHook(hookDef) | ||
.then(function({data: hook}) { | ||
console.log("A travis hook has been created which will trigger a build on push and pull request events..."); | ||
}); | ||
``` |
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