From cf948e47e338896aea0b634fb7fe84dd171b1ec1 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 4 Apr 2024 14:23:11 +1100 Subject: [PATCH 1/5] Remove unused method from `ServiceRemoteWordPressComREST` --- CHANGELOG.md | 2 +- .../Services/ServiceRemoteWordPressComREST.h | 7 ------- .../Services/ServiceRemoteWordPressComREST.m | 10 ---------- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 803b047d..c80990b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ _None._ ### Breaking Changes -_None._ +- Remove unused `anonymousWordPressComRestApiWithUserAgent` method from `ServiceRemoteWordPressComREST` [TBD] ### New Features diff --git a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h index b214d4d1..3edfedce 100644 --- a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h +++ b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h @@ -52,13 +52,6 @@ NS_ASSUME_NONNULL_BEGIN - (NSString *)pathForEndpoint:(NSString *)endpoint withVersion:(ServiceRemoteWordPressComRESTApiVersion)apiVersion; -/** - * @brief An anonoymous API object to use for communications where authentication is not needed. - * - * @param userAgent The user agent string to use on all requests - */ -+ (WordPressComRestApi *)anonymousWordPressComRestApiWithUserAgent:(NSString *)userAgent; - @end NS_ASSUME_NONNULL_END diff --git a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m index 73c3e835..1eff8730 100644 --- a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m +++ b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m @@ -14,9 +14,6 @@ static NSString* const ServiceRemoteWordPressComRESTApiVersionString_1_3 = @"rest/v1.3"; static NSString* const ServiceRemoteWordPressComRESTApiVersionString_2_0 = @"wpcom/v2"; -@interface ServiceRemoteWordPressComREST () -@end - @implementation ServiceRemoteWordPressComREST - (instancetype)initWithWordPressComRestApi:(WordPressComRestApi *)wordPressComRestApi { @@ -80,11 +77,4 @@ - (NSString *)pathForEndpoint:(NSString *)resourceUrl return [NSString stringWithFormat:@"%@/%@", apiVersionString, resourceUrl]; } -+ (WordPressComRestApi *)anonymousWordPressComRestApiWithUserAgent:(NSString *)userAgent { - - return [[WordPressComRestApi alloc] initWithOAuthToken:nil - userAgent:userAgent - ]; -} - @end From 8193c2afe775aa739bd694acaae8679e8985989d Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 4 Apr 2024 21:15:59 +1100 Subject: [PATCH 2/5] Convert `ServiceRemoteWordPressComRESTApiVersion` to modern ObjC enum This should help with isolating the value so that we can further extract the path logic in the Swift implementation. --- .../Services/ServiceRemoteWordPressComREST.h | 16 +++++++++------- .../Services/ServiceRemoteWordPressComREST.m | 6 ------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h index 3edfedce..1085d002 100644 --- a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h +++ b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h @@ -3,12 +3,13 @@ @class WordPressComRestApi; -typedef NSInteger NS_TYPED_ENUM ServiceRemoteWordPressComRESTApiVersion; -extern ServiceRemoteWordPressComRESTApiVersion const ServiceRemoteWordPressComRESTApiVersion_1_0; -extern ServiceRemoteWordPressComRESTApiVersion const ServiceRemoteWordPressComRESTApiVersion_1_1; -extern ServiceRemoteWordPressComRESTApiVersion const ServiceRemoteWordPressComRESTApiVersion_1_2; -extern ServiceRemoteWordPressComRESTApiVersion const ServiceRemoteWordPressComRESTApiVersion_1_3; -extern ServiceRemoteWordPressComRESTApiVersion const ServiceRemoteWordPressComRESTApiVersion_2_0; +typedef NS_ENUM(NSInteger, ServiceRemoteWordPressComRESTApiVersion) { + ServiceRemoteWordPressComRESTApiVersion_1_0 = 1000, + ServiceRemoteWordPressComRESTApiVersion_1_1 = 1001, + ServiceRemoteWordPressComRESTApiVersion_1_2 = 1002, + ServiceRemoteWordPressComRESTApiVersion_1_3 = 1003, + ServiceRemoteWordPressComRESTApiVersion_2_0 = 2000 +}; NS_ASSUME_NONNULL_BEGIN @@ -50,7 +51,8 @@ NS_ASSUME_NONNULL_BEGIN * @returns The request URL. */ - (NSString *)pathForEndpoint:(NSString *)endpoint - withVersion:(ServiceRemoteWordPressComRESTApiVersion)apiVersion; + withVersion:(ServiceRemoteWordPressComRESTApiVersion)apiVersion +NS_SWIFT_NAME(path(forEndpoint:withVersion:)); @end diff --git a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m index 1eff8730..622bc1ab 100644 --- a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m +++ b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m @@ -1,12 +1,6 @@ #import "ServiceRemoteWordPressComREST.h" #import "WPKit-Swift.h" -ServiceRemoteWordPressComRESTApiVersion const ServiceRemoteWordPressComRESTApiVersion_1_0 = 1000; -ServiceRemoteWordPressComRESTApiVersion const ServiceRemoteWordPressComRESTApiVersion_1_1 = 1001; -ServiceRemoteWordPressComRESTApiVersion const ServiceRemoteWordPressComRESTApiVersion_1_2 = 1002; -ServiceRemoteWordPressComRESTApiVersion const ServiceRemoteWordPressComRESTApiVersion_1_3 = 1003; -ServiceRemoteWordPressComRESTApiVersion const ServiceRemoteWordPressComRESTApiVersion_2_0 = 2000; - static NSString* const ServiceRemoteWordPressComRESTApiVersionStringInvalid = @"invalid_api_version"; static NSString* const ServiceRemoteWordPressComRESTApiVersionString_1_0 = @"rest/v1"; static NSString* const ServiceRemoteWordPressComRESTApiVersionString_1_1 = @"rest/v1.1"; From a42f0367001c71a846496b14a90e14332273aa49 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 4 Apr 2024 21:26:43 +1100 Subject: [PATCH 3/5] Remove `ServiceRemote` prefix from `WordPressComRESTAPIVersion` --- .../Services/AccountServiceRemoteREST.m | 14 ++++----- .../Services/BlogServiceRemoteREST.m | 16 +++++----- .../Services/CommentServiceRemoteREST.m | 30 +++++++++---------- .../Services/MediaServiceRemoteREST.m | 18 +++++------ .../Services/MenusServiceRemote.m | 8 ++--- .../Services/PostServiceRemoteREST.m | 22 +++++++------- .../Services/ReaderPostServiceRemote.m | 10 +++---- .../Services/ReaderSiteServiceRemote.m | 20 ++++++------- .../Services/ReaderTopicServiceRemote.m | 16 +++++----- .../Services/ServiceRemoteWordPressComREST.h | 14 ++++----- .../Services/ServiceRemoteWordPressComREST.m | 14 ++++----- .../Services/ServiceRequest.swift | 4 +-- .../Services/TaxonomyServiceRemoteREST.m | 8 ++--- .../Services/ThemeServiceRemote.m | 22 +++++++------- .../Services/WordPressComServiceRemote.m | 6 ++-- .../Tests/BlogServiceRemoteRESTTests.m | 8 ++--- .../Tests/MenusServiceRemoteTests.m | 8 ++--- .../Tests/MockServiceRequest.swift | 2 +- .../Tests/PostServiceRemoteRESTTests.m | 20 ++++++------- .../Tests/TaxonomyServiceRemoteRESTTests.m | 6 ++-- .../Tests/ThemeServiceRemoteTests.m | 12 ++++---- 21 files changed, 139 insertions(+), 139 deletions(-) diff --git a/Sources/WordPressKit/Services/AccountServiceRemoteREST.m b/Sources/WordPressKit/Services/AccountServiceRemoteREST.m index cb76d930..2d938c78 100644 --- a/Sources/WordPressKit/Services/AccountServiceRemoteREST.m +++ b/Sources/WordPressKit/Services/AccountServiceRemoteREST.m @@ -54,7 +54,7 @@ - (void)getAccountDetailsWithSuccess:(void (^)(RemoteUser *remoteUser))success failure:(void (^)(NSError *error))failure { NSString *requestUrl = [self pathForEndpoint:@"me" - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:nil @@ -107,7 +107,7 @@ - (void)updateBlogsVisibility:(NSDictionary *)blogs @"sites": sites }; NSString *path = [self pathForEndpoint:@"me/sites" - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:path parameters:parameters success:^(id responseObject, NSHTTPURLResponse *httpResponse) { @@ -126,7 +126,7 @@ - (void)isPasswordlessAccount:(NSString *)identifier success:(void (^)(BOOL pass NSString *encodedIdentifier = [identifier stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLPathRFC3986AllowedCharacterSet]; NSString *path = [self pathForEndpoint:[NSString stringWithFormat:@"users/%@/auth-options", encodedIdentifier] - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:path parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { @@ -249,7 +249,7 @@ - (void)requestWPComAuthLinkForEmail:(NSString *)email failure:(void (^)(NSError *error))failure { NSString *path = [self pathForEndpoint:@"auth/send-login-email" - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_3]; + withVersion:WordPressComRESTAPIVersion_1_3]; NSDictionary *extraParams = @{ MagicLinkParameterFlow: MagicLinkFlowLogin, @@ -275,7 +275,7 @@ - (void)requestWPComSignupLinkForEmail:(NSString *)email { NSString *path = [self pathForEndpoint:@"auth/send-signup-email" - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *extraParams = @{ @"signup_flow_name": @"mobile-ios", @@ -334,7 +334,7 @@ - (void)requestVerificationEmailWithSucccess:(void (^)(void))success failure:(void (^)(NSError *))failure { NSString *path = [self pathForEndpoint:@"me/send-verification-email" - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:path parameters:nil success:^(id _Nonnull responseObject, NSHTTPURLResponse * _Nullable httpResponse) { if (success) { @@ -354,7 +354,7 @@ - (void)getBlogsWithParameters:(NSDictionary *)parameters failure:(void (^)(NSError *))failure { NSString *requestUrl = [self pathForEndpoint:@"me/sites" - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; [self.wordPressComRESTAPI get:requestUrl parameters:parameters success:^(id responseObject, NSHTTPURLResponse *httpResponse) { diff --git a/Sources/WordPressKit/Services/BlogServiceRemoteREST.m b/Sources/WordPressKit/Services/BlogServiceRemoteREST.m index ec47ca49..b8b3f140 100644 --- a/Sources/WordPressKit/Services/BlogServiceRemoteREST.m +++ b/Sources/WordPressKit/Services/BlogServiceRemoteREST.m @@ -104,7 +104,7 @@ - (void)getAllAuthorsWithRemoteUsers:(NSMutableArray *)remoteUsers NSString *path = [self pathForUsers]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:parameters @@ -136,7 +136,7 @@ - (void)syncPostTypesWithSuccess:(PostTypesHandler)success { NSString *path = [self pathForPostTypes]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = @{@"context": @"edit"}; [self.wordPressComRESTAPI get:requestUrl parameters:parameters @@ -166,7 +166,7 @@ - (void)syncPostFormatsWithSuccess:(PostFormatsHandler)success { NSString *path = [self pathForPostFormats]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:nil @@ -187,7 +187,7 @@ - (void)syncBlogWithSuccess:(BlogDetailsHandler)success { NSString *path = [self pathForSite]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:nil @@ -208,7 +208,7 @@ - (void)syncBlogSettingsWithSuccess:(SettingsHandler)success failure:(void (^)(NSError *error))failure { NSString *path = [self pathForSettings]; - NSString *requestUrl = [self pathForEndpoint:path withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + NSString *requestUrl = [self pathForEndpoint:path withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:nil @@ -238,7 +238,7 @@ - (void)updateBlogSettings:(RemoteBlogSettings *)settings NSDictionary *parameters = [self remoteSettingsToDictionary:settings]; NSString *path = [NSString stringWithFormat:@"sites/%@/settings?context=edit", self.siteID]; - NSString *requestUrl = [self pathForEndpoint:path withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + NSString *requestUrl = [self pathForEndpoint:path withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:parameters @@ -270,7 +270,7 @@ - (void)fetchSiteInfoForAddress:(NSString *)siteAddress { NSString *path = [NSString stringWithFormat:@"sites/%@", siteAddress]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:nil @@ -290,7 +290,7 @@ - (void)fetchUnauthenticatedSiteInfoForAddress:(NSString *)siteAddress success:(void(^)(NSDictionary *siteInfoDict))success failure:(void (^)(NSError *error))failure { - NSString *path = [self pathForEndpoint:@"connect/site-info" withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + NSString *path = [self pathForEndpoint:@"connect/site-info" withVersion:WordPressComRESTAPIVersion_1_1]; NSURL *siteURL = [NSURL URLWithString:siteAddress]; [self.wordPressComRESTAPI get:path diff --git a/Sources/WordPressKit/Services/CommentServiceRemoteREST.m b/Sources/WordPressKit/Services/CommentServiceRemoteREST.m index 68cfdd38..0f13fddd 100644 --- a/Sources/WordPressKit/Services/CommentServiceRemoteREST.m +++ b/Sources/WordPressKit/Services/CommentServiceRemoteREST.m @@ -26,7 +26,7 @@ - (void)getCommentsWithMaximumCount:(NSInteger)maximumComments { NSString *path = [NSString stringWithFormat:@"sites/%@/comments", self.siteID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{ @"force": @"wpcom", // Force fetching data from shadow site on Jetpack sites @@ -82,7 +82,7 @@ - (void)getCommentWithID:(NSNumber *)commentID { NSString *path = [NSString stringWithFormat:@"sites/%@/comments/%@", self.siteID, commentID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:nil @@ -110,7 +110,7 @@ - (void)createComment:(RemoteComment *)comment } NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = @{ @"content": comment.content, @@ -137,7 +137,7 @@ - (void)updateComment:(RemoteComment *)comment { NSString *path = [NSString stringWithFormat:@"sites/%@/comments/%@", self.siteID, comment.commentID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = @{ @"content": comment.content, @@ -168,7 +168,7 @@ - (void)moderateComment:(RemoteComment *)comment { NSString *path = [NSString stringWithFormat:@"sites/%@/comments/%@", self.siteID, comment.commentID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = @{ @"status": [self remoteStatusWithStatus:comment.status], @@ -195,7 +195,7 @@ - (void)trashComment:(RemoteComment *)comment { NSString *path = [NSString stringWithFormat:@"sites/%@/comments/%@/delete", self.siteID, comment.commentID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil @@ -221,7 +221,7 @@ - (void)syncHierarchicalCommentsForPost:(NSNumber *)postID { NSString *path = [NSString stringWithFormat:@"sites/%@/posts/%@/replies?order=ASC&hierarchical=1&page=%lu&number=%lu", self.siteID, postID, (unsigned long)page, (unsigned long)number]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = @{ @"force": @"wpcom" // Force fetching data from shadow site on Jetpack sites @@ -252,7 +252,7 @@ - (void)updateCommentWithID:(NSNumber *)commentID { NSString *path = [NSString stringWithFormat:@"sites/%@/comments/%@", self.siteID, commentID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = @{ @"content": content, @@ -278,7 +278,7 @@ - (void)replyToPostWithID:(NSNumber *)postID { NSString *path = [NSString stringWithFormat:@"sites/%@/posts/%@/replies/new", self.siteID, postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = @{@"content": content}; @@ -304,7 +304,7 @@ - (void)replyToCommentWithID:(NSNumber *)commentID { NSString *path = [NSString stringWithFormat:@"sites/%@/comments/%@/replies/new", self.siteID, commentID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = @{ @"content": content, @@ -332,7 +332,7 @@ - (void)moderateCommentWithID:(NSNumber *)commentID { NSString *path = [NSString stringWithFormat:@"sites/%@/comments/%@", self.siteID, commentID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = @{ @"status" : status, @@ -358,7 +358,7 @@ - (void)trashCommentWithID:(NSNumber *)commentID { NSString *path = [NSString stringWithFormat:@"sites/%@/comments/%@/delete", self.siteID, commentID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil @@ -379,7 +379,7 @@ - (void)likeCommentWithID:(NSNumber *)commentID { NSString *path = [NSString stringWithFormat:@"sites/%@/comments/%@/likes/new", self.siteID, commentID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil @@ -400,7 +400,7 @@ - (void)unlikeCommentWithID:(NSNumber *)commentID { NSString *path = [NSString stringWithFormat:@"sites/%@/comments/%@/likes/mine/delete", self.siteID, commentID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil @@ -426,7 +426,7 @@ - (void)getLikesForCommentID:(NSNumber *)commentID NSString *path = [NSString stringWithFormat:@"sites/%@/comments/%@/likes", self.siteID, commentID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; NSNumber *siteID = self.siteID; // If no count provided, default to endpoint max. diff --git a/Sources/WordPressKit/Services/MediaServiceRemoteREST.m b/Sources/WordPressKit/Services/MediaServiceRemoteREST.m index 9d684c3b..6aca3d44 100644 --- a/Sources/WordPressKit/Services/MediaServiceRemoteREST.m +++ b/Sources/WordPressKit/Services/MediaServiceRemoteREST.m @@ -14,7 +14,7 @@ - (void)getMediaWithID:(NSNumber *)mediaID { NSString *apiPath = [NSString stringWithFormat:@"sites/%@/media/%@", self.siteID, mediaID]; NSString *requestUrl = [self pathForEndpoint:apiPath - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary * parameters = @{}; @@ -58,7 +58,7 @@ - (void)getMediaLibraryPage:(NSString *)pageHandle } NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:[NSDictionary dictionaryWithDictionary:parameters] @@ -97,7 +97,7 @@ - (void)getMediaLibraryCountForType:(NSString *)mediaType { NSString *path = [NSString stringWithFormat:@"sites/%@/media", self.siteID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{ @"number" : @1 }]; if (mediaType) { @@ -129,7 +129,7 @@ - (void)uploadMedia:(NSArray *)mediaItems NSString *apiPath = [NSString stringWithFormat:@"sites/%@/media/new", self.siteID]; NSString *requestUrl = [self pathForEndpoint:apiPath - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{}]; NSMutableArray *fileParts = [NSMutableArray array]; @@ -190,7 +190,7 @@ - (void)uploadMedia:(RemoteMedia *)media NSString *apiPath = [NSString stringWithFormat:@"sites/%@/media/new", self.siteID]; NSString *requestUrl = [self pathForEndpoint:apiPath - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = [self parametersForUploadMedia:media]; @@ -257,7 +257,7 @@ - (void)updateMedia:(RemoteMedia *)media NSString *path = [NSString stringWithFormat:@"sites/%@/media/%@", self.siteID, media.mediaID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = [self parametersFromRemoteMedia:media]; @@ -283,7 +283,7 @@ - (void)deleteMedia:(RemoteMedia *)media NSString *path = [NSString stringWithFormat:@"sites/%@/media/%@/delete", self.siteID, media.mediaID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil @@ -316,7 +316,7 @@ -(void)getMetadataFromVideoPressID:(NSString *)videoPressID { NSString *path = [NSString stringWithFormat:@"videos/%@", videoPressID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:nil @@ -356,7 +356,7 @@ -(void)getVideoPressToken:(NSString *)videoPressID NSString *path = [NSString stringWithFormat:@"sites/%@/media/videopress-playback-jwt/%@", self.siteID, videoPressID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_2_0]; + withVersion:WordPressComRESTAPIVersion_2_0]; [self.wordPressComRESTAPI post:requestUrl parameters:nil diff --git a/Sources/WordPressKit/Services/MenusServiceRemote.m b/Sources/WordPressKit/Services/MenusServiceRemote.m index 119651a7..e7c0b145 100644 --- a/Sources/WordPressKit/Services/MenusServiceRemote.m +++ b/Sources/WordPressKit/Services/MenusServiceRemote.m @@ -37,7 +37,7 @@ - (void)createMenuWithName:(NSString *)menuName NSString *path = [NSString stringWithFormat:@"sites/%@/menus/new", siteID]; NSString *requestURL = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestURL parameters:@{MenusRemoteKeyName: menuName} @@ -77,7 +77,7 @@ - (void)updateMenuForID:(NSNumber *)menuID NSString *path = [NSString stringWithFormat:@"sites/%@/menus/%@", siteID, menuID]; NSString *requestURL = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:2]; if (updatedName.length) { @@ -130,7 +130,7 @@ - (void)deleteMenuForID:(NSNumber *)menuID NSString *path = [NSString stringWithFormat:@"sites/%@/menus/%@/delete", siteID, menuID]; NSString *requestURL = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestURL parameters:nil success:^(id _Nonnull responseObject, NSHTTPURLResponse *httpResponse) { @@ -167,7 +167,7 @@ - (void)getMenusForSiteID:(NSNumber *)siteID NSString *path = [NSString stringWithFormat:@"sites/%@/menus", siteID]; NSString *requestURL = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestURL parameters:nil diff --git a/Sources/WordPressKit/Services/PostServiceRemoteREST.m b/Sources/WordPressKit/Services/PostServiceRemoteREST.m index 50401de1..e4455a61 100644 --- a/Sources/WordPressKit/Services/PostServiceRemoteREST.m +++ b/Sources/WordPressKit/Services/PostServiceRemoteREST.m @@ -37,7 +37,7 @@ - (void)getPostWithID:(NSNumber *)postID NSString *path = [NSString stringWithFormat:@"sites/%@/posts/%@", self.siteID, postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = @{ @"context": @"edit" }; @@ -70,7 +70,7 @@ - (void)getPostsOfType:(NSString *)postType NSString *path = [NSString stringWithFormat:@"sites/%@/posts", self.siteID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; NSDictionary *parameters = @{ @"status": @"any,trash", @@ -102,7 +102,7 @@ -(void)getAutoSaveForPost:(RemotePost *)post { NSString *path = [NSString stringWithFormat:@"sites/%@/posts/%@/autosave", self.siteID, post.postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = [self parametersWithRemotePost:post]; @@ -128,7 +128,7 @@ - (void)createPost:(RemotePost *)post NSString *path = [NSString stringWithFormat:@"sites/%@/posts/new?context=edit", self.siteID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; NSDictionary *parameters = [self parametersWithRemotePost:post]; @@ -158,7 +158,7 @@ - (void)createPost:(RemotePost *)post NSString *filename = media.file; NSString *path = [NSString stringWithFormat:@"sites/%@/posts/new", self.siteID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{}]; parameters[@"content"] = post.content; @@ -192,7 +192,7 @@ - (void)updatePost:(RemotePost *)post NSString *path = [NSString stringWithFormat:@"sites/%@/posts/%@?context=edit", self.siteID, post.postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; NSDictionary *parameters = [self parametersWithRemotePost:post]; @@ -218,7 +218,7 @@ - (void)autoSave:(RemotePost *)post NSString *path = [NSString stringWithFormat:@"sites/%@/posts/%@/autosave", self.siteID, post.postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = [self parametersWithRemotePost:post]; @@ -245,7 +245,7 @@ - (void)deletePost:(RemotePost *)post NSString *path = [NSString stringWithFormat:@"sites/%@/posts/%@/delete", self.siteID, post.postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil @@ -269,7 +269,7 @@ - (void)trashPost:(RemotePost *)post // The parameters are passed as part of the string here because AlamoFire doesn't encode parameters on POST requests. NSString *path = [NSString stringWithFormat:@"sites/%@/posts/%@/delete?context=edit", self.siteID, post.postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil @@ -295,7 +295,7 @@ - (void)restorePost:(RemotePost *)post // https://github.com/wordpress-mobile/WordPressKit-iOS/pull/385 NSString *path = [NSString stringWithFormat:@"sites/%@/posts/%@/restore?context=edit", self.siteID, post.postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil @@ -322,7 +322,7 @@ - (void)getLikesForPostID:(NSNumber *)postID NSString *path = [NSString stringWithFormat:@"sites/%@/posts/%@/likes", self.siteID, postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; NSNumber *siteID = self.siteID; // If no count provided, default to endpoint max. diff --git a/Sources/WordPressKit/Services/ReaderPostServiceRemote.m b/Sources/WordPressKit/Services/ReaderPostServiceRemote.m index 68545f04..6cafe5f1 100644 --- a/Sources/WordPressKit/Services/ReaderPostServiceRemote.m +++ b/Sources/WordPressKit/Services/ReaderPostServiceRemote.m @@ -70,7 +70,7 @@ - (void)fetchPost:(NSUInteger)postID NSString *path = [NSString stringWithFormat:@"read/%@/%lu/posts/%lu/?meta=site", feedType, (unsigned long)siteID, (unsigned long)postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; [self.wordPressComRESTAPI get:requestUrl parameters:nil @@ -142,7 +142,7 @@ - (void)likePost:(NSUInteger)postID { NSString *path = [NSString stringWithFormat:@"sites/%lu/posts/%lu/likes/new", (unsigned long)siteID, (unsigned long)postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { if (success) { @@ -162,7 +162,7 @@ - (void)unlikePost:(NSUInteger)postID { NSString *path = [NSString stringWithFormat:@"sites/%lu/posts/%lu/likes/mine/delete", (unsigned long)siteID, (unsigned long)postID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { if (success) { @@ -180,7 +180,7 @@ - (NSString *)endpointUrlForSearchPhrase:(NSString *)phrase NSAssert([phrase length] > 0, @"A search phrase is required."); NSString *endpoint = [NSString stringWithFormat:@"read/search?q=%@", [phrase stringByUrlEncoding]]; - NSString *absolutePath = [self pathForEndpoint:endpoint withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + NSString *absolutePath = [self pathForEndpoint:endpoint withVersion:WordPressComRESTAPIVersion_1_2]; NSURL *url = [NSURL URLWithString:absolutePath relativeToURL:self.wordPressComRESTAPI.baseURL]; return [url absoluteString]; } @@ -267,7 +267,7 @@ - (nullable NSString *)apiPathForPostAtURL:(NSURL *)url NSString *path = [NSString stringWithFormat:@"sites/%@/posts/slug:%@?meta=site,likes", hostname, slug]; return [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; } @end diff --git a/Sources/WordPressKit/Services/ReaderSiteServiceRemote.m b/Sources/WordPressKit/Services/ReaderSiteServiceRemote.m index 975c6a8f..44d278eb 100644 --- a/Sources/WordPressKit/Services/ReaderSiteServiceRemote.m +++ b/Sources/WordPressKit/Services/ReaderSiteServiceRemote.m @@ -15,7 +15,7 @@ - (void)fetchFollowedSitesWithSuccess:(void(^)(NSArray *sites))success failure:( { NSString *path = @"read/following/mine?meta=site,feed"; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { if (!success) { @@ -42,7 +42,7 @@ - (void)followSiteWithID:(NSUInteger)siteID success:(void (^)(void))success fail { NSString *path = [NSString stringWithFormat:@"sites/%lu/follows/new?%@=%@", (unsigned long)siteID, ReaderSiteServiceRemoteSourceKey, ReaderSiteServiceRemoteSourceValue]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { if (success) { @@ -59,7 +59,7 @@ - (void)unfollowSiteWithID:(NSUInteger)siteID success:(void (^)(void))success fa { NSString *path = [NSString stringWithFormat:@"sites/%lu/follows/mine/delete", (unsigned long)siteID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { if (success) { @@ -76,7 +76,7 @@ - (void)followSiteAtURL:(NSString *)siteURL success:(void (^)(void))success fail { NSString *path = @"read/following/mine/new"; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *params = @{ReaderSiteServiceRemoteURLKey: siteURL, ReaderSiteServiceRemoteSourceKey: ReaderSiteServiceRemoteSourceValue}; @@ -105,7 +105,7 @@ - (void)unfollowSiteAtURL:(NSString *)siteURL success:(void (^)(void))success fa { NSString *path = @"read/following/mine/delete"; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *params = @{ReaderSiteServiceRemoteURLKey: siteURL}; @@ -161,7 +161,7 @@ - (void)findSiteIDForURL:(NSURL *)siteURL success:(void (^)(NSUInteger siteID))s NSString *path = [NSString stringWithFormat:@"sites/%@", host]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:nil success:successBlock failure:^(NSError *error, NSHTTPURLResponse *httpResponse) { NSString *newHost; @@ -176,7 +176,7 @@ - (void)findSiteIDForURL:(NSURL *)siteURL success:(void (^)(NSUInteger siteID))s } NSString *newPath = [NSString stringWithFormat:@"sites/%@", newHost]; NSString *newPathRequestUrl = [self pathForEndpoint:newPath - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:newPathRequestUrl parameters:nil success:successBlock failure:failureBlock]; }]; @@ -216,7 +216,7 @@ - (void)checkSubscribedToSiteByID:(NSUInteger)siteID success:(void (^)(BOOL foll { NSString *path = [NSString stringWithFormat:@"sites/%lu/follows/mine", (unsigned long)siteID]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { if (!success) { @@ -237,7 +237,7 @@ - (void)checkSubscribedToFeedByURL:(NSURL *)siteURL success:(void (^)(BOOL follo { NSString *path = @"read/following/mine"; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { if (!success) { @@ -268,7 +268,7 @@ - (void)flagSiteWithID:(NSUInteger)siteID asBlocked:(BOOL)blocked success:(void( } NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { NSDictionary *dict = (NSDictionary *)responseObject; diff --git a/Sources/WordPressKit/Services/ReaderTopicServiceRemote.m b/Sources/WordPressKit/Services/ReaderTopicServiceRemote.m index 18fbece6..b78003d6 100644 --- a/Sources/WordPressKit/Services/ReaderTopicServiceRemote.m +++ b/Sources/WordPressKit/Services/ReaderTopicServiceRemote.m @@ -17,7 +17,7 @@ - (void)fetchReaderMenuWithSuccess:(void (^)(NSArray *topics))success failure:(v { NSString *path = @"read/menu"; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_3]; + withVersion:WordPressComRESTAPIVersion_1_3]; [self.wordPressComRESTAPI get:requestUrl parameters:nil success:^(NSDictionary *response, NSHTTPURLResponse *httpResponse) { if (!success) { @@ -77,7 +77,7 @@ - (void)fetchFollowedSitesForPage:(NSUInteger)page { NSString *path = [self pathForFollowedSitesWithPage:page number:number]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; [self.wordPressComRESTAPI get:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { if (!success) { @@ -105,7 +105,7 @@ - (void)unfollowTopicWithSlug:(NSString *)slug { NSString *path = [NSString stringWithFormat:@"read/tags/%@/mine/delete", slug]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil success:^(NSDictionary *responseObject, NSHTTPURLResponse *httpResponse) { if (!success) { @@ -136,7 +136,7 @@ - (void)followTopicWithSlug:(NSString *)slug NSString *path = [NSString stringWithFormat:@"read/tags/%@/mine/new", slug]; path = [path stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { if (!success) { @@ -158,7 +158,7 @@ - (void)fetchTagInfoForTagWithSlug:(NSString *)slug { NSString *path = [NSString stringWithFormat:@"read/tags/%@", slug]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; [self.wordPressComRESTAPI get:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { if (!success) { @@ -187,11 +187,11 @@ - (void)fetchSiteInfoForSiteWithID:(NSNumber *)siteID if (isFeed) { NSString *path = [NSString stringWithFormat:@"read/feed/%@", siteID]; requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; } else { NSString *path = [NSString stringWithFormat:@"read/sites/%@", siteID]; requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; } [self.wordPressComRESTAPI get:requestUrl parameters:nil success:^(id responseObject, NSHTTPURLResponse *httpResponse) { @@ -234,7 +234,7 @@ - (RemoteReaderSiteInfo *)siteInfoFromFollowedSiteDictionary:(NSDictionary *)dic - (NSString *)endpointUrlForPath:(NSString *)endpoint { - NSString *absolutePath = [self pathForEndpoint:endpoint withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + NSString *absolutePath = [self pathForEndpoint:endpoint withVersion:WordPressComRESTAPIVersion_1_2]; NSURL *url = [NSURL URLWithString:absolutePath relativeToURL:self.wordPressComRESTAPI.baseURL]; return [url absoluteString]; } diff --git a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h index 1085d002..2c96903e 100644 --- a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h +++ b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h @@ -3,12 +3,12 @@ @class WordPressComRestApi; -typedef NS_ENUM(NSInteger, ServiceRemoteWordPressComRESTApiVersion) { - ServiceRemoteWordPressComRESTApiVersion_1_0 = 1000, - ServiceRemoteWordPressComRESTApiVersion_1_1 = 1001, - ServiceRemoteWordPressComRESTApiVersion_1_2 = 1002, - ServiceRemoteWordPressComRESTApiVersion_1_3 = 1003, - ServiceRemoteWordPressComRESTApiVersion_2_0 = 2000 +typedef NS_ENUM(NSInteger, WordPressComRESTAPIVersion) { + WordPressComRESTAPIVersion_1_0 = 1000, + WordPressComRESTAPIVersion_1_1 = 1001, + WordPressComRESTAPIVersion_1_2 = 1002, + WordPressComRESTAPIVersion_1_3 = 1003, + WordPressComRESTAPIVersion_2_0 = 2000 }; NS_ASSUME_NONNULL_BEGIN @@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN * @returns The request URL. */ - (NSString *)pathForEndpoint:(NSString *)endpoint - withVersion:(ServiceRemoteWordPressComRESTApiVersion)apiVersion + withVersion:(WordPressComRESTAPIVersion)apiVersion NS_SWIFT_NAME(path(forEndpoint:withVersion:)); @end diff --git a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m index 622bc1ab..cfe4a43f 100644 --- a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m +++ b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.m @@ -25,28 +25,28 @@ - (instancetype)initWithWordPressComRestApi:(WordPressComRestApi *)wordPressComR #pragma mark - API Version -- (NSString *)apiVersionStringWithEnumValue:(ServiceRemoteWordPressComRESTApiVersion)apiVersion +- (NSString *)apiVersionStringWithEnumValue:(WordPressComRESTAPIVersion)apiVersion { NSString *result = nil; switch (apiVersion) { - case ServiceRemoteWordPressComRESTApiVersion_1_0: + case WordPressComRESTAPIVersion_1_0: result = ServiceRemoteWordPressComRESTApiVersionString_1_0; break; - case ServiceRemoteWordPressComRESTApiVersion_1_1: + case WordPressComRESTAPIVersion_1_1: result = ServiceRemoteWordPressComRESTApiVersionString_1_1; break; - case ServiceRemoteWordPressComRESTApiVersion_1_2: + case WordPressComRESTAPIVersion_1_2: result = ServiceRemoteWordPressComRESTApiVersionString_1_2; break; - case ServiceRemoteWordPressComRESTApiVersion_1_3: + case WordPressComRESTAPIVersion_1_3: result = ServiceRemoteWordPressComRESTApiVersionString_1_3; break; - case ServiceRemoteWordPressComRESTApiVersion_2_0: + case WordPressComRESTAPIVersion_2_0: result = ServiceRemoteWordPressComRESTApiVersionString_2_0; break; @@ -62,7 +62,7 @@ - (NSString *)apiVersionStringWithEnumValue:(ServiceRemoteWordPressComRESTApiVer #pragma mark - Request URL construction - (NSString *)pathForEndpoint:(NSString *)resourceUrl - withVersion:(ServiceRemoteWordPressComRESTApiVersion)apiVersion + withVersion:(WordPressComRESTAPIVersion)apiVersion { NSParameterAssert([resourceUrl isKindOfClass:[NSString class]]); diff --git a/Sources/WordPressKit/Services/ServiceRequest.swift b/Sources/WordPressKit/Services/ServiceRequest.swift index e2d934b8..99ea5afb 100644 --- a/Sources/WordPressKit/Services/ServiceRequest.swift +++ b/Sources/WordPressKit/Services/ServiceRequest.swift @@ -13,7 +13,7 @@ protocol ServiceRequest { var path: String { get } /// Returns the used API version - var apiVersion: ServiceRemoteWordPressComRESTApiVersion { get } + var apiVersion: WordPressComRESTAPIVersion { get } } /// Reader Topic Service request @@ -24,7 +24,7 @@ enum ReaderTopicServiceSubscriptionsRequest { } extension ReaderTopicServiceSubscriptionsRequest: ServiceRequest { - var apiVersion: ServiceRemoteWordPressComRESTApiVersion { + var apiVersion: WordPressComRESTAPIVersion { switch self { case .notifications: return ._2_0 case .postsEmail: return ._1_2 diff --git a/Sources/WordPressKit/Services/TaxonomyServiceRemoteREST.m b/Sources/WordPressKit/Services/TaxonomyServiceRemoteREST.m index 70c352cc..c35291d9 100644 --- a/Sources/WordPressKit/Services/TaxonomyServiceRemoteREST.m +++ b/Sources/WordPressKit/Services/TaxonomyServiceRemoteREST.m @@ -184,7 +184,7 @@ - (void)createTaxonomyWithType:(NSString *)typeIdentifier failure:(nullable void (^)(NSError *error))failure { NSString *path = [NSString stringWithFormat:@"sites/%@/%@/new?context=edit", self.siteID, typeIdentifier]; - NSString *requestUrl = [self pathForEndpoint:path withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + NSString *requestUrl = [self pathForEndpoint:path withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:parameters @@ -209,7 +209,7 @@ - (void)getTaxonomyWithType:(NSString *)typeIdentifier { NSString *path = [NSString stringWithFormat:@"sites/%@/%@?context=edit", self.siteID, typeIdentifier]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI get:requestUrl parameters:parameters @@ -234,7 +234,7 @@ - (void)deleteTaxonomyWithType:(NSString *)typeIdentifier { NSString *path = [NSString stringWithFormat:@"sites/%@/%@/slug:%@/delete?context=edit", self.siteID, typeIdentifier, parameters[TaxonomyRESTSlugParameter]]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:nil @@ -259,7 +259,7 @@ - (void)updateTaxonomyWithType:(NSString *)typeIdentifier { NSString *path = [NSString stringWithFormat:@"sites/%@/%@/slug:%@?context=edit", self.siteID, typeIdentifier, parameters[TaxonomyRESTSlugParameter]]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:parameters diff --git a/Sources/WordPressKit/Services/ThemeServiceRemote.m b/Sources/WordPressKit/Services/ThemeServiceRemote.m index d6b73417..97d6e60e 100644 --- a/Sources/WordPressKit/Services/ThemeServiceRemote.m +++ b/Sources/WordPressKit/Services/ThemeServiceRemote.m @@ -26,7 +26,7 @@ - (NSProgress *)getActiveThemeForBlogId:(NSNumber *)blogId NSString *path = [NSString stringWithFormat:@"sites/%@/themes/mine", blogId]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSProgress *progress = [self.wordPressComRESTAPI get:requestUrl parameters:nil @@ -53,7 +53,7 @@ - (NSProgress *)getPurchasedThemesForBlogId:(NSNumber *)blogId NSString *path = [NSString stringWithFormat:@"sites/%@/themes/purchased", blogId]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSProgress *progress = [self.wordPressComRESTAPI get:requestUrl parameters:nil @@ -79,7 +79,7 @@ - (NSProgress *)getThemeId:(NSString*)themeId NSString *path = [NSString stringWithFormat:@"themes/%@", themeId]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSProgress *progress = [self.wordPressComRESTAPI get:requestUrl parameters:nil @@ -105,7 +105,7 @@ - (NSProgress *)getWPThemesPage:(NSInteger)page NSParameterAssert(page > 0); NSString *requestUrl = [self pathForEndpoint:@"themes" - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; NSDictionary *parameters = @{ThemeRequestTierKey: freeOnly ? ThemeRequestTierFreeValue : ThemeRequestTierAllValue, ThemeRequestNumberKey: @(ThemeRequestNumberValue), @@ -128,7 +128,7 @@ - (NSProgress *)getThemesPage:(NSInteger)page NSParameterAssert([path isKindOfClass:[NSString class]]); NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; NSDictionary *parameters = @{ThemeRequestTierKey: ThemeRequestTierAllValue, ThemeRequestNumberKey: @(ThemeRequestNumberValue), @@ -152,7 +152,7 @@ - (NSProgress *)getThemesForBlogId:(NSNumber *)blogId NSProgress *progress = [self getThemesForBlogId:blogId page:page - apiVersion:ServiceRemoteWordPressComRESTApiVersion_1_2 + apiVersion:WordPressComRESTAPIVersion_1_2 params:@{ThemeRequestTierKey: ThemeRequestTierAllValue} success:success failure:failure]; @@ -169,7 +169,7 @@ - (NSProgress *)getCustomThemesForBlogId:(NSNumber *)blogId NSProgress *progress = [self getThemesForBlogId:blogId page:1 - apiVersion:ServiceRemoteWordPressComRESTApiVersion_1_0 + apiVersion:WordPressComRESTAPIVersion_1_0 params:@{} success:success failure:failure]; @@ -179,7 +179,7 @@ - (NSProgress *)getCustomThemesForBlogId:(NSNumber *)blogId - (NSProgress *)getThemesForBlogId:(NSNumber *)blogId page:(NSInteger)page - apiVersion:(ServiceRemoteWordPressComRESTApiVersion) apiVersion + apiVersion:(WordPressComRESTAPIVersion) apiVersion params:(NSDictionary *)params success:(ThemeServiceRemoteThemesRequestSuccessBlock)success failure:(ThemeServiceRemoteFailureBlock)failure @@ -212,7 +212,7 @@ - (void)getStartingThemesForCategory:(NSString *)category NSString *path = [NSString stringWithFormat:@"themes/?filter=starting-%@", category]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; NSDictionary *parameters = @{ ThemeRequestNumberKey: @(ThemeRequestNumberValue), @@ -266,7 +266,7 @@ - (NSProgress *)activateThemeId:(NSString *)themeId NSString* const path = [NSString stringWithFormat:@"sites/%@/themes/mine", blogId]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary* parameters = @{@"theme": themeId}; @@ -297,7 +297,7 @@ - (NSProgress *)installThemeId:(NSString*)themeId NSString* const path = [NSString stringWithFormat:@"sites/%@/themes/%@/install", blogId, themeId]; NSString *requestUrl = [self pathForEndpoint:path - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSProgress *progress = [self.wordPressComRESTAPI post:requestUrl parameters:nil diff --git a/Sources/WordPressKit/Services/WordPressComServiceRemote.m b/Sources/WordPressKit/Services/WordPressComServiceRemote.m index 454553aa..20cf3a87 100644 --- a/Sources/WordPressKit/Services/WordPressComServiceRemote.m +++ b/Sources/WordPressKit/Services/WordPressComServiceRemote.m @@ -59,7 +59,7 @@ - (void)createWPComAccountWithEmail:(NSString *)email }; NSString *requestUrl = [self pathForEndpoint:@"users/new" - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:params success:successBlock failure:failureBlock]; } @@ -115,7 +115,7 @@ - (void)createSocialWPComAccountWithParams:(NSDictionary *)params failure(errorWithLocalizedMessage); }; - NSString *requestUrl = [self pathForEndpoint:@"users/social/new" withVersion:ServiceRemoteWordPressComRESTApiVersion_1_0]; + NSString *requestUrl = [self pathForEndpoint:@"users/social/new" withVersion:WordPressComRESTAPIVersion_1_0]; [self.wordPressComRESTAPI post:requestUrl parameters:params success:successBlock failure:failureBlock]; } @@ -220,7 +220,7 @@ - (void)createWPComBlogWithUrl:(NSString *)blogUrl NSString *requestUrl = [self pathForEndpoint:@"sites/new" - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [self.wordPressComRESTAPI post:requestUrl parameters:params success:successBlock failure:failureBlock]; } diff --git a/Tests/WordPressKitTests/Tests/BlogServiceRemoteRESTTests.m b/Tests/WordPressKitTests/Tests/BlogServiceRemoteRESTTests.m index 6ea95182..1e369321 100644 --- a/Tests/WordPressKitTests/Tests/BlogServiceRemoteRESTTests.m +++ b/Tests/WordPressKitTests/Tests/BlogServiceRemoteRESTTests.m @@ -35,7 +35,7 @@ - (void)testThatGetAuthorsWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/users", blog.blogID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api get:[OCMArg isEqual:url] parameters:[OCMArg isKindOfClass:[NSDictionary class]] @@ -60,7 +60,7 @@ - (void)testThatSyncSiteDetailsForBlogWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@", blog.blogID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api get:[OCMArg isEqual:url] parameters:[OCMArg isNil] @@ -85,7 +85,7 @@ - (void)testThatSyncPostTypesForBlogWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/post-types", blog.blogID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSDictionary *parameters = @{@"context": @"edit"}; OCMStub([api get:[OCMArg isEqual:url] @@ -111,7 +111,7 @@ - (void)testThatSyncPostFormatsForBlogWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/post-formats", blog.blogID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api get:[OCMArg isEqual:url] parameters:[OCMArg isNil] diff --git a/Tests/WordPressKitTests/Tests/MenusServiceRemoteTests.m b/Tests/WordPressKitTests/Tests/MenusServiceRemoteTests.m index 5aa794eb..6df6d304 100644 --- a/Tests/WordPressKitTests/Tests/MenusServiceRemoteTests.m +++ b/Tests/WordPressKitTests/Tests/MenusServiceRemoteTests.m @@ -23,7 +23,7 @@ - (void)testThatCreateMenuWithNameWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/menus/new", dotComID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; NSString *name = @"SomeName"; BOOL (^parametersCheckBlock)(id obj) = ^BOOL(NSDictionary *parameters) { @@ -57,7 +57,7 @@ - (void)testThatUpdateMenuWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/menus/%@", dotComID, menu.menuID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api post:[OCMArg isEqual:url] parameters:[OCMArg isKindOfClass:[NSDictionary class]] @@ -87,7 +87,7 @@ - (void)testThatDeleteMenuWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/menus/%@/delete", dotComID, menu.menuID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api post:[OCMArg isEqual:url] parameters:[OCMArg isNil] @@ -110,7 +110,7 @@ - (void)testThatGetMenusWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/menus", dotComID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api get:[OCMArg isEqual:url] parameters:[OCMArg isNil] diff --git a/Tests/WordPressKitTests/Tests/MockServiceRequest.swift b/Tests/WordPressKitTests/Tests/MockServiceRequest.swift index 331c500b..34fa3e3a 100644 --- a/Tests/WordPressKitTests/Tests/MockServiceRequest.swift +++ b/Tests/WordPressKitTests/Tests/MockServiceRequest.swift @@ -6,7 +6,7 @@ struct MockServiceRequest: ServiceRequest { return "localhost/path/" } - var apiVersion: ServiceRemoteWordPressComRESTApiVersion { + var apiVersion: WordPressComRESTAPIVersion { return ._1_2 } } diff --git a/Tests/WordPressKitTests/Tests/PostServiceRemoteRESTTests.m b/Tests/WordPressKitTests/Tests/PostServiceRemoteRESTTests.m index e1c73864..51edec32 100644 --- a/Tests/WordPressKitTests/Tests/PostServiceRemoteRESTTests.m +++ b/Tests/WordPressKitTests/Tests/PostServiceRemoteRESTTests.m @@ -38,7 +38,7 @@ - (void)testThatGetPostWithIDWorks NSNumber *postID = @1; NSString *endpoint = [NSString stringWithFormat:@"sites/%@/posts/%@", dotComID, postID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api get:[OCMArg isEqual:url] parameters:[OCMArg isNotNil] @@ -74,7 +74,7 @@ - (void)testThatGetPostsOfTypeWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/posts", dotComID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; BOOL (^parametersCheckBlock)(id obj) = ^BOOL(NSDictionary *parameters) { @@ -105,7 +105,7 @@ - (void)testThatGetPostsOfTypeWithOptionsWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/posts", dotComID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; NSString *testOptionKey = @"SomeKey"; NSString *testOptionValue = @"SomeValue"; @@ -151,7 +151,7 @@ - (void)testThatCreatePostWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/posts/new?context=edit", dotComID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; OCMStub([api post:[OCMArg isEqual:url] parameters:[OCMArg isKindOfClass:[NSDictionary class]] @@ -196,7 +196,7 @@ - (void)testThatUpdatePostWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/posts/%@?context=edit", dotComID, post.postID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; OCMStub([api post:[OCMArg isEqual:url] parameters:[OCMArg isKindOfClass:[NSDictionary class]] @@ -241,7 +241,7 @@ - (void)testThatAutoSavePostWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/posts/%@/autosave", dotComID, post.postID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api post:[OCMArg isEqual:url] parameters:[OCMArg isKindOfClass:[NSDictionary class]] @@ -274,7 +274,7 @@ - (void)testThatGetAutoSaveForPostWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/posts/%@/autosave", dotComID, post.postID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api get:[OCMArg isEqual:url] parameters:[OCMArg isNotNil] @@ -302,7 +302,7 @@ - (void)testThatDeletePostWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/posts/%@/delete", dotComID, post.postID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api post:[OCMArg isEqual:url] parameters:[OCMArg isNil] @@ -339,7 +339,7 @@ - (void)testThatTrashPostWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/posts/%@/delete?context=edit", dotComID, post.postID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api post:[OCMArg isEqual:url] parameters:[OCMArg isNil] @@ -376,7 +376,7 @@ - (void)testThatRestorePostWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/posts/%@/restore?context=edit", dotComID, post.postID]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; OCMStub([api post:[OCMArg isEqual:url] parameters:[OCMArg isNil] diff --git a/Tests/WordPressKitTests/Tests/TaxonomyServiceRemoteRESTTests.m b/Tests/WordPressKitTests/Tests/TaxonomyServiceRemoteRESTTests.m index 12be440d..90a08311 100644 --- a/Tests/WordPressKitTests/Tests/TaxonomyServiceRemoteRESTTests.m +++ b/Tests/WordPressKitTests/Tests/TaxonomyServiceRemoteRESTTests.m @@ -36,7 +36,7 @@ - (NSString *)GETtaxonomyURLWithType:(NSString *)taxonomyTypeIdentifier { NSString *endpoint = [NSString stringWithFormat:@"sites/%@/%@?context=edit", self.service.siteID, taxonomyTypeIdentifier]; NSString *url = [self.service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; return url; } @@ -50,7 +50,7 @@ - (void)testThatCreateCategoryWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/%@/new?context=edit", self.service.siteID, @"categories"]; NSString *url = [self.service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; BOOL (^parametersCheckBlock)(id obj) = ^BOOL(NSDictionary *parameters) { return ([parameters isKindOfClass:[NSDictionary class]] && [[parameters objectForKey:@"name"] isEqualToString:category.name]); @@ -210,7 +210,7 @@ - (void)testThatCreateTagWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/%@/new?context=edit", self.service.siteID, @"tags"]; NSString *url = [self.service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; BOOL (^parametersCheckBlock)(id obj) = ^BOOL(NSDictionary *parameters) { return ([parameters isKindOfClass:[NSDictionary class]] && [[parameters objectForKey:@"name"] isEqualToString:tag.name]); diff --git a/Tests/WordPressKitTests/Tests/ThemeServiceRemoteTests.m b/Tests/WordPressKitTests/Tests/ThemeServiceRemoteTests.m index f4e6277e..e0a6ac7f 100644 --- a/Tests/WordPressKitTests/Tests/ThemeServiceRemoteTests.m +++ b/Tests/WordPressKitTests/Tests/ThemeServiceRemoteTests.m @@ -40,7 +40,7 @@ - (void)testThatGetActiveThemeForBlogIdWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/themes/mine", blogId]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [OCMStub([api get:[OCMArg isEqual:url] parameters:[OCMArg isNil] @@ -93,7 +93,7 @@ - (void)testThatGetPurchasedThemesForBlogIdWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/themes/purchased", blogId]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [OCMStub([api get:[OCMArg isEqual:url] parameters:[OCMArg isNil] @@ -146,7 +146,7 @@ - (void)testThatGetThemeIdWorks NSString *endpoint = [NSString stringWithFormat:@"themes/%@", themeId]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; [OCMStub([api get:[OCMArg isEqual:url] parameters:[OCMArg isNil] @@ -196,7 +196,7 @@ - (void)testThatGetThemesWorks XCTAssertNoThrow(service = [[ThemeServiceRemote alloc] initWithWordPressComRestApi:api]); NSString *url = [service pathForEndpoint:@"themes" - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; ThemeServiceRemoteThemesRequestSuccessBlock successBlock = ^void (NSArray *themes, BOOL hasMore, NSInteger totalThemeCount) { NSCAssert([themes count] == expectedThemes, @"Expected %ld themes to be returned", expectedThemes); @@ -245,7 +245,7 @@ - (void)testThatGetThemesForBlogIdWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/themes", blogId]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2]; + withVersion:WordPressComRESTAPIVersion_1_2]; [OCMStub([api get:[OCMArg isEqual:url] parameters:[OCMArg isNotNil] @@ -300,7 +300,7 @@ - (void)testThatActivateThemeIdWorks NSString *endpoint = [NSString stringWithFormat:@"sites/%@/themes/mine", blogId]; NSString *url = [service pathForEndpoint:endpoint - withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1]; + withVersion:WordPressComRESTAPIVersion_1_1]; DictionaryVerificationBlock checkBlock = ^BOOL(NSDictionary *parameters) { NSCAssert([parameters isKindOfClass:[NSDictionary class]], From c9117b5a168137298882157690daaf910dd023da Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 4 Apr 2024 21:35:54 +1100 Subject: [PATCH 4/5] Extract `WordPressComRESTAPIVersion` to dedicated file --- .../APIInterface/include/WordPressComRESTAPIVersion.h | 9 +++++++++ .../Services/ServiceRemoteWordPressComREST.h | 10 +--------- Sources/WordPressKit/WordPressKit.h | 1 + WordPressKit.xcodeproj/project.pbxproj | 4 ++++ 4 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 Sources/APIInterface/include/WordPressComRESTAPIVersion.h diff --git a/Sources/APIInterface/include/WordPressComRESTAPIVersion.h b/Sources/APIInterface/include/WordPressComRESTAPIVersion.h new file mode 100644 index 00000000..9625473e --- /dev/null +++ b/Sources/APIInterface/include/WordPressComRESTAPIVersion.h @@ -0,0 +1,9 @@ +#import + +typedef NS_ENUM(NSInteger, WordPressComRESTAPIVersion) { + WordPressComRESTAPIVersion_1_0 = 1000, + WordPressComRESTAPIVersion_1_1 = 1001, + WordPressComRESTAPIVersion_1_2 = 1002, + WordPressComRESTAPIVersion_1_3 = 1003, + WordPressComRESTAPIVersion_2_0 = 2000 +}; diff --git a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h index 2c96903e..f6cc94c9 100644 --- a/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h +++ b/Sources/WordPressKit/Services/ServiceRemoteWordPressComREST.h @@ -1,16 +1,9 @@ #import #import +#import @class WordPressComRestApi; -typedef NS_ENUM(NSInteger, WordPressComRESTAPIVersion) { - WordPressComRESTAPIVersion_1_0 = 1000, - WordPressComRESTAPIVersion_1_1 = 1001, - WordPressComRESTAPIVersion_1_2 = 1002, - WordPressComRESTAPIVersion_1_3 = 1003, - WordPressComRESTAPIVersion_2_0 = 2000 -}; - NS_ASSUME_NONNULL_BEGIN /** @@ -19,7 +12,6 @@ NS_ASSUME_NONNULL_BEGIN */ @interface ServiceRemoteWordPressComREST : NSObject - /** * @brief The API object to use for communications. */ diff --git a/Sources/WordPressKit/WordPressKit.h b/Sources/WordPressKit/WordPressKit.h index 9552d17f..395134db 100644 --- a/Sources/WordPressKit/WordPressKit.h +++ b/Sources/WordPressKit/WordPressKit.h @@ -8,6 +8,7 @@ FOUNDATION_EXPORT const unsigned char WordPressKitVersionString[]; #import #import +#import #import #import diff --git a/WordPressKit.xcodeproj/project.pbxproj b/WordPressKit.xcodeproj/project.pbxproj index c73303b2..393460ce 100644 --- a/WordPressKit.xcodeproj/project.pbxproj +++ b/WordPressKit.xcodeproj/project.pbxproj @@ -71,6 +71,7 @@ 3FB8642C2888089F003A86BE /* BuildkiteTestCollector in Frameworks */ = {isa = PBXBuildFile; productRef = 3FB8642B2888089F003A86BE /* BuildkiteTestCollector */; }; 3FE2E94F2BB29A1B002CA2E1 /* FilePart.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FE2E94D2BB29A1B002CA2E1 /* FilePart.m */; }; 3FE2E9502BB29A1B002CA2E1 /* FilePart.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FE2E94E2BB29A1B002CA2E1 /* FilePart.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3FE2E9672BBEB8D2002CA2E1 /* WordPressComRESTAPIVersion.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FE2E9662BBEB8D2002CA2E1 /* WordPressComRESTAPIVersion.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3FFCC0412BA995290051D229 /* Date+WordPressComTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FFCC0402BA995290051D229 /* Date+WordPressComTests.swift */; }; 3FFCC0472BAA6EF40051D229 /* NSDate+WordPressCom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FFCC0462BAA6EF40051D229 /* NSDate+WordPressCom.swift */; }; 3FFCC0492BAB98130051D229 /* DateFormatter+WordPressCom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FFCC0482BAB98130051D229 /* DateFormatter+WordPressCom.swift */; }; @@ -815,6 +816,7 @@ 3FB8642D288813E9003A86BE /* UnitTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = UnitTests.xctestplan; sourceTree = ""; }; 3FE2E94D2BB29A1B002CA2E1 /* FilePart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FilePart.m; sourceTree = ""; }; 3FE2E94E2BB29A1B002CA2E1 /* FilePart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilePart.h; sourceTree = ""; }; + 3FE2E9662BBEB8D2002CA2E1 /* WordPressComRESTAPIVersion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WordPressComRESTAPIVersion.h; sourceTree = ""; }; 3FFCC0402BA995290051D229 /* Date+WordPressComTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+WordPressComTests.swift"; sourceTree = ""; }; 3FFCC0462BAA6EF40051D229 /* NSDate+WordPressCom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSDate+WordPressCom.swift"; sourceTree = ""; }; 3FFCC0482BAB98130051D229 /* DateFormatter+WordPressCom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateFormatter+WordPressCom.swift"; sourceTree = ""; }; @@ -2033,6 +2035,7 @@ children = ( 3FE2E94E2BB29A1B002CA2E1 /* FilePart.h */, 3FFCC0552BABC78B0051D229 /* WordPressComRESTAPIInterfacing.h */, + 3FE2E9662BBEB8D2002CA2E1 /* WordPressComRESTAPIVersion.h */, ); path = include; sourceTree = ""; @@ -2617,6 +2620,7 @@ 93C674F11EE8351E00BFAF05 /* NSMutableDictionary+Helpers.h in Headers */, 93BD273C1EE73282002BB00B /* AccountServiceRemoteREST.h in Headers */, 93BD27711EE737A8002BB00B /* ServiceRemoteWordPressXMLRPC.h in Headers */, + 3FE2E9672BBEB8D2002CA2E1 /* WordPressComRESTAPIVersion.h in Headers */, 93BD276F1EE737A8002BB00B /* ServiceRemoteWordPressComREST.h in Headers */, 93BD273B1EE73282002BB00B /* AccountServiceRemote.h in Headers */, 93BD27691EE736A8002BB00B /* RemoteUser.h in Headers */, From ee3d90b85eb1a2498c94e55c520f96fd8d26a6be Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 4 Apr 2024 21:43:23 +1100 Subject: [PATCH 5/5] Add changelog entry for enum rename --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c80990b7..926bbd22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,8 @@ _None._ ### Breaking Changes -- Remove unused `anonymousWordPressComRestApiWithUserAgent` method from `ServiceRemoteWordPressComREST` [TBD] +- Removed `anonymousWordPressComRestApiWithUserAgent` method from `ServiceRemoteWordPressComREST` [#778] +- Renamed `ServiceRemoteWordPressComRESTApiVersion` to `WordPressComRestAPIVersion` [#778] ### New Features