Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to retrieve the URL used in API call #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Source/ObjectiveFlickr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
15 changes: 15 additions & 0 deletions Source/ObjectiveFlickr.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down