Skip to content

Commit 4ebba7c

Browse files
committed
Added actions
1 parent d481cdd commit 4ebba7c

File tree

4 files changed

+89
-10
lines changed

4 files changed

+89
-10
lines changed

components/listen_notes/actions/get-episode-details/get-episode-details.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default {
1313
app,
1414
"q",
1515
],
16+
optional: true,
1617
},
1718
language: {
1819
propDefinition: [
@@ -37,12 +38,21 @@ export default {
3738
}),
3839
],
3940
},
41+
showTranscript: {
42+
propDefinition: [
43+
app,
44+
"showTranscript",
45+
],
46+
},
4047
},
4148

4249
async run({ $ }) {
4350
const response = await this.app.getEpisodeDetails({
4451
$,
4552
id: this.id,
53+
params: {
54+
show_transcript: this.showTranscript,
55+
},
4656
});
4757

4858
$.export("$summary", `Successfully retrieved details for the episode '${response.title}'`);

components/listen_notes/actions/get-podcast-details/get-podcast-details.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default {
1313
app,
1414
"q",
1515
],
16+
optional: true,
1617
},
1718
language: {
1819
propDefinition: [
@@ -38,12 +39,28 @@ export default {
3839
}),
3940
],
4041
},
42+
nextEpisodePubDate: {
43+
propDefinition: [
44+
app,
45+
"nextEpisodePubDate",
46+
],
47+
},
48+
sort: {
49+
propDefinition: [
50+
app,
51+
"sort",
52+
],
53+
},
4154
},
4255

4356
async run({ $ }) {
4457
const response = await this.app.getPodcastDetails({
4558
$,
4659
id: this.id,
60+
params: {
61+
next_episode_pub_date: this.nextEpisodePubDate,
62+
sort: this.sort,
63+
},
4764
});
4865

4966
$.export("$summary", `Successfully retrieved details for the podcast '${response.title}'`);

components/listen_notes/common/constants.mjs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
11
export default {
2-
BOOLEAN_OPTIONS: [
3-
"0",
4-
"1",
2+
SEARCH_SORTING_OPTIONS: [
3+
{
4+
value: "0",
5+
label: "Sort by Relevance",
6+
},
7+
{
8+
value: "1",
9+
label: "Sort by Date",
10+
},
11+
],
12+
EPISODES_SORTING_OPTIONS: [
13+
{
14+
value: "recent_first",
15+
label: "Recent First",
16+
},
17+
{
18+
value: "oldest_first",
19+
label: "Oldest First",
20+
},
21+
],
22+
TRANSCRIPT_OPTIONS: [
23+
{
24+
value: "0",
25+
label: "Don't include transcript",
26+
},
27+
{
28+
value: "1",
29+
label: "Include transcript",
30+
},
531
],
632
TYPE_OPTIONS: [
733
"episode",

components/listen_notes/listen_notes.app.mjs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { axios } from "@pipedream/platform";
22
import constants from "./common/constants.mjs";
3+
import { ConfigurationError } from "@pipedream/platform";
34

45
export default {
56
type: "app",
@@ -42,7 +43,7 @@ export default {
4243
type: "string",
4344
label: "Sort By Date",
4445
description: "Sort by date. If 0, then sort by relevance. If 1, then sort by date",
45-
options: constants.BOOLEAN_OPTIONS,
46+
options: constants.SEARCH_SORTING_OPTIONS,
4647
optional: true,
4748
},
4849
type: {
@@ -52,6 +53,27 @@ export default {
5253
options: constants.TYPE_OPTIONS,
5354
optional: true,
5455
},
56+
showTranscript: {
57+
type: "string",
58+
label: "Show Transcript",
59+
description: "To include the transcript of this episode or not?",
60+
options: constants.TRANSCRIPT_OPTIONS,
61+
optional: true,
62+
},
63+
nextEpisodePubDate: {
64+
type: "string",
65+
label: "Next Episode Pub Date",
66+
description: "For episodes pagination. It's the value of `next_episode_pub_date` from the response of last request",
67+
options: constants.EPISODES_SORTING_OPTIONS,
68+
optional: true,
69+
},
70+
sort: {
71+
type: "string",
72+
label: "Sort",
73+
description: "What type of contents do you want to search for?",
74+
options: constants.EPISODES_SORTING_OPTIONS,
75+
optional: true,
76+
},
5577
language: {
5678
type: "string",
5779
label: "Language",
@@ -111,13 +133,23 @@ export default {
111133
...args,
112134
});
113135
},
136+
async getLanguages(args = {}) {
137+
return this._makeRequest({
138+
path: "/languages",
139+
...args,
140+
});
141+
},
114142
async listPodcasts({
115143
q,
116144
language,
117145
type,
118146
offset,
119147
...args
120148
}) {
149+
if (!q) {
150+
throw new ConfigurationError("You need to inform a query to list the IDs. Alternatively you can directly inform an ID unsing the custom expression function.");
151+
}
152+
121153
return this._makeRequest({
122154
path: "/search",
123155
params: {
@@ -129,11 +161,5 @@ export default {
129161
...args,
130162
});
131163
},
132-
async getLanguages(args = {}) {
133-
return this._makeRequest({
134-
path: "/languages",
135-
...args,
136-
});
137-
},
138164
},
139165
};

0 commit comments

Comments
 (0)