mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat(Todoist Node): Make it possible to move tasks between sections (#3074)
* refactor todoist implementation and break code into separate classes * add move item between sections functionality * add todoist sync integration * rebase with master * Fixed get task returning only true * Fix empty response bug * Fixed bug which prevented sections from being loaded * Removed crendentials from node and injected directly in credentials file * Remove console.logs * Changed parameter name for coherence * Fixed error * 🐛 Fix merge issues * ⚡ Improvements * 🔥 Remove unnecessary code * 👕 Fix linting issue * 👕 Fix linting issue * 🐛 Fix ts issue * 👕 Fix linting issue Co-authored-by: Rahim Rahimli <ragim95@gmail.com> Co-authored-by: Ricardo Espinoza <ricardo@n8n.io> Co-authored-by: ricardo <ricardoespinoza105@gmail.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -12,6 +12,8 @@ import {
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export type Context = IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions;
|
||||
|
||||
export function FormatDueDatetime(isoString: string): string {
|
||||
// Assuming that the problem with incorrect date format was caused by milliseconds
|
||||
// Replacing the last 5 characters of ISO-formatted string with just Z char
|
||||
@@ -19,10 +21,7 @@ export function FormatDueDatetime(isoString: string): string {
|
||||
}
|
||||
|
||||
export async function todoistApiRequest(
|
||||
this:
|
||||
| IHookFunctions
|
||||
| IExecuteFunctions
|
||||
| ILoadOptionsFunctions,
|
||||
this: Context,
|
||||
method: string,
|
||||
resource: string,
|
||||
body: any = {}, // tslint:disable-line:no-any
|
||||
@@ -48,6 +47,34 @@ export async function todoistApiRequest(
|
||||
return await this.helpers.requestWithAuthentication.call(this, credentialType, options);
|
||||
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
throw new NodeApiError(this.getNode(), (error));
|
||||
}
|
||||
}
|
||||
|
||||
export async function todoistSyncRequest(
|
||||
this: Context,
|
||||
body: any = {}, // tslint:disable-line:no-any
|
||||
qs: IDataObject = {},
|
||||
): Promise<any> { // tslint:disable-line:no-any
|
||||
const authentication = this.getNodeParameter('authentication', 0, 'oAuth2');
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
headers: {},
|
||||
method: 'POST',
|
||||
qs,
|
||||
uri: `https://api.todoist.com/sync/v8/sync`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (Object.keys(body).length !== 0) {
|
||||
options.body = body;
|
||||
}
|
||||
|
||||
try {
|
||||
const credentialType = authentication === 'oAuth2' ? 'todoistOAuth2Api' : 'todoistApi';
|
||||
return await this.helpers.requestWithAuthentication.call(this, credentialType, options);
|
||||
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), (error));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user