diff options
Diffstat (limited to 'QSThingsPlugin/Actions')
| -rw-r--r-- | QSThingsPlugin/Actions/CompleteTaskAction.m | 7 | ||||
| -rw-r--r-- | QSThingsPlugin/Actions/CreateTaskAction.h | 13 | ||||
| -rw-r--r-- | QSThingsPlugin/Actions/CreateTaskAction.m | 47 |
3 files changed, 61 insertions, 6 deletions
diff --git a/QSThingsPlugin/Actions/CompleteTaskAction.m b/QSThingsPlugin/Actions/CompleteTaskAction.m index 5ff1bd0..afc55ac 100644 --- a/QSThingsPlugin/Actions/CompleteTaskAction.m +++ b/QSThingsPlugin/Actions/CompleteTaskAction.m @@ -7,13 +7,8 @@ NS_ASSUME_NONNULL_BEGIN - (QSObject *)completeTask:(QSObject *)directObject { NSSet *validTypes = [NSSet setWithObjects:kProjectType, kTaskType, nil]; - NSString *authenticationKey = [KeychainHelper authenticationKey]; - if (!authenticationKey) { - NSLog(@"There is no authentication key."); - } - - if (authenticationKey && [validTypes containsObject:directObject.primaryType]) { + if ([validTypes containsObject:directObject.primaryType]) { NSDictionary *contents = [directObject objectForType:directObject.primaryType]; ThingsURLRoute route = ThingsURLRouteUpdate; if (directObject.primaryType == kProjectType) { diff --git a/QSThingsPlugin/Actions/CreateTaskAction.h b/QSThingsPlugin/Actions/CreateTaskAction.h new file mode 100644 index 0000000..36c5c3c --- /dev/null +++ b/QSThingsPlugin/Actions/CreateTaskAction.h @@ -0,0 +1,13 @@ +#import "Constants.h" +#import "ThingsHelper.h" +#import "TextParsingHelper.h" +#import <Foundation/Foundation.h> +#import <QSCore/QSCore.h> + +NS_ASSUME_NONNULL_BEGIN + +@interface CreateTaskAction : QSActionProvider + +@end + +NS_ASSUME_NONNULL_END 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 |