Skip to content

Commit

Permalink
Use WordPressComRESTAPIInterfacing in AccountServiceRemoteREST
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio committed Mar 25, 2024
1 parent bc80e76 commit 4776cd8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions WordPressKit/AccountServiceRemoteREST+SocialService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension AccountServiceRemoteREST {
params.merge(connectParameters, uniquingKeysWith: { (current, _) in current })
}

wordPressComRestApi.POST(path, parameters: params, success: { (_, _) in
wordPressComRESTAPI.post(path, parameters: params, success: { (_, _) in
success()
}, failure: { (error, _) in
failure(error)
Expand Down Expand Up @@ -73,7 +73,7 @@ extension AccountServiceRemoteREST {
"service": service.rawValue
] as [String: AnyObject]

wordPressComRestApi.POST(path, parameters: params, success: { (_, _) in
wordPressComRESTAPI.post(path, parameters: params, success: { (_, _) in
success()
}, failure: { (error, _) in
failure(error)
Expand Down
16 changes: 8 additions & 8 deletions WordPressKit/AccountSettingsRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class AccountSettingsRemote: ServiceRemoteWordPressComREST {
let parameters = ["context": "edit"]
let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)

wordPressComRestApi.GET(path,
wordPressComRESTAPI.get(path,
parameters: parameters as [String: AnyObject]?,
success: {
responseObject, _ in
Expand All @@ -54,7 +54,7 @@ public class AccountSettingsRemote: ServiceRemoteWordPressComREST {
let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)
let parameters = [fieldNameForChange(change): change.stringValue]

wordPressComRestApi.POST(path,
wordPressComRESTAPI.post(path,
parameters: parameters as [String: AnyObject]?,
success: {
_, _ in
Expand All @@ -79,7 +79,7 @@ public class AccountSettingsRemote: ServiceRemoteWordPressComREST {

let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)

wordPressComRestApi.POST(path,
wordPressComRESTAPI.post(path,
parameters: parameters as [String: AnyObject]?,
success: { _, _ in
success()
Expand All @@ -99,7 +99,7 @@ public class AccountSettingsRemote: ServiceRemoteWordPressComREST {
let endpoint = "me/username/validate/\(username)"
let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)

wordPressComRestApi.GET(path,
wordPressComRESTAPI.get(path,
parameters: nil,
success: { _, _ in
// The success block needs to be changed if
Expand All @@ -116,7 +116,7 @@ public class AccountSettingsRemote: ServiceRemoteWordPressComREST {
let endpoint = "wpcom/v2/users/username/suggestions"
let parameters = ["name": base]

wordPressComRestApi.GET(endpoint, parameters: parameters as [String: AnyObject]?, success: { (responseObject, _) in
wordPressComRESTAPI.get(endpoint, parameters: parameters as [String: AnyObject]?, success: { (responseObject, _) in
guard let response = responseObject as? [String: AnyObject],
let suggestions = response["suggestions"] as? [String] else {
finished([])
Expand All @@ -134,7 +134,7 @@ public class AccountSettingsRemote: ServiceRemoteWordPressComREST {
let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)
let parameters = ["password": password]

wordPressComRestApi.POST(path,
wordPressComRESTAPI.post(path,
parameters: parameters as [String: AnyObject]?,
success: {
_, _ in
Expand All @@ -149,14 +149,14 @@ public class AccountSettingsRemote: ServiceRemoteWordPressComREST {
let endpoint = "me/account/close"
let path = path(forEndpoint: endpoint, withVersion: ._1_1)

wordPressComRestApi.POST(path, parameters: nil) { _, _ in
wordPressComRESTAPI.post(path, parameters: nil) { _, _ in
success()
} failure: { error, _ in
failure(error)
}
}

private func settingsFromResponse(_ responseObject: AnyObject) throws -> AccountSettings {
private func settingsFromResponse(_ responseObject: Any) throws -> AccountSettings {
guard let response = responseObject as? [String: AnyObject],
let firstName = response["first_name"] as? String,
let lastName = response["last_name"] as? String,
Expand Down
7 changes: 4 additions & 3 deletions WordPressKit/ActivityServiceRemote_ApiVersion1_0.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
parameters["types"] = types.toDictionary() as AnyObject
}

wordPressComRestApi.POST(path,
wordPressComRESTAPI.post(path,
parameters: parameters,
success: { response, _ in
guard let restoreID = response["restore_id"] as? Int,
let jobID = response["job_id"] as? Int else {
guard let responseDict = response as? [String: Any],
let restoreID = responseDict["restore_id"] as? Int,
let jobID = responseDict["job_id"] as? Int else {
failure(ResponseError.decodingFailure)
return
}
Expand Down

0 comments on commit 4776cd8

Please sign in to comment.