mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
✨ Add Raindrop node (#1464)
* ⚡ Register node and credentials * ✨ Implement OAuth2 flow * 🎨 Add SVG icon * ⚡ Add preliminary node stub * ⚡ Add preliminary generic functions * ⚡ Add resource description stubs * ✨ Implement collection:getAll * ✨ Implement collection:get * ✨ Implement collection:create * ✨ Implement collection:delete * ✨ Implement collection:update * ✨ Implement raindrop:create * ✨ Implement raindrop:delete and update * ✨ Implement user:get * ⚡ Improvements * 🎨 Touch up resource descriptions * 🎨 Rename resource description files * ⚡ Remove params for uneditable properties * ⚡ Remove unneeded success response assignment * ⚡ Update raindrop params * ⚡ Minor improvements * ⚡ Small improvement * ⚡ Minor improvements Co-authored-by: ricardo <ricardoespinoza105@gmail.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
63
packages/nodes-base/nodes/Raindrop/GenericFunctions.ts
Normal file
63
packages/nodes-base/nodes/Raindrop/GenericFunctions.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
|
||||
/**
|
||||
* Make an authenticated API request to Raindrop.
|
||||
*/
|
||||
export async function raindropApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
qs: IDataObject,
|
||||
body: IDataObject,
|
||||
option: IDataObject = {},
|
||||
) {
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'user-agent': 'n8n',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method,
|
||||
uri: `https://api.raindrop.io/rest/v1${endpoint}`,
|
||||
qs,
|
||||
body,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (!Object.keys(body).length) {
|
||||
delete options.body;
|
||||
}
|
||||
|
||||
if (!Object.keys(qs).length) {
|
||||
delete options.qs;
|
||||
}
|
||||
|
||||
if (Object.keys(option).length !== 0) {
|
||||
Object.assign(options, option);
|
||||
}
|
||||
|
||||
try {
|
||||
return await this.helpers.requestOAuth2!.call(this, 'raindropOAuth2Api', options);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
if (error?.response?.body?.errorMessage) {
|
||||
const errorMessage = error?.response?.body?.errorMessage;
|
||||
throw new Error(`Raindrop error response [${error.statusCode}]: ${errorMessage}`);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user