diff options
Diffstat (limited to 'QSThingsPlugin/Actions/CreateTaskAction.m')
| -rw-r--r-- | QSThingsPlugin/Actions/CreateTaskAction.m | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/QSThingsPlugin/Actions/CreateTaskAction.m b/QSThingsPlugin/Actions/CreateTaskAction.m new file mode 100644 index 0000000..f11936f --- /dev/null +++ b/QSThingsPlugin/Actions/CreateTaskAction.m @@ -0,0 +1,47 @@ +#import "CreateTaskAction.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation CreateTaskAction + +- (QSObject *)createTask:(QSObject *)directObject +{ + NSString *contents = [directObject displayName]; + if (contents) { + NSDictionary *parameters = [TextParsingHelper parseText: contents]; + [ThingsHelper callRoute:ThingsURLRouteAdd withParameters:parameters]; + } else { + NSLog(@"Could not get the text of the Things object."); + } + return directObject; +} + +- (QSObject *)createTask:(QSObject *)directObject in:(QSObject *)indirectObject +{ + NSString *contents = [directObject displayName]; + + NSDictionary *indirectContents = [indirectObject objectForType:indirectObject.primaryType]; + NSString *listId = nil; + if (indirectContents) { + listId = [indirectContents objectForKey:@"uuid"]; + } else { + NSLog(@"Could not read the contents for the indirect object"); + } + + if (contents) { + NSMutableDictionary *parameters = [TextParsingHelper parseText: contents]; + if (listId) { + [parameters setObject:listId forKey:@"list-id"]; + } else { + NSLog(@"Could not find a list id"); + } + [ThingsHelper callRoute:ThingsURLRouteAdd withParameters:parameters]; + } else { + NSLog(@"Could not get the text of the Things object."); + } + return directObject; +} + +@end + +NS_ASSUME_NONNULL_END |