Skip to content

Commit

Permalink
Add new endpoint fetchPodcastsByDomain
Browse files Browse the repository at this point in the history
  • Loading branch information
wenbinf committed Apr 17, 2023
1 parent d233ba4 commit 914a8aa
Show file tree
Hide file tree
Showing 8 changed files with 11,211 additions and 8,101 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@ dist
.tern-port

.idea/
.yarn/
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Listen Notes
Copyright (c) 2023 Listen Notes

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6,620 changes: 3,721 additions & 2,899 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "podcast-api",
"version": "2.0.2",
"version": "2.0.3",
"description": "JavaScript bindings for the Listen Notes Podcast API",
"main": "src/PodcastApiClient.js",
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions src/PodcastApiMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ const addApiMethodsToClient = (client) => {
return client.httpClient._get(`/podcasts/${id}/audience`, otherParams);
};

client.fetchPodcastsByDomain = (params) => {
const { domain_name, ...otherParams } = params;
return client.httpClient._get(`/podcasts/domains/${domain_name}`, otherParams);
};

return client;
};

Expand Down
16 changes: 15 additions & 1 deletion tests/TestsLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ const runTests = (Client) => {

test('Test fetchAudienceForPodcast with mock', () => {
const client = Client();
const podcastId = 'abcde';
const podcastId = 'abcdef';
return client.fetchAudienceForPodcast({
id: podcastId,
}).then((response) => {
Expand All @@ -348,6 +348,20 @@ const runTests = (Client) => {
fail('Failed!');
});
});

test('Test fetchPodcastsByDomain with mock', () => {
const client = Client();
const domain = 'nytimes.com';
return client.fetchPodcastsByDomain({
domain_name: domain,
}).then((response) => {
expect(response.config.url).toBe(`/podcasts/domains/${domain}`);
expect(response.config.method).toBe('get');
expect(response.data.podcasts.length > 0).toBe(true);
}).catch(() => {
fail('Failed!');
});
});
};

module.exports = {
Expand Down
12,665 changes: 7,466 additions & 5,199 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 914a8aa

Please sign in to comment.