n8n-nodes-apiinfo 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # n8n-nodes-apiinfo
2
+
3
+ This is an n8n community node. It lets you interact with ApiInfo in your n8n workflows.
4
+
5
+ [n8n](https://n8n.io/) is a fair-code licensed workflow automation platform.
6
+
7
+ ## Installation
8
+
9
+ Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
10
+
11
+ ## Credentials
12
+
13
+ No credentials are required for this node.
14
+
15
+ ## Compatibility
16
+
17
+ - n8n v0.124.0 or later
18
+
19
+ ## Operations
20
+
21
+ - **Info**: Get information from the API.
22
+
23
+ ## Resources
24
+
25
+ - [n8n Community Nodes](https://n8n.io/integrations/community-nodes/)
26
+
27
+ ## API Documentation
28
+
29
+ ### GET /{ip_address}
30
+ **Get details for IP**
31
+ Retrieve details for a specific IPv4 or IPv6 address.
32
+
33
+ ### GET /{ip_address}/org
34
+ **Filter response by org field**
35
+ Get the organization field as plaintext for a specific IP address.
36
+
37
+ ### GET /{ip_address}/city
38
+ **Filter response by city field**
39
+ Get the city as plaintext for a specific IP address.
40
+
41
+ ### GET /{ip_address}/country
42
+ **Filter response by country field**
43
+ Get country ISO code as plaintext for a specific IP address.
@@ -53,6 +53,59 @@ class ApiInfo {
53
53
  ],
54
54
  default: 'get',
55
55
  },
56
+ {
57
+ displayName: 'IP Address',
58
+ name: 'ip',
59
+ type: 'string',
60
+ default: '',
61
+ placeholder: '1.1.1.1',
62
+ description: 'The IP address to lookup',
63
+ displayOptions: {
64
+ show: {
65
+ resource: [
66
+ 'info',
67
+ ],
68
+ operation: [
69
+ 'get',
70
+ ],
71
+ },
72
+ },
73
+ },
74
+ {
75
+ displayName: 'Field',
76
+ name: 'field',
77
+ type: 'options',
78
+ default: 'all',
79
+ description: 'Specific field to retrieve',
80
+ displayOptions: {
81
+ show: {
82
+ resource: [
83
+ 'info',
84
+ ],
85
+ operation: [
86
+ 'get',
87
+ ],
88
+ },
89
+ },
90
+ options: [
91
+ {
92
+ name: 'All Details',
93
+ value: 'all',
94
+ },
95
+ {
96
+ name: 'Organization',
97
+ value: 'org',
98
+ },
99
+ {
100
+ name: 'City',
101
+ value: 'city',
102
+ },
103
+ {
104
+ name: 'Country',
105
+ value: 'country',
106
+ },
107
+ ],
108
+ },
56
109
  ],
57
110
  };
58
111
  }
