Skip to content

Commit f29bf39

Browse files
committed
Add fetchAudienceForPodcast function.
1 parent 3459adc commit f29bf39

File tree

6 files changed

+3385
-2493
lines changed

6 files changed

+3385
-2493
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Listen Notes
3+
Copyright (c) 2022 Listen Notes
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 3357 additions & 2490 deletions
Large diffs are not rendered by default.

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
GROUP_ID=com.listennotes
2-
VERSION_NAME=1.1.1
2+
VERSION_NAME=1.1.4
33

44
POM_URL=https://github.com/ListenNotes/podcast-api-java
55
POM_SCM_URL[email protected]:ListenNotes/podcast-api-java.git
@@ -12,7 +12,7 @@ POM_DEVELOPER_ID=listennotes
1212
POM_DEVELOPER_NAME=Listen Notes, Inc.
1313
POM_DEVELOPER_EMAIL[email protected]
1414

15-
POM_DESCRIPTION=The Official Java library for the Listen Notes Podcast API. Simple & no-nonsense podcast search & directory API.
15+
POM_DESCRIPTION=The Official Java library for the Listen Notes Podcast API. Simple & no-nonsense podcast search, directory, and insights API.
1616
POM_NAME=Podcast Search and Directory API
1717
POM_ARTIFACT_ID=podcast-api
1818
POM_PACKAGING=jar

src/main/java/com/listennotes/podcast_api/Client.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ public ApiResponse search(Map<String, String> mapParams) throws ListenApiExcepti
153153
return this.get("search", mapParams);
154154
}
155155

156+
public ApiResponse fetchAudienceForPodcast(Map<String, String> mapParams) throws ListenApiException {
157+
String strId = mapParams.get("id");
158+
mapParams.remove("id");
159+
return this.get("podcasts/" + strId + "/audience", mapParams);
160+
}
161+
156162
protected String getUrl(String strPath) {
157163
String strUrl = BASE_URL_TEST;
158164
if (this.apiKey != null &&this.apiKey.length() > 0) {

src/main/java/com/listennotes/podcast_api/Sample.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ public static void main(String[] args) {
122122
// parameters.put("reason", "the podcaster wants to delete it");
123123
// response = objClient.deletePodcast( parameters );
124124
// System.out.println(response.toJSON().toString(2));
125+
126+
// parameters = new HashMap<>();
127+
// parameters.put("id", "25212ac3c53240a880dd5032e547047b");
128+
// response = objClient.fetchRecommendationsForPodcast( parameters );
129+
// System.out.println(response.toJSON().toString(2));
125130
} catch (AuthenticationException ae) {
126131
System.out.println("Authentication Issue: " + ae.getMessage());
127132
} catch (InvalidRequestException ir) {

src/test/java/com/listennotes/podcast_api/ClientTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,4 +354,18 @@ public void testSubmitPodcast() throws Exception {
354354
URL u = tester.con.getURL();
355355
assertEquals(u.getPath(), "/api/v2/podcasts/submit");
356356
}
357+
358+
public void testFetchAudienceForPodcast() throws Exception {
359+
Client tester = new Client();
360+
361+
Map<String, String> parameters = new HashMap<>();
362+
String id = "23";
363+
parameters.put("id", id);
364+
ApiResponse response = tester.fetchAudienceForPodcast(parameters);
365+
JSONObject oj = response.toJSON();
366+
assertTrue(oj.optJSONArray("by_regions").length() > 0);
367+
assertEquals(tester.con.getRequestMethod(), "GET");
368+
URL u = tester.con.getURL();
369+
assertEquals(u.getPath(), "/api/v2/podcasts/" + id + "/audience");
370+
}
357371
}

0 commit comments

Comments
 (0)