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

Commit a7415a0

Browse files
committed
Add POST method to WordPressComRESTAPIInterfacing
Used for all POST requests in `AccountServiceRemoteREST`
1 parent 73d51e7 commit a7415a0

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Sources/APIInterface/include/WordPressComRESTAPIInterfacing.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@
77
success:(void (^ _Nonnull)(id _Nonnull, NSHTTPURLResponse * _Nullable))success
88
failure:(void (^ _Nonnull)(NSError * _Nonnull, NSHTTPURLResponse * _Nullable))failure;
99

10+
- (void)post:(NSString * _Nonnull)URLString
11+
parameters:(NSDictionary<NSString *, NSObject *> * _Nullable)parameters
12+
success:(void (^ _Nonnull)(id _Nonnull, NSHTTPURLResponse * _Nullable))success
13+
failure:(void (^ _Nonnull)(NSError * _Nonnull, NSHTTPURLResponse * _Nullable))failure;
14+
1015
@end

WordPressKit/AccountServiceRemoteREST.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ - (void)updateBlogsVisibility:(NSDictionary *)blogs
108108
};
109109
NSString *path = [self pathForEndpoint:@"me/sites"
110110
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
111-
[self.wordPressComRestApi POST:path
111+
[self.wordPressComRESTAPI post:path
112112
parameters:parameters
113113
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
114114
if (success) {
@@ -317,7 +317,7 @@ - (void)requestWPComMagicLinkForEmail:(NSString *)email
317317
[params addEntriesFromDictionary:extraParams];
318318
}
319319

320-
[self.wordPressComRestApi POST:path
320+
[self.wordPressComRESTAPI post:path
321321
parameters:[NSDictionary dictionaryWithDictionary:params]
322322
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
323323
if (success) {
@@ -336,7 +336,7 @@ - (void)requestVerificationEmailWithSucccess:(void (^)(void))success
336336
NSString *path = [self pathForEndpoint:@"me/send-verification-email"
337337
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
338338

339-
[self.wordPressComRestApi POST:path parameters:nil success:^(id _Nonnull responseObject, NSHTTPURLResponse * _Nullable httpResponse) {
339+
[self.wordPressComRESTAPI post:path parameters:nil success:^(id _Nonnull responseObject, NSHTTPURLResponse * _Nullable httpResponse) {
340340
if (success) {
341341
success();
342342
}

WordPressKit/WordPressComRestApi.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ extension WordPressComRestApi: WordPressComRESTAPIInterfacing {
628628
// Also, there is no Objective-C direct equivalent of `AnyObject`, which here is used in `parameters: [String: AnyObject]?`.
629629
//
630630
// For those reasons, we can't immediately conform to `WordPressComRESTAPIInterfacing` and need instead to use this kind of wrapping.
631+
// The same applies for the other methods below.
631632
public func get(
632633
_ URLString: String,
633634
parameters: [String: NSObject]?,
@@ -636,4 +637,13 @@ extension WordPressComRestApi: WordPressComRESTAPIInterfacing {
636637
) {
637638
GET(URLString, parameters: parameters, success: success, failure: failure)
638639
}
640+
641+
public func post(
642+
_ URLString: String,
643+
parameters: [String: NSObject]?,
644+
success: @escaping (Any, HTTPURLResponse?) -> Void,
645+
failure: @escaping (any Error, HTTPURLResponse?) -> Void
646+
) {
647+
POST(URLString, parameters: parameters, success: success, failure: failure)
648+
}
639649
}

0 commit comments

Comments
 (0)