This repository has been archived by the owner on Dec 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from kaimallea/next-dev
feat(album): add getAlbum
- Loading branch information
Showing
8 changed files
with
88 additions
and
4 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
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,38 @@ | ||
import { ImgurClient } from '../client'; | ||
import { getAlbum } from './getAlbum'; | ||
|
||
test('returns an album response', async () => { | ||
const accessToken = 'abc123'; | ||
const client = new ImgurClient({ accessToken }); | ||
const response = await getAlbum(client, 'XtMnA'); | ||
expect(response).toMatchInlineSnapshot(` | ||
Object { | ||
"data": Object { | ||
"description": "Dank memes", | ||
"id": "XtMnA", | ||
"image_count": 22, | ||
"images": Array [ | ||
Object { | ||
"datetime": 1316635799, | ||
"description": null, | ||
"id": "2dAns", | ||
"link": "https://i.imgur.com/2dAns.gif", | ||
"title": null, | ||
"type": "image/gif", | ||
}, | ||
Object { | ||
"datetime": 1316635800, | ||
"description": null, | ||
"id": "snAd2", | ||
"link": "https://i.imgur.com/2dAns.jpg", | ||
"title": null, | ||
"type": "image/jpeg", | ||
}, | ||
], | ||
"title": "Meme album", | ||
}, | ||
"status": 200, | ||
"success": true, | ||
} | ||
`); | ||
}); |
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,11 @@ | ||
import { ImgurClient } from '../client'; | ||
import { ALBUM_ENDPOINT } from '../common/endpoints'; | ||
import { ImgurApiResponse, AlbumData } from '../common/types'; | ||
|
||
export async function getAlbum( | ||
client: ImgurClient, | ||
albumHash: string | ||
): Promise<ImgurApiResponse<AlbumData>> { | ||
const url = `${ALBUM_ENDPOINT}/${albumHash}`; | ||
return (await client.request(url).json()) as ImgurApiResponse<AlbumData>; | ||
} |
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 @@ | ||
export * from './getAlbum'; |
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