Skip to content

Commit

Permalink
Update README for new data format
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed May 27, 2017
1 parent 33f2abd commit e3a19e4
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,32 @@ yarn add gitnews

You must first create a GitHub token so the module has access to your notifications. To create the token, visit the [Tokens](https://github.com/settings/tokens) page and generate a new token for the app. You can call it "gitnews" and it needs at least `notifications` scope and the `repo` scope.

Then import the `getNotifications` named function and pass it the token. (There is also a `getReadNotifications` function to return already-read notifications.)
Then import the `getNotifications` named function and pass it the token.

```js
const { getNotifications } = require( 'gitnews' );
getNotifications( token )
.then( notes => notes.filter( note => note.unread ) )
.then( notes => notes.map( showNotification ) );

function showNotification( note ) {
console.log( note.repository.full_name + ': ' + note.subject.title + ' -- ' + note.html_url );
}
```

The function will return a Promise. When the Promise resolves, it will pass the callback an array of notification objects. Each notification object has several properties, of which the most relevant are those listed below:
The function will return a Promise. When the Promise resolves, it will pass the callback an array of notification objects. Each notification object has the properties listed below:

- `updated_at`: The time (in ISO 8601 format) of the notification.
- `updatedAt`: The time (in ISO 8601 format) of the notification.
- `unread`: True if the notification has not been seen.
- `repository.name`: The Repository name (eg: `gitnews`).
- `repository.full_name`: The full Repository name (eg: `sirbrillig/gitnews`).
- `subject.title`: The title of the notification.
- `html_url`: The URL of the notification.
- `repositoryName`: The Repository name (eg: `gitnews`).
- `repositoryFullName`: The full Repository name (eg: `sirbrillig/gitnews`).
- `title`: The title of the notification.
- `type`: The type of the notification.
- `id`: A unique ID for this notification (at its most recently updated timestamp).
- `private`: True if the notification repo is private.
- `commentUrl`: The URL of the notification's most recent comment.
- `subjectUrl`: The URL of the notification's issue or PR.
- `commentAvatar`: The URL of the image for the notification's most recent commenter.
- `repositoryOwnerAvatar`: The URL of the image for the Repository's owner.

If you need additional data, the actual GitHub API responses are stored under the `api` property.

0 comments on commit e3a19e4

Please sign in to comment.