diff --git a/Source/ObjectiveFlickr.h b/Source/ObjectiveFlickr.h index bd63e2a..7e39555 100644 --- a/Source/ObjectiveFlickr.h +++ b/Source/ObjectiveFlickr.h @@ -149,6 +149,10 @@ typedef id OFFlickrAPIRequestDelegateType; - (BOOL)callAPIMethodWithGET:(NSString *)inMethodName arguments:(NSDictionary *)inArguments; - (BOOL)callAPIMethodWithPOST:(NSString *)inMethodName arguments:(NSDictionary *)inArguments; +// methods to call from threads / blocking connections +- (NSURL *)urlAPIMethodWithGET:(NSString *)inMethodName arguments:(NSDictionary *)inArguments; +- (NSDictionary *)dictionaryFromRequestData:(NSData *)requestData; + // image upload—we use NSInputStream here because we want to have flexibity; with this you can upload either a file or NSData from NSImage - (BOOL)uploadImageStream:(NSInputStream *)inImageStream suggestedFilename:(NSString *)inFilename MIMEType:(NSString *)inType arguments:(NSDictionary *)inArguments; diff --git a/Source/ObjectiveFlickr.m b/Source/ObjectiveFlickr.m index ca0ed7a..ecbf458 100644 --- a/Source/ObjectiveFlickr.m +++ b/Source/ObjectiveFlickr.m @@ -357,6 +357,21 @@ - (BOOL)callAPIMethodWithGET:(NSString *)inMethodName arguments:(NSDictionary *) return [HTTPRequest performMethod:LFHTTPRequestGETMethod onURL:[NSURL URLWithString:URLString] withData:nil]; } +- (NSURL *)urlAPIMethodWithGET:(NSString *)inMethodName arguments:(NSDictionary *)inArguments +{ + // combine the parameters + NSMutableDictionary *newArgs = inArguments ? [NSMutableDictionary dictionaryWithDictionary:inArguments] : [NSMutableDictionary dictionary]; + [newArgs setObject:inMethodName forKey:@"method"]; + NSString *query = [context signedQueryFromArguments:newArgs]; + NSString *URLString = [NSString stringWithFormat:@"%@?%@", [context RESTAPIEndpoint], query]; + + return [NSURL URLWithString:URLString]; +} + +- (NSDictionary *)dictionaryFromRequestData:(NSData *)requestData { + return [OFXMLMapper dictionaryMappedFromXMLData:requestData]; +} + - (BOOL)callAPIMethodWithPOST:(NSString *)inMethodName arguments:(NSDictionary *)inArguments { if ([HTTPRequest isRunning]) {