@@ -60,26 +113,37 @@ class ApiInfo {
60
113
  const items = this.getInputData();
61
114
  const returnData = [];
62
115
  const length = items.length;
63
- const qs = {};
64
116
  let responseData;
65
117
  const resource = this.getNodeParameter('resource', 0);
66
118
  const operation = this.getNodeParameter('operation', 0);
67
119
  for (let i = 0; i < length; i++) {
68
- if (resource === 'info') {
69
- if (operation === 'get') {
70
- // Placeholder for actual API call
71
- responseData = {
72
- message: 'ApiInfo Node executed successfully',
73
- timestamp: new Date().toISOString(),
74
- inputIndex: i,
75
- };
120
+ try {
121
+ if (resource === 'info' && operation === 'get') {
122
+ const ip = this.getNodeParameter('ip', i);
123
+ const field = this.getNodeParameter('field', i);
124
+ let path = `/${ip}`;
125
+ if (field !== 'all') {
126
+ path += `/${field}`;
127
+ }
128
+ responseData = await this.helpers.httpRequest({
129
+ method: 'GET',
130
+ url: `https://ipinfo.io${path}`,
131
+ json: true,
132
+ });
133
+ }
134
+ if (Array.isArray(responseData)) {
135
+ returnData.push.apply(returnData, responseData);
136
+ }
137
+ else if (responseData !== undefined) {
138
+ returnData.push({ json: responseData });
76
139
  }
77
140
  }
78
- if (Array.isArray(responseData)) {
79
- returnData.push.apply(returnData, responseData);
80
- }
81
- else if (responseData !== undefined) {
82
- returnData.push({ json: responseData });
141
+ catch (error) {
142
+ if (this.continueOnFail()) {
143
+ returnData.push({ json: { error: error.message } });
144
+ continue;
145
+ }
146
+ throw error;
83
147
  }
84
148
  }
85
149
  return [returnData];
@@ -1 +1 @@
1
-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AAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;wBAC1C,MAAM,EAAE,KAAK;wBACb,GAAG,EAAE,oBAAoB,IAAI,EAAE;wBAC/B,IAAI,EAAE,IAAI;qBACb,CAAC,CAAC;iBACN;gBAED,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;oBAC7B,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,YAAoC,CAAC,CAAC;iBAC3E;qBAAM,IAAI,YAAY,KAAK,SAAS,EAAE;oBACnC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAwB,CAAC,CAAC;iBACjE;aACJ;YAAC,OAAO,KAAK,EAAE;gBACZ,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE;oBACvB,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;oBAC/D,SAAS;iBACZ;gBACD,MAAM,KAAK,CAAC;aACf;SACJ;QACD,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;CACJ;AApJD,0BAoJC"}
@@ -1 +1,32 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+
4
+ <svg
5
+ width="24"
6
+ height="24"
7
+ viewBox="0 0 6.3499999 6.3500002"
8
+ version="1.1"
9
+ id="svg1"
10
+ xml:space="preserve"
11
+ xmlns="http://www.w3.org/2000/svg"
12
+ xmlns:svg="http://www.w3.org/2000/svg"><defs
13
+ id="defs1" /><g
14
+ id="layer1"><g
15
+ id="g2"
16
+ transform="matrix(0.01249767,0,0,0.01249767,-0.00311225,0.00762118)"><path
17
+ d="m 254.341,402.054 c -7.865,0 -15.65,-2.996 -21.65,-8.995 L 8.995,229.363 C -3,217.368 -3,197.915 8.995,185.92 l 223.696,-223.696 c 11.995,-11.995 31.448,-11.995 43.443,0 l 223.696,223.696 c 11.995,11.995 11.995,31.448 0,43.443 L 276.134,393.202 c -6,5.999 -13.864,8.852 -21.793,8.852 z M 54.129,207.642 254.42,407.933 454.71,207.642 254.42,7.351 Z"
18
+ id="path1"
19
+ style="fill:#ea475b;fill-opacity:1" /><path
20
+ d="M 254.341,508.311 C 114.07,508.311 0,394.241 0,253.97 0,113.7 114.07,0 254.341,0 c 140.271,0 254.341,114.07 254.341,253.97 0,140.271 -114.07,254.341 -254.341,254.341 z m 0,-477.591 c -123.298,0 -223.621,100.323 -223.621,223.621 0,123.298 100.323,223.621 223.621,223.621 123.298,0 223.621,-100.323 223.621,-223.621 C 477.962,131.043 377.639,30.72 254.341,30.72 Z"
21
+ id="path2"
22
+ style="fill:#ea475b;fill-opacity:1" /><g
23
+ id="g1"><path
24
+ d="m 171.181,337.899 c 0,-32.843 38.62,-58.583 66.864,-82.723 23.906,-25.134 22.985,-38.334 22.985,-46.315 0,-14.735 -9.517,-22.099 -24.25,-22.099 -17.804,0 -24.558,11.665 -25.172,27.318 l -57.098,-8.597 c 1.229,-36.837 26.706,-63.509 82.269,-63.509 52.179,0 80.735,28.85 80.735,68.106 0,27.625 -18.725,56.772 -47.28,81.187 -23.018,19.339 -28.528,31.311 -28.528,46.623 h -70.525 z"
25
+ id="path3"
26
+ style="fill:#ea475b;fill-opacity:1" /><rect
27
+ x="171.181"
28
+ y="359.38599"
29
+ width="70.525002"
30
+ height="70.525002"
31
+ id="rect1"
32
+ style="fill:#ea475b;fill-opacity:1" /></g></g></g></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-apiinfo",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "n8n node for ApiInfo",
5
5
  "keywords": [
6
6
  "n8n-community-node-package"
@@ -35,4 +35,4 @@
35
35
  "tslint": "^6.1.2",
36
36
  "typescript": "^4.0.2"
37
37
  }
38
- }
38
+ }