Skip to content

Commit 37b55f7

Browse files
committed
Added actions
1 parent 7f7145f commit 37b55f7

File tree

6 files changed

+185
-46
lines changed

6 files changed

+185
-46
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import app from "../../api_ninjas.app.mjs";
2+
3+
export default {
4+
key: "api_ninjas-check-domain",
5+
name: "Check Domain",
6+
description: "Returns domain availability status and registration details for a given domain name. [See the documentation](https://api-ninjas.com/api/domain)",
7+
version: "0.0.2",
8+
annotations: {
9+
openWorldHint: true,
10+
destructiveHint: false,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
domain: {
17+
propDefinition: [
18+
app,
19+
"domain",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.app.checkDomain({
25+
$,
26+
params: {
27+
domain: this.domain,
28+
},
29+
});
30+
$.export("$summary", "Successfully submited domain to be checked. Domain availability: " + response.available);
31+
return response;
32+
},
33+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import app from "../../api_ninjas.app.mjs";
2+
3+
export default {
4+
key: "api_ninjas-generate-password",
5+
name: "Generate Password",
6+
description: "Returns a random password string adhering to the specified parameters. [See the documentation](https://api-ninjas.com/api/passwordgenerator)",
7+
version: "0.0.1",
8+
annotations: {
9+
openWorldHint: true,
10+
destructiveHint: false,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
length: {
17+
propDefinition: [
18+
app,
19+
"length",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.app.generatePassword({
25+
$,
26+
params: {
27+
length: this.length,
28+
},
29+
});
30+
$.export("$summary", "Successfully generated password");
31+
return response;
32+
},
33+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import app from "../../api_ninjas.app.mjs";
2+
3+
export default {
4+
key: "api_ninjas-ip-lookup",
5+
name: "IP Lookup",
6+
description: "Returns the location of the IP address specified. [See the documentation](https://api-ninjas.com/api/iplookup)",
7+
version: "0.0.1",
8+
annotations: {
9+
openWorldHint: true,
10+
destructiveHint: false,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
address: {
17+
propDefinition: [
18+
app,
19+
"address",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.app.ipLookup({
25+
$,
26+
params: {
27+
address: this.address,
28+
},
29+
});
30+
$.export("$summary", "Successfully sent the request to lookup the IP: " + this.address);
31+
return response;
32+
},
33+
};
Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,62 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "api_ninjas",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
domain: {
8+
type: "string",
9+
label: "Domain",
10+
description: "Domain that will be checked",
11+
},
12+
length: {
13+
type: "string",
14+
label: "Length",
15+
description: "Length of the password that will be generated",
16+
},
17+
address: {
18+
type: "string",
19+
label: "IP",
20+
description: "IP address to lookup",
21+
},
22+
},
523
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
24+
_baseUrl() {
25+
return "https://api.api-ninjas.com/v1";
26+
},
27+
async _makeRequest(opts = {}) {
28+
const {
29+
$ = this,
30+
path,
31+
headers,
32+
...otherOpts
33+
} = opts;
34+
return axios($, {
35+
...otherOpts,
36+
url: this._baseUrl() + path,
37+
headers: {
38+
"X-Api-Key": `${this.$auth.api_key}`,
39+
...headers,
40+
},
41+
});
42+
},
43+
async checkDomain(args = {}) {
44+
return this._makeRequest({
45+
path: "/domain",
46+
...args,
47+
});
48+
},
49+
async generatePassword(args = {}) {
50+
return this._makeRequest({
51+
path: "/passwordgenerator",
52+
...args,
53+
});
54+
},
55+
async ipLookup(args = {}) {
56+
return this._makeRequest({
57+
path: "/iplookup",
58+
...args,
59+
});
960
},
1061
},
1162
};

components/api_ninjas/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/api_ninjas",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream API Ninjas Components",
55
"main": "api_ninjas.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
}
1518
}

0 commit comments

Comments
 (0)