2022-06-14 16:31:05 +02:00
|
|
|
import { INodeType, INodeTypeDescription } from "n8n-workflow";
|
2022-06-16 12:00:05 +02:00
|
|
|
import { httpVerbOperations, httpVerbFields } from "./HttpVerbDescriptions";
|
2022-06-14 16:31:05 +02:00
|
|
|
|
|
|
|
|
export class HttpBin implements INodeType {
|
|
|
|
|
description: INodeTypeDescription = {
|
|
|
|
|
displayName: "HttpBin",
|
|
|
|
|
name: "httpbin",
|
|
|
|
|
icon: "file:httpbin.svg",
|
|
|
|
|
group: ["transform"],
|
|
|
|
|
version: 1,
|
|
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
|
|
|
description: "Interact with HttpBin API",
|
|
|
|
|
defaults: {
|
2022-06-14 17:02:04 +02:00
|
|
|
name: "HttpBin",
|
|
|
|
|
color: "#3b4151",
|
2022-06-14 16:31:05 +02:00
|
|
|
},
|
|
|
|
|
inputs: ["main"],
|
|
|
|
|
outputs: ["main"],
|
|
|
|
|
credentials: [
|
|
|
|
|
{
|
2022-06-14 17:02:04 +02:00
|
|
|
name: "httpbinApi",
|
|
|
|
|
required: false,
|
2022-06-14 16:31:05 +02:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
requestDefaults: {
|
2022-06-16 12:00:05 +02:00
|
|
|
baseURL: "https://httpbin.org",
|
2022-06-14 16:31:05 +02:00
|
|
|
url: "",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-06-14 17:02:04 +02:00
|
|
|
/**
|
|
|
|
|
* In the properties array we have two mandatory options objects required
|
|
|
|
|
*
|
2022-06-16 15:03:56 +02:00
|
|
|
* [Resource & Operation]
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* https://docs.n8n.io/integrations/creating-nodes/code/create-first-node/#resources-and-operations
|
|
|
|
|
*
|
|
|
|
|
* In our example, the operations are separated into their own file (HTTPVerbDescription)
|
|
|
|
|
* to keep this class easy to read
|
2022-06-14 17:02:04 +02:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
properties: [
|
|
|
|
|
{
|
|
|
|
|
displayName: "Resource",
|
|
|
|
|
name: "resource",
|
|
|
|
|
type: "options",
|
|
|
|
|
noDataExpression: true,
|
|
|
|
|
options: [
|
|
|
|
|
{
|
2022-06-16 12:00:05 +02:00
|
|
|
name: "HTTP Verbs",
|
2022-06-14 17:02:04 +02:00
|
|
|
value: "httpverbs",
|
2022-06-20 14:21:52 +02:00
|
|
|
}
|
2022-06-14 17:02:04 +02:00
|
|
|
],
|
|
|
|
|
default: "httpverbs",
|
|
|
|
|
},
|
2022-06-16 15:03:56 +02:00
|
|
|
|
2022-06-16 12:00:05 +02:00
|
|
|
...httpVerbOperations,
|
|
|
|
|
...httpVerbFields,
|
2022-06-14 17:02:04 +02:00
|
|
|
],
|
2022-06-14 16:31:05 +02:00
|
|
|
};
|
|
|
|
|
}
|