Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 83d03ab

Browse files
committed
Use WordPressComRESTAPIInterfacing in ThemeServiceRemote
Required updating it to return a discardable `NSProgress * _Nullable` value, as per the original API which I didn't notice.
1 parent baf5fb8 commit 83d03ab

4 files changed

Lines changed: 22 additions & 22 deletions

File tree

WordPressKit/ThemeServiceRemote.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ - (NSProgress *)getActiveThemeForBlogId:(NSNumber *)blogId
2828
NSString *requestUrl = [self pathForEndpoint:path
2929
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
3030

31-
NSProgress *progress = [self.wordPressComRestApi GET:requestUrl
31+
NSProgress *progress = [self.wordPressComRESTAPI get:requestUrl
3232
parameters:nil
3333
success:^(NSDictionary *themeDictionary, NSHTTPURLResponse *httpResponse) {
3434
if (success) {
@@ -55,7 +55,7 @@ - (NSProgress *)getPurchasedThemesForBlogId:(NSNumber *)blogId
5555
NSString *requestUrl = [self pathForEndpoint:path
5656
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
5757

58-
NSProgress *progress = [self.wordPressComRestApi GET:requestUrl
58+
NSProgress *progress = [self.wordPressComRESTAPI get:requestUrl
5959
parameters:nil
6060
success:^(NSDictionary *response, NSHTTPURLResponse *httpResponse) {
6161
if (success) {
@@ -81,7 +81,7 @@ - (NSProgress *)getThemeId:(NSString*)themeId
8181
NSString *requestUrl = [self pathForEndpoint:path
8282
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
8383

84-
NSProgress *progress = [self.wordPressComRestApi GET:requestUrl
84+
NSProgress *progress = [self.wordPressComRESTAPI get:requestUrl
8585
parameters:nil
8686
success:^(NSDictionary *themeDictionary, NSHTTPURLResponse *httpResponse) {
8787
if (success) {
@@ -233,7 +233,7 @@ - (NSProgress *)getThemesWithRequestUrl:(NSString *)requestUrl
233233
failure:(ThemeServiceRemoteFailureBlock)failure
234234
{
235235

236-
return [self.wordPressComRestApi GET:requestUrl
236+
return [self.wordPressComRESTAPI get:requestUrl
237237
parameters:parameters
238238
success:^(NSDictionary *response, NSHTTPURLResponse *httpResponse) {
239239
if (success) {
@@ -270,7 +270,7 @@ - (NSProgress *)activateThemeId:(NSString *)themeId
270270

271271
NSDictionary* parameters = @{@"theme": themeId};
272272

273-
NSProgress *progress = [self.wordPressComRestApi POST:requestUrl
273+
NSProgress *progress = [self.wordPressComRESTAPI post:requestUrl
274274
parameters:parameters
275275
success:^(NSDictionary *themeDictionary, NSHTTPURLResponse *httpResponse) {
276276
if (success) {
@@ -299,7 +299,7 @@ - (NSProgress *)installThemeId:(NSString*)themeId
299299
NSString *requestUrl = [self pathForEndpoint:path
300300
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
301301

302-
NSProgress *progress = [self.wordPressComRestApi POST:requestUrl
302+
NSProgress *progress = [self.wordPressComRESTAPI post:requestUrl
303303
parameters:nil
304304
success:^(NSDictionary *themeDictionary, NSHTTPURLResponse *httpResponse) {
305305
if (success) {

WordPressKit/WordPressComRESTAPIInterfacing.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
@property (strong, nonatomic, readonly) NSURL * _Nonnull baseURL;
66

7-
- (void)get:(NSString * _Nonnull)URLString
8-
parameters:(NSDictionary<NSString *, NSObject *> * _Nullable)parameters
9-
success:(void (^ _Nonnull)(id _Nonnull, NSHTTPURLResponse * _Nullable))success
10-
failure:(void (^ _Nonnull)(NSError * _Nonnull, NSHTTPURLResponse * _Nullable))failure;
7+
- (NSProgress * _Nullable)get:(NSString * _Nonnull)URLString
8+
parameters:(NSDictionary<NSString *, NSObject *> * _Nullable)parameters
9+
success:(void (^ _Nonnull)(id _Nonnull, NSHTTPURLResponse * _Nullable))success
10+
failure:(void (^ _Nonnull)(NSError * _Nonnull, NSHTTPURLResponse * _Nullable))failure;
1111

12-
- (void)post:(NSString * _Nonnull)URLString
13-
parameters:(NSDictionary<NSString *, NSObject *> * _Nullable)parameters
14-
success:(void (^ _Nonnull)(id _Nonnull, NSHTTPURLResponse * _Nullable))success
15-
failure:(void (^ _Nonnull)(NSError * _Nonnull, NSHTTPURLResponse * _Nullable))failure;
12+
- (NSProgress * _Nullable)post:(NSString * _Nonnull)URLString
13+
parameters:(NSDictionary<NSString *, NSObject *> * _Nullable)parameters
14+
success:(void (^ _Nonnull)(id _Nonnull, NSHTTPURLResponse * _Nullable))success
15+
failure:(void (^ _Nonnull)(NSError * _Nonnull, NSHTTPURLResponse * _Nullable))failure;
1616

1717
@end

WordPressKit/WordPressComRestApi.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ extension WordPressComRestApi: WordPressComRESTAPIInterfacing {
634634
parameters: [String: NSObject]?,
635635
success: @escaping (Any, HTTPURLResponse?) -> Void,
636636
failure: @escaping (any Error, HTTPURLResponse?) -> Void
637-
) {
637+
) -> Progress? {
638638
GET(URLString, parameters: parameters, success: success, failure: failure)
639639
}
640640

@@ -643,7 +643,7 @@ extension WordPressComRestApi: WordPressComRESTAPIInterfacing {
643643
parameters: [String: NSObject]?,
644644
success: @escaping (Any, HTTPURLResponse?) -> Void,
645645
failure: @escaping (any Error, HTTPURLResponse?) -> Void
646-
) {
646+
) -> Progress? {
647647
POST(URLString, parameters: parameters, success: success, failure: failure)
648648
}
649649
}

WordPressKitTests/ThemeServiceRemoteTests.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ - (void)testThatGetActiveThemeForBlogIdWorks
4242
NSString *url = [service pathForEndpoint:endpoint
4343
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
4444

45-
[OCMStub([api GET:[OCMArg isEqual:url]
45+
[OCMStub([api get:[OCMArg isEqual:url]
4646
parameters:[OCMArg isNil]
4747
success:[OCMArg isNotNil]
4848
failure:[OCMArg isNotNil]]) andDo:^(NSInvocation *invocation) {
@@ -95,7 +95,7 @@ - (void)testThatGetPurchasedThemesForBlogIdWorks
9595
NSString *url = [service pathForEndpoint:endpoint
9696
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
9797

98-
[OCMStub([api GET:[OCMArg isEqual:url]
98+
[OCMStub([api get:[OCMArg isEqual:url]
9999
parameters:[OCMArg isNil]
100100
success:[OCMArg isNotNil]
101101
failure:[OCMArg isNotNil]]) andDo:^(NSInvocation *invocation) {
@@ -148,7 +148,7 @@ - (void)testThatGetThemeIdWorks
148148
NSString *url = [service pathForEndpoint:endpoint
149149
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
150150

151-
[OCMStub([api GET:[OCMArg isEqual:url]
151+
[OCMStub([api get:[OCMArg isEqual:url]
152152
parameters:[OCMArg isNil]
153153
success:[OCMArg isNotNil]
154154
failure:[OCMArg isNotNil]]) andDo:^(NSInvocation *invocation) {
@@ -203,7 +203,7 @@ - (void)testThatGetThemesWorks
203203
NSCAssert(totalThemeCount == expectedThemes, @"Expected %ld themes to be found", expectedThemes);
204204
};
205205

206-
[OCMStub([api GET:[OCMArg isEqual:url]
206+
[OCMStub([api get:[OCMArg isEqual:url]
207207
parameters:[OCMArg isNotNil]
208208
success:[OCMArg isNotNil]
209209
failure:[OCMArg isNotNil]]) andDo:^(NSInvocation *invocation) {
@@ -247,7 +247,7 @@ - (void)testThatGetThemesForBlogIdWorks
247247
NSString *url = [service pathForEndpoint:endpoint
248248
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2];
249249

250-
[OCMStub([api GET:[OCMArg isEqual:url]
250+
[OCMStub([api get:[OCMArg isEqual:url]
251251
parameters:[OCMArg isNotNil]
252252
success:[OCMArg isNotNil]
253253
failure:[OCMArg isNotNil]]) andDo:^(NSInvocation *invocation) {
@@ -311,7 +311,7 @@ - (void)testThatActivateThemeIdWorks
311311
return [themeIdParameter isEqualToString:themeId];
312312
};
313313

314-
[OCMStub([api POST:[OCMArg isEqual:url]
314+
[OCMStub([api post:[OCMArg isEqual:url]
315315
parameters:[OCMArg checkWithBlock:checkBlock]
316316
success:[OCMArg isNotNil]
317317
failure:[OCMArg isNotNil]]) andDo:^(NSInvocation *invocation) {

0 commit comments

Comments
 (0)