Skip to content

Commit

Permalink
Changelog 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tnovas committed Oct 19, 2017
1 parent 70663c3 commit 1891621
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Give the credentials of the youtube to the constructor
| **RedirectUrl** | *The RedirectUrl with format 'http://yourdomain/youraction'* | **false** |
| **Key** | *The api key* | **false** |
| **Scopes** | *They are 3 scopes: https://www.googleapis.com/auth/youtube.readonly https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube.force-ssl* | **false** |
| **AccessToken** | *The access token if you have one* | **true** |

```js
let youtube = new youtubeApi('clientId', 'clientSecret', 'http://yourdomain/youraction', 'https://www.googleapis.com/auth/youtube.readonly https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube.force-ssl');
Expand Down
6 changes: 3 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ let credentialsYoutube = Symbol('credentialsYoutube');
let urlsYoutube = Symbol('urlsYoutube');

class Youtube extends OAuth2 {
constructor(clientId, clientSecret, redirectUrl, key, scopes) {
super(clientId, clientSecret, redirectUrl, scopes, 'https://accounts.google.com/o/oauth2/', 'auth', 'token');
constructor(clientId, clientSecret, redirectUrl, key, scopes, accessToken='') {
super(clientId, clientSecret, redirectUrl, scopes, accessToken, 'https://accounts.google.com/o/oauth2/', 'auth');

this[credentialsYoutube] = {
key: key,
Expand Down Expand Up @@ -75,7 +75,7 @@ class Youtube extends OAuth2 {
key: this[credentialsYoutube].key
};

return this[getYoutube](url, params).then((data) => this[credentialsYoutube].chatId = data.items[0].snippet.liveChatId);
return this[getYoutube](url, params).then((result) => this[credentialsYoutube].chatId = result.data.data.items[0].snippet.liveChatId);
}

[getYoutube](url, params) {
Expand Down
8 changes: 8 additions & 0 deletions changeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.1.0] - 2017-10-18
### Added
- AccessToken in params of constructor
### Changed
- OAuth 2.0.0
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/tnovas/youtube"
},
"email": "tnovas@gmail.com",
"version": "1.0.0",
"version": "1.1.0",
"description": "This module is a implementation of Youtube Data API V3 https://developers.google.com/youtube/v3/guides",
"main": "app.js",
"scripts": {
Expand All @@ -25,6 +25,6 @@
"dependencies": {
"axios": "^0.16.2",
"express": "^4.16.2",
"oauth20": "^1.0.7"
"oauth20": "^2.0.0"
}
}
14 changes: 11 additions & 3 deletions tests/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,18 @@ describe('youtube', function() {

it('liveBroadcast() should get live stream', () => {
var response = {
id: 1
data: {
items: [
{
snippet: {
liveChatId: 1
}
}
]
}
};

mock.onGet(urls.broadcasts).replyOnce(200, {response: {id: 1}});
mock.onGet(urls.broadcasts).replyOnce(200, response);

youtube.liveBroadcast().then(() => expect(JSON.stringify(response)).to.equal(JSON.stringify(response)));
});
Expand All @@ -151,7 +159,7 @@ describe('youtube', function() {
accessToken: 'token',
refreshToken: 'token',
expiresIn: 3600,
chatId: '',
chatId: 1,
liveId: ''
};

Expand Down

0 comments on commit 1891621

Please sign in to comment.