diff --git a/README.md b/README.md index 5127df7..6007d4d 100644 --- a/README.md +++ b/README.md @@ -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); ``` @@ -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); +``` diff --git a/constants/shared_albums.js b/constants/shared_albums.js new file mode 100644 index 0000000..58d1281 --- /dev/null +++ b/constants/shared_albums.js @@ -0,0 +1,7 @@ +'use strict'; + +const SHARED_ALBUMS = { + BASE_PATH: '/v1/sharedAlbums' +}; + +module.exports = SHARED_ALBUMS; diff --git a/lib/index.js b/lib/index.js index c390b33..b5e876e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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'); @@ -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; diff --git a/lib/shared_albums/index.js b/lib/shared_albums/index.js new file mode 100644 index 0000000..b62cffb --- /dev/null +++ b/lib/shared_albums/index.js @@ -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; diff --git a/package.json b/package.json index c9c9801..0ca3565 100644 --- a/package.json +++ b/package.json @@ -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": {