From ce8b86a7522bda8896115ca7d0118c9d574f3a3f Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Thu, 11 Sep 2025 16:46:19 +0200 Subject: Add "add project" tasks --- QSThingsPlugin/Actions/CreateProjectAction.m | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 QSThingsPlugin/Actions/CreateProjectAction.m (limited to 'QSThingsPlugin/Actions/CreateProjectAction.m') diff --git a/QSThingsPlugin/Actions/CreateProjectAction.m b/QSThingsPlugin/Actions/CreateProjectAction.m new file mode 100644 index 0000000..38a0a5f --- /dev/null +++ b/QSThingsPlugin/Actions/CreateProjectAction.m @@ -0,0 +1,47 @@ +#import "CreateProjectAction.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation CreateProjectAction + +- (QSObject *)createProject:(QSObject *)directObject +{ + NSString *contents = [directObject displayName]; + if (contents) { + NSDictionary *parameters = [TextParsingHelper parseText: contents]; + [ThingsHelper callRoute:ThingsURLRouteAddProject withParameters:parameters]; + } else { + NSLog(@"Could not get the text of the Things object."); + } + return directObject; +} + +- (QSObject *)createProject:(QSObject *)directObject in:(QSObject *)indirectObject +{ + NSString *contents = [directObject displayName]; + + NSDictionary *indirectContents = [indirectObject objectForType:indirectObject.primaryType]; + NSString *areaId = nil; + if (indirectContents) { + areaId = [indirectContents objectForKey:@"uuid"]; + } else { + NSLog(@"Could not read the contents for the indirect object"); + } + + if (contents) { + NSMutableDictionary *parameters = [TextParsingHelper parseText: contents]; + if (areaId) { + [parameters setObject:areaId forKey:@"area-id"]; + } else { + NSLog(@"Could not find a list id"); + } + [ThingsHelper callRoute:ThingsURLRouteAddProject withParameters:parameters]; + } else { + NSLog(@"Could not get the text of the Things object."); + } + return directObject; +} + +@end + +NS_ASSUME_NONNULL_END -- cgit