Skip to content

Commit 2af634d

Browse files
committed
l2s init
1 parent fab4297 commit 2af634d

File tree

3 files changed

+178
-4
lines changed

3 files changed

+178
-4
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import l2s from "../../l2s.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "l2s-create-shortened-url",
6+
name: "Create Shortened URL",
7+
description: "Generates a shortened URL utilizing L2S capabilities. [See the documentation](https://docs.l2s.is/)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
l2s,
12+
url: {
13+
propDefinition: [
14+
l2s,
15+
"url",
16+
],
17+
},
18+
customKey: {
19+
propDefinition: [
20+
l2s,
21+
"customKey",
22+
],
23+
},
24+
utmSource: {
25+
propDefinition: [
26+
l2s,
27+
"utmSource",
28+
],
29+
},
30+
utmMedium: {
31+
propDefinition: [
32+
l2s,
33+
"utmMedium",
34+
],
35+
},
36+
utmCampaign: {
37+
propDefinition: [
38+
l2s,
39+
"utmCampaign",
40+
],
41+
},
42+
utmTerm: {
43+
propDefinition: [
44+
l2s,
45+
"utmTerm",
46+
],
47+
},
48+
utmContent: {
49+
propDefinition: [
50+
l2s,
51+
"utmContent",
52+
],
53+
},
54+
title: {
55+
propDefinition: [
56+
l2s,
57+
"title",
58+
],
59+
},
60+
tags: {
61+
propDefinition: [
62+
l2s,
63+
"tags",
64+
],
65+
},
66+
},
67+
async run({ $ }) {
68+
const response = await this.l2s.shortenUrl({
69+
url: this.url,
70+
customKey: this.customKey,
71+
utmSource: this.utmSource,
72+
utmMedium: this.utmMedium,
73+
utmCampaign: this.utmCampaign,
74+
utmTerm: this.utmTerm,
75+
utmContent: this.utmContent,
76+
title: this.title,
77+
tags: this.tags,
78+
});
79+
80+
$.export("$summary", "URL shortened successfully");
81+
return response;
82+
},
83+
};

components/l2s/l2s.app.mjs

Lines changed: 94 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,102 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "l2s",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
url: {
8+
type: "string",
9+
label: "URL",
10+
description: "The URL to be shortened",
11+
},
12+
customKey: {
13+
type: "string",
14+
label: "Custom Key",
15+
description: "Custom key for the shortened URL",
16+
optional: true,
17+
},
18+
utmSource: {
19+
type: "string",
20+
label: "UTM Source",
21+
description: "UTM source parameter",
22+
optional: true,
23+
},
24+
utmMedium: {
25+
type: "string",
26+
label: "UTM Medium",
27+
description: "UTM medium parameter",
28+
optional: true,
29+
},
30+
utmCampaign: {
31+
type: "string",
32+
label: "UTM Campaign",
33+
description: "UTM campaign parameter",
34+
optional: true,
35+
},
36+
utmTerm: {
37+
type: "string",
38+
label: "UTM Term",
39+
description: "UTM term parameter",
40+
optional: true,
41+
},
42+
utmContent: {
43+
type: "string",
44+
label: "UTM Content",
45+
description: "UTM content parameter",
46+
optional: true,
47+
},
48+
title: {
49+
type: "string",
50+
label: "Title",
51+
description: "Title for the shortened URL",
52+
optional: true,
53+
},
54+
tags: {
55+
type: "string[]",
56+
label: "Tags",
57+
description: "Tags associated with the URL",
58+
optional: true,
59+
},
60+
},
561
methods: {
6-
// this.$auth contains connected account data
762
authKeys() {
863
console.log(Object.keys(this.$auth));
964
},
65+
_baseUrl() {
66+
return "https://api.l2s.is";
67+
},
68+
async _makeRequest(opts = {}) {
69+
const {
70+
$ = this, method = "POST", path = "/url", headers, data,
71+
} = opts;
72+
return axios($, {
73+
method,
74+
url: this._baseUrl() + path,
75+
headers: {
76+
...headers,
77+
Authorization: `Bearer ${this.$auth.api_token}`,
78+
},
79+
data,
80+
});
81+
},
82+
async shortenUrl(opts = {}) {
83+
const {
84+
url, customKey, utmSource, utmMedium, utmCampaign, utmTerm, utmContent, title, tags,
85+
} = opts;
86+
const data = {
87+
url,
88+
customKey,
89+
utmSource,
90+
utmMedium,
91+
utmCampaign,
92+
utmTerm,
93+
utmContent,
94+
title,
95+
tags,
96+
};
97+
return this._makeRequest({
98+
data,
99+
});
100+
},
10101
},
11-
};
102+
};

components/l2s/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)