| 
									
										
										
										
											2025-07-31 12:11:07 +00:00
										 |  |  | import { | 
					
						
							|  |  |  | 	IAuthenticateGeneric, | 
					
						
							|  |  |  | 	ICredentialTestRequest, | 
					
						
							|  |  |  | 	ICredentialType, | 
					
						
							|  |  |  | 	INodeProperties, | 
					
						
							|  |  |  | } from 'n8n-workflow'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export class ZapSignApi implements ICredentialType { | 
					
						
							|  |  |  | 	name = 'zapSignApi'; | 
					
						
							|  |  |  | 	displayName = 'ZapSign API'; | 
					
						
							|  |  |  | 	documentationUrl = 'https://docs.zapsign.com.br/'; | 
					
						
							|  |  |  | 	properties: INodeProperties[] = [ | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			displayName: 'API Key', | 
					
						
							|  |  |  | 			name: 'apiKey', | 
					
						
							|  |  |  | 			type: 'string', | 
					
						
							|  |  |  | 			typeOptions: { | 
					
						
							|  |  |  | 				password: true, | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			default: '', | 
					
						
							|  |  |  | 			required: true, | 
					
						
							|  |  |  | 			description: 'Your ZapSign API key', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			displayName: 'Environment', | 
					
						
							|  |  |  | 			name: 'environment', | 
					
						
							|  |  |  | 			type: 'options', | 
					
						
							|  |  |  | 			options: [ | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					name: 'Production', | 
					
						
							|  |  |  | 					value: 'production', | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					name: 'Sandbox', | 
					
						
							|  |  |  | 					value: 'sandbox', | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 			], | 
					
						
							|  |  |  | 			default: 'production', | 
					
						
							|  |  |  | 			description: 'The environment to use', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 	]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	authenticate: IAuthenticateGeneric = { | 
					
						
							|  |  |  | 		type: 'generic', | 
					
						
							|  |  |  | 		properties: { | 
					
						
							|  |  |  | 			headers: { | 
					
						
							|  |  |  | 				'Authorization': '=Bearer {{$credentials.apiKey}}', | 
					
						
							|  |  |  | 				'Content-Type': 'application/json', | 
					
						
							|  |  |  | 				'Accept': 'application/json', | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	test: ICredentialTestRequest = { | 
					
						
							|  |  |  | 		request: { | 
					
						
							| 
									
										
										
										
											2025-07-31 12:19:03 +00:00
										 |  |  | 			baseURL: '={{$credentials.environment === "sandbox" ? "https://sandbox.api.zapsign.co" : "https://api.zapsign.co"}}', | 
					
						
							| 
									
										
										
										
											2025-07-31 12:11:07 +00:00
										 |  |  | 			url: '/v1/me', | 
					
						
							|  |  |  | 			method: 'GET', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | } |