Skip to content

Commit 247638a

Browse files
committed
Klipy #15496
Actions - Search Clips - Search GIFs - Search Stickers - Get Clip By Slug - Get GIF By Slug - Get Sticker By Slug
1 parent 2de71b2 commit 247638a

File tree

11 files changed

+170
-349
lines changed

11 files changed

+170
-349
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import klipy from "../../klipy.app.mjs";
2+
3+
export default {
4+
props: {
5+
klipy,
6+
customerId: {
7+
propDefinition: [
8+
klipy,
9+
"customerId",
10+
],
11+
},
12+
},
13+
async run({ $ }) {
14+
const model = this.getModel();
15+
const response = await this.klipy.search({
16+
$,
17+
model,
18+
slug: this.slug,
19+
data: {
20+
customer_id: this.customerId,
21+
},
22+
});
23+
24+
$.export("$summary", `Successfully fetched ${model}.`);
25+
return response;
26+
},
27+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { LIMIT } from "../../common/constants.mjs";
2+
import klipy from "../../klipy.app.mjs";
3+
4+
export default {
5+
props: {
6+
klipy,
7+
locale: {
8+
propDefinition: [
9+
klipy,
10+
"locale",
11+
],
12+
optional: true,
13+
},
14+
page: {
15+
propDefinition: [
16+
klipy,
17+
"page",
18+
],
19+
},
20+
},
21+
async run({ $ }) {
22+
const model = this.getModel();
23+
const response = await this.klipy.search({
24+
$,
25+
model,
26+
data: {
27+
q: this.q,
28+
customer_id: this.customer_id,
29+
locale: this.locale,
30+
page: this.page,
31+
per_page: LIMIT,
32+
},
33+
});
34+
$.export("$summary", `Retrieved ${response.data.data.length} ${model}`);
35+
return response;
36+
},
37+
};
Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,24 @@
1-
import klipy from "../../klipy.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import common from "../common/base-get-by-slug.mjs";
32

43
export default {
4+
...common,
55
key: "klipy-get-clips-by-slug",
66
name: "Get Clips by Slug",
7-
description: "Identify user-viewed content and recommend tailored content to the same user. [See the documentation]()",
8-
version: "0.0.{{ts}}",
7+
description: "Get a specific GIF idendified by its slug. [See the documentation](https://docs.klipy.com/clips-api/clips-search-api)",
8+
version: "0.0.1",
99
type: "action",
1010
props: {
11-
klipy,
11+
...common.props,
1212
slug: {
1313
propDefinition: [
14-
klipy,
15-
"viewClipsSlug",
16-
],
17-
},
18-
customerId: {
19-
propDefinition: [
20-
klipy,
21-
"viewClipsCustomerId",
14+
common.props.klipy,
15+
"slug",
2216
],
2317
},
2418
},
25-
async run({ $ }) {
26-
// Trigger the view action for the specified slug and customer ID
27-
await this.klipy.viewClips({
28-
slug: this.slug,
29-
customer_id: this.customerId,
30-
});
31-
32-
// Retrieve tailored content recommendations based on the viewed slug and customer ID
33-
const recommendations = await this.klipy.searchClips({
34-
q: this.slug,
35-
customer_id: this.customerId,
36-
});
37-
38-
// Export a summary of the action
39-
$.export("$summary", "Successfully identified viewed content and fetched tailored recommendations.");
40-
41-
// Return the recommended clips
42-
return recommendations;
19+
methods: {
20+
getModel() {
21+
return "clips";
22+
},
4323
},
4424
};
Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,25 @@
1-
import klipy from "../../klipy.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import common from "../common/base-get-by-slug.mjs";
32

43
export default {
4+
...common,
55
key: "klipy-get-gifs-by-slug",
66
name: "Get GIFs by Slug",
7-
description: "Identify user-viewed content and recommend tailored content to the same user. [See the documentation]()",
8-
version: "0.0.{{ts}}",
7+
description: "Identify user-viewed content and recommend tailored content to the same user. [See the documentation](https://docs.klipy.com/gifs-api/gifs-search-api)",
8+
version: "0.0.1",
99
type: "action",
1010
props: {
11-
klipy,
11+
...common.props,
1212
slug: {
1313
propDefinition: [
14-
klipy,
15-
"viewGifsSlug",
16-
],
17-
},
18-
customerId: {
19-
propDefinition: [
20-
klipy,
21-
"viewGifsCustomerId",
22-
],
23-
},
24-
searchQuery: {
25-
propDefinition: [
26-
klipy,
27-
"searchGifsQ",
14+
common.props.klipy,
15+
"slug",
2816
],
17+
description: "The slug of the GIF.",
2918
},
3019
},
31-
async run({ $ }) {
32-
// Trigger the view action for the specified GIF
33-
await this.klipy.viewGifs();
34-
35-
// Search for tailored GIFs based on the provided query
36-
const recommendations = await this.klipy.searchGifs();
37-
38-
// Export a summary of the actions performed
39-
$.export(
40-
"$summary",
41-
`Viewed GIF with slug '${this.slug}' for customer '${this.customerId}' and retrieved ${recommendations.length} recommendations.`,
42-
);
43-
44-
// Return the recommendations
45-
return recommendations;
20+
methods: {
21+
getModel() {
22+
return "gifs";
23+
},
4624
},
4725
};
Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,25 @@
1-
import klipy from "../../klipy.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import common from "../common/base-get-by-slug.mjs";
32

43
export default {
4+
...common,
55
key: "klipy-get-stickers-by-slug",
66
name: "Get Stickers By Slug",
7-
description: "Identifies user-viewed content and recommends tailored content. [See the documentation]().",
8-
version: "0.0.{{ts}}",
7+
description: "Identifies user-viewed content and recommends tailored content. [See the documentation](https://docs.klipy.com/stickers-api/stickers-search-api).",
8+
version: "0.0.1",
99
type: "action",
1010
props: {
11-
klipy,
11+
...common.props,
1212
slug: {
1313
propDefinition: [
14-
"klipy",
15-
"viewStickersSlug",
14+
common.props.klipy,
15+
"slug",
1616
],
17-
label: "Slug",
18-
description: "The slug of the sticker to identify as viewed.",
19-
},
20-
customer_id: {
21-
propDefinition: [
22-
"klipy",
23-
"viewStickersCustomerId",
24-
],
25-
label: "Customer ID",
26-
description: "A unique user identifier in your system.",
17+
description: "The slug of the sticker.",
2718
},
2819
},
29-
async run({ $ }) {
30-
// Log that the user has viewed the sticker
31-
await this.klipy.viewStickers();
32-
33-
// Recommend tailored content based on the viewed sticker
34-
const recommendations = await this.klipy._makeRequest({
35-
method: "GET",
36-
path: "/api/v1/stickers/search",
37-
params: {
38-
q: this.slug,
39-
customer_id: this.customer_id,
40-
page: 1,
41-
per_page: 24,
42-
},
43-
});
44-
45-
// Export a summary for the user
46-
$.export("$summary", `Fetched ${recommendations.length} tailored sticker recommendations for customer ID ${this.customer_id}.`);
47-
48-
// Return the recommended stickers
49-
return recommendations;
20+
methods: {
21+
getModel() {
22+
return "stickers";
23+
},
5024
},
5125
};
Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
1-
import klipy from "../../klipy.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import common from "../common/base-search.mjs";
32

43
export default {
4+
...common,
55
key: "klipy-search-clips",
66
name: "Search Clips",
77
description: "Search and retrieve clips from Klipy's database. [See the documentation](https://docs.klipy.com/clips-api/clips-search-api)",
8-
version: "0.0.{{ts}}",
8+
version: "0.0.1",
99
type: "action",
1010
props: {
11-
klipy,
11+
...common.props,
1212
q: {
1313
propDefinition: [
14-
klipy,
15-
"searchClipsQ",
14+
common.props.klipy,
15+
"q",
1616
],
1717
},
1818
customer_id: {
1919
propDefinition: [
20-
klipy,
21-
"searchClipsCustomerId",
20+
common.props.klipy,
21+
"customerId",
2222
],
2323
},
24-
locale: {
25-
propDefinition: [
26-
klipy,
27-
"searchClipsLocale",
28-
],
29-
optional: true,
30-
},
3124
},
32-
async run({ $ }) {
33-
const clips = await this.klipy.searchClips();
34-
$.export("$summary", `Retrieved ${clips.length} clips`);
35-
return clips;
25+
methods: {
26+
getModel() {
27+
return "clips";
28+
},
3629
},
3730
};
Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
1-
import klipy from "../../klipy.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import common from "../common/base-search.mjs";
32

43
export default {
4+
...common,
55
key: "klipy-search-gifs",
66
name: "Search GIFs",
77
description: "Search and retrieve GIFs from Klipy's database. [See the documentation](https://docs.klipy.com/gifs-api/gifs-search-api)",
8-
version: "0.0.{{ts}}",
8+
version: "0.0.1",
99
type: "action",
1010
props: {
11-
klipy,
11+
...common.props,
1212
q: {
1313
propDefinition: [
14-
klipy,
15-
"searchGifsQ",
14+
common.props.klipy,
15+
"q",
1616
],
17+
description: "The search keyword for finding relevant GIFs.",
1718
},
1819
customer_id: {
1920
propDefinition: [
20-
klipy,
21-
"searchGifsCustomerId",
21+
common.props.klipy,
22+
"customerId",
2223
],
23-
},
24-
locale: {
25-
propDefinition: [
26-
klipy,
27-
"searchGifsLocale",
28-
],
29-
optional: true,
24+
description: "A unique user identifier in your system for GIFs.",
3025
},
3126
},
32-
async run({ $ }) {
33-
const response = await this.klipy.searchGifs();
34-
$.export("$summary", `Successfully retrieved GIFs for query "${this.q}"`);
35-
return response;
27+
methods: {
28+
getModel() {
29+
return "gifs";
30+
},
3631
},
3732
};

0 commit comments

Comments
 (0)