| 
									
										
										
										
											2022-06-21 11:23:10 +02:00
										 |  |  | /* eslint-disable n8n-nodes-base/filesystem-wrong-node-filename */ | 
					
						
							| 
									
										
										
										
											2022-06-20 15:22:10 +02:00
										 |  |  | import { INodeType, INodeTypeDescription } from 'n8n-workflow'; | 
					
						
							|  |  |  | import { httpVerbFields, httpVerbOperations } from './HttpVerbDescriptions'; | 
					
						
							| 
									
										
										
										
											2022-06-14 16:31:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | export class HttpBin implements INodeType { | 
					
						
							|  |  |  | 	description: INodeTypeDescription = { | 
					
						
							| 
									
										
										
										
											2022-06-20 15:22:10 +02:00
										 |  |  | 		displayName: 'HttpBin', | 
					
						
							|  |  |  | 		name: 'httpbin', | 
					
						
							|  |  |  | 		icon: 'file:httpbin.svg', | 
					
						
							|  |  |  | 		group: ['transform'], | 
					
						
							| 
									
										
										
										
											2022-06-14 16:31:05 +02:00
										 |  |  | 		version: 1, | 
					
						
							|  |  |  | 		subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', | 
					
						
							| 
									
										
										
										
											2022-06-20 15:22:10 +02:00
										 |  |  | 		description: 'Interact with HttpBin API', | 
					
						
							| 
									
										
										
										
											2022-06-14 16:31:05 +02:00
										 |  |  | 		defaults: { | 
					
						
							| 
									
										
										
										
											2022-06-20 15:22:10 +02:00
										 |  |  | 			name: 'HttpBin', | 
					
						
							|  |  |  | 			color: '#3b4151', | 
					
						
							| 
									
										
										
										
											2022-06-14 16:31:05 +02:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2022-06-20 15:22:10 +02:00
										 |  |  | 		inputs: ['main'], | 
					
						
							|  |  |  | 		outputs: ['main'], | 
					
						
							| 
									
										
										
										
											2022-06-14 16:31:05 +02:00
										 |  |  | 		credentials: [ | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2022-06-20 15:22:10 +02:00
										 |  |  | 				name: 'httpbinApi', | 
					
						
							| 
									
										
										
										
											2022-06-14 17:02:04 +02:00
										 |  |  | 				required: false, | 
					
						
							| 
									
										
										
										
											2022-06-14 16:31:05 +02:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 		], | 
					
						
							|  |  |  | 		requestDefaults: { | 
					
						
							| 
									
										
										
										
											2022-06-20 15:22:10 +02:00
										 |  |  | 			baseURL: 'https://httpbin.org', | 
					
						
							|  |  |  | 			url: '', | 
					
						
							| 
									
										
										
										
											2022-06-14 16:31:05 +02:00
										 |  |  | 			headers: { | 
					
						
							| 
									
										
										
										
											2022-06-20 15:22:10 +02:00
										 |  |  | 				Accept: 'application/json', | 
					
						
							|  |  |  | 				'Content-Type': 'application/json', | 
					
						
							| 
									
										
										
										
											2022-06-14 16:31:05 +02:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											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: [ | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2022-06-20 15:22:10 +02:00
										 |  |  | 				displayName: 'Resource', | 
					
						
							|  |  |  | 				name: 'resource', | 
					
						
							|  |  |  | 				type: 'options', | 
					
						
							| 
									
										
										
										
											2022-06-14 17:02:04 +02:00
										 |  |  | 				noDataExpression: true, | 
					
						
							|  |  |  | 				options: [ | 
					
						
							|  |  |  | 					{ | 
					
						
							| 
									
										
										
										
											2022-06-21 11:23:10 +02:00
										 |  |  | 						name: 'HTTP Verb', | 
					
						
							| 
									
										
										
										
											2022-06-20 15:22:10 +02:00
										 |  |  | 						value: 'httpverbs', | 
					
						
							|  |  |  | 					}, | 
					
						
							| 
									
										
										
										
											2022-06-14 17:02:04 +02:00
										 |  |  | 				], | 
					
						
							| 
									
										
										
										
											2022-06-20 15:22:10 +02:00
										 |  |  | 				default: 'httpverbs', | 
					
						
							| 
									
										
										
										
											2022-06-14 17:02:04 +02:00
										 |  |  | 			}, | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 	}; | 
					
						
							|  |  |  | } |