Skip to content

Commit 14499d8

Browse files
authored
[Components] ipstack #17207 (#17284)
* Added actions * Added actions * Added actions
1 parent ece8500 commit 14499d8

File tree

5 files changed

+156
-7
lines changed

5 files changed

+156
-7
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import app from "../../ipstack.app.mjs";
2+
3+
export default {
4+
key: "ipstack-ip-lookup",
5+
name: "IP Lookup",
6+
description: "Look up single IPv4 or IPv6 addresses. [See the documentation](https://ipstack.com/documentation#standard)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
ip: {
12+
propDefinition: [
13+
app,
14+
"ip",
15+
],
16+
},
17+
hostname: {
18+
propDefinition: [
19+
app,
20+
"hostname",
21+
],
22+
},
23+
security: {
24+
propDefinition: [
25+
app,
26+
"security",
27+
],
28+
},
29+
language: {
30+
propDefinition: [
31+
app,
32+
"language",
33+
],
34+
},
35+
},
36+
async run({ $ }) {
37+
const response = await this.app.ipLookup({
38+
$,
39+
ip: this.ip,
40+
params: {
41+
hostname: this.hostname
42+
? 1
43+
: 0,
44+
security: this.security
45+
? 1
46+
: 0,
47+
language: this.language,
48+
},
49+
});
50+
$.export("$summary", "Successfully retrieved data for the IP " + this.ip);
51+
return response;
52+
},
53+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export default {
2+
3+
LANGUAGE_OPTIONS: [
4+
{
5+
value: "en",
6+
label: "English/US",
7+
},
8+
{
9+
value: "de",
10+
label: "German",
11+
},
12+
{
13+
value: "es",
14+
label: "Spanish",
15+
},
16+
{
17+
value: "fr",
18+
label: "French",
19+
},
20+
{
21+
value: "ja",
22+
label: "Japanese",
23+
},
24+
{
25+
value: "pt-br",
26+
label: "Portugues (Brazil)",
27+
},
28+
{
29+
value: "ru",
30+
label: "Russian",
31+
},
32+
{
33+
value: "zh",
34+
label: "Chinese",
35+
},
36+
],
37+
};

components/ipstack/ipstack.app.mjs

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,63 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "ipstack",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
ip: {
9+
type: "string",
10+
label: "IP",
11+
description: "IPv4 or IPv6 address to be looked up",
12+
},
13+
hostname: {
14+
type: "boolean",
15+
label: "Hostname",
16+
description: "If set to `true`, hostname lookup will be included in the API response",
17+
optional: true,
18+
},
19+
security: {
20+
type: "boolean",
21+
label: "Security",
22+
description: "If set to `true`, includes security module in the API response",
23+
optional: true,
24+
},
25+
language: {
26+
type: "string",
27+
label: "Language",
28+
description: "Output language using 2-letter ISO 639-1 format",
29+
optional: true,
30+
options: constants.LANGUAGE_OPTIONS,
31+
},
32+
},
533
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
34+
_baseUrl() {
35+
return "https://api.ipstack.com";
36+
},
37+
async _makeRequest(opts = {}) {
38+
const {
39+
$ = this,
40+
path,
41+
params,
42+
...otherOpts
43+
} = opts;
44+
return axios($, {
45+
...otherOpts,
46+
url: this._baseUrl() + path,
47+
params: {
48+
access_key: `${this.$auth.access_key}`,
49+
...params,
50+
},
51+
});
52+
},
53+
54+
async ipLookup({
55+
ip, ...args
56+
}) {
57+
return this._makeRequest({
58+
path: `/${ip}`,
59+
...args,
60+
});
961
},
1062
},
1163
};

components/ipstack/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/ipstack",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream ipstack Components",
55
"main": "ipstack.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)