Skip to content

Commit

Permalink
Add shared albums to API
Browse files Browse the repository at this point in the history
  • Loading branch information
roopakv committed May 22, 2018
1 parent 0b486b8 commit 632f717
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ const photos = new Photos(your_google_auth_token);

### list

The default page size used is 50 and pageToken is ignored if not passed in.

```
const response = await photos.albums.list();
const response = await photos.albums.list(pageSize, pageToken);
// const response = await photos.albums.list(pageSize);
doSomethingWithResponse(response);
```

Expand Down Expand Up @@ -63,3 +66,21 @@ const textEnrichment = {
};
const response = await photos.albums.addEnrichment(albumId, textEnrichment, albumPosition);
```

## Shared Albums

### list

Default pageSize is 50 and pageToken is optional.

```
const response = await photos.sharedAlbums.list(pageSize, pageToken);
doSomethingWithResponse(response);
```

### join

```
const response = await photos.sharedAlbums.join(shareToken);
doSomethingWithResponse(response);
```
7 changes: 7 additions & 0 deletions constants/shared_albums.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const SHARED_ALBUMS = {
BASE_PATH: '/v1/sharedAlbums'
};

module.exports = SHARED_ALBUMS;
3 changes: 3 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const Albums = require('./albums');
const SharedAlbums = require('./shared_albums');

const TextEnrichment = require('./albums/text_enrichment');
const MapEnrichment = require('./albums/map_enrichment');
const LocationEnrichment = require('./albums/location_enrichment');
Expand All @@ -12,6 +14,7 @@ class Photos {
constructor(authToken) {
this.transport = new Transport(authToken);
this.albums = new Albums(this.transport);
this.sharedAlbums = new SharedAlbums(this.transport);

this.Location = Location;
this.TextEnrichment = TextEnrichment;
Expand Down
19 changes: 19 additions & 0 deletions lib/shared_albums/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

const constants = require('../../constants/shared_albums');

class SharedAlbums {
constructor(transport) {
this.transport = transport;
}

join(shareToken) {
return this.transport.post(`${constants.BASE_PATH}:join`, {shareToken});
}

list(pageSize = 50, pageToken) {
return this.transport.get(constants.BASE_PATH, {pageSize, pageToken});
}
}

module.exports = SharedAlbums;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "googlephotos",
"version": "0.1.0",
"version": "0.1.1",
"description": "Library to make hitting the Google Photos API easy",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 632f717

Please sign in to comment.