n8n/packages/nodes-base/nodes/Todoist/v2/Service.ts
Iván Ovejero b03e358a12
refactor: Integrate consistent-type-imports in nodes-base (no-changelog) (#5267)
* 👕 Enable `consistent-type-imports` for nodes-base

* 👕 Apply to nodes-base

*  Undo unrelated changes

* 🚚 Move to `.eslintrc.js` in nodes-base

*  Revert "Enable `consistent-type-imports` for nodes-base"

This reverts commit 529ad72b05.

* 👕 Fix severity
2023-01-27 12:22:44 +01:00

63 lines
1.2 KiB
TypeScript

import {
CloseHandler,
CreateHandler,
DeleteHandler,
GetAllHandler,
GetHandler,
MoveHandler,
ReopenHandler,
SyncHandler,
UpdateHandler,
} from './OperationHandler';
import type { Context } from '../GenericFunctions';
import type { IDataObject } from 'n8n-workflow';
export class TodoistService implements Service {
async execute(
ctx: Context,
operation: OperationType,
itemIndex: number,
): Promise<TodoistResponse> {
return this.handlers[operation].handleOperation(ctx, itemIndex);
}
private handlers = {
create: new CreateHandler(),
close: new CloseHandler(),
delete: new DeleteHandler(),
get: new GetHandler(),
getAll: new GetAllHandler(),
reopen: new ReopenHandler(),
update: new UpdateHandler(),
move: new MoveHandler(),
sync: new SyncHandler(),
};
}
export enum OperationType {
create = 'create',
close = 'close',
delete = 'delete',
get = 'get',
getAll = 'getAll',
reopen = 'reopen',
update = 'update',
move = 'move',
sync = 'sync',
}
export interface Section {
name: string;
id: string;
}
export interface Service {
execute(ctx: Context, operation: OperationType, itemIndex: number): Promise<TodoistResponse>;
}
export interface TodoistResponse {
success?: boolean;
data?: IDataObject;
}