#import "CompleteTaskAction.h" NS_ASSUME_NONNULL_BEGIN @implementation CompleteTaskAction - (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]) { NSDictionary *contents = [directObject objectForType:directObject.primaryType]; ThingsURLRoute route = ThingsURLRouteUpdate; if (directObject.primaryType == kProjectType) { route = ThingsURLRouteUpdateProject; } if (contents) { NSString *uuid = [contents objectForKey:@"uuid"]; if (uuid) { NSDictionary *parameters = @{@"id": uuid, @"completed": @"true"}; [ThingsHelper callRoute:route withParameters:parameters]; } else { NSLog(@"Things object did not have a uuid."); } } else { NSLog(@"Could not get the contents of the Things object."); } } return directObject; } @end NS_ASSUME_NONNULL_END