@@ -21,8 +21,6 @@ @interface TMAPIClient()
2121
2222NSString *fullBlogName (NSString *blogName);
2323
24- NSString *URLWithPath (NSString *path);
25-
2624@end
2725
2826
@@ -379,7 +377,7 @@ - (JXHTTPOperation *)getRequestWithPath:(NSString *)path parameters:(NSDictionar
379377 NSMutableDictionary *mutableParameters = [NSMutableDictionary dictionaryWithDictionary: parameters];
380378 mutableParameters[@" api_key" ] = self.OAuthConsumerKey ;
381379
382- JXHTTPOperation *request = [JXHTTPOperation withURLString: URLWithPath ( path) queryParameters: mutableParameters];
380+ JXHTTPOperation *request = [JXHTTPOperation withURLString: [ self URLWithPath: path] queryParameters: mutableParameters];
383381 request.continuesInAppBackground = YES ;
384382 request.requestTimeoutInterval = self.timeoutInterval ;
385383
@@ -392,7 +390,7 @@ - (JXHTTPOperation *)postRequestWithPath:(NSString *)path parameters:(NSDictiona
392390 NSMutableDictionary *mutableParameters = [NSMutableDictionary dictionaryWithDictionary: parameters];
393391 mutableParameters[@" api_key" ] = self.OAuthConsumerKey ;
394392
395- JXHTTPOperation *request = [JXHTTPOperation withURLString: URLWithPath ( path) ];
393+ JXHTTPOperation *request = [JXHTTPOperation withURLString: [ self URLWithPath: path] ];
396394 request.requestMethod = @" POST" ;
397395 request.continuesInAppBackground = YES ;
398396 request.requestBody = [JXHTTPFormEncodedBody withDictionary: mutableParameters];
@@ -410,7 +408,7 @@ - (JXHTTPOperation *)multipartPostRequest:(NSString *)blogName type:(NSString *)
410408 mutableParameters[@" api_key" ] = self.OAuthConsumerKey ;
411409 mutableParameters[@" type" ] = type;
412410
413- JXHTTPOperation *request = [JXHTTPOperation withURLString: URLWithPath ( blogPath (@" post" , blogName)) ];
411+ JXHTTPOperation *request = [JXHTTPOperation withURLString: [ self URLWithPath: blogPath (@" post" , blogName)] ];
414412 request.requestMethod = @" POST" ;
415413 request.continuesInAppBackground = YES ;
416414 request.requestBody = [self multipartBodyForParameters: mutableParameters filePathArray: filePathArray
@@ -485,6 +483,10 @@ - (void)sendRequest:(JXHTTPOperation *)request queue:(NSOperationQueue *)queue c
485483 [self .queue addOperation: request];
486484}
487485
486+ - (NSString *)URLWithPath : (NSString *)path {
487+ return [[self .baseURL URLByAppendingPathComponent: path] absoluteString ];
488+ }
489+
488490NSString *blogPath (NSString *ext, NSString *blogName) {
489491 return [NSString stringWithFormat: @" blog/%@ /%@ " , fullBlogName (blogName), ext];
490492}
@@ -497,17 +499,14 @@ - (void)sendRequest:(JXHTTPOperation *)request queue:(NSOperationQueue *)queue c
497499 return blogName;
498500}
499501
500- NSString *URLWithPath (NSString *path) {
501- return [@" http://api.tumblr.com/v2/" stringByAppendingString: path];
502- }
503-
504502#pragma mark - NSObject
505503
506504- (id )init {
507505 if (self = [super init ]) {
508506 self.queue = [[JXHTTPOperationQueue alloc ] init ];
509507 self.defaultCallbackQueue = [NSOperationQueue mainQueue ];
510508 self.timeoutInterval = TMAPIClientDefaultRequestTimeoutInterval;
509+ self.baseURL = [NSURL URLWithString: @" https://api.tumblr.com/v2/" ];
511510 }
512511
513512 return self;
0 commit comments