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

Commit 470171b

Browse files
committed
Add PostServiceRemoteREST/createAutosave
1 parent 41bda2a commit 470171b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ _None._
3838

3939
### New Features
4040

41-
_None._
41+
- Add `PostServiceRemoteREST/createAutosave` that uses new types to represent request parameters
4242

4343
### Bug Fixes
4444

Sources/WordPressKit/Services/PostServiceRemoteREST+Extended.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ extension PostServiceRemoteREST: PostServiceRemoteExtended {
5959
}
6060
}
6161
}
62+
63+
public func createAutosave(forPostID postID: Int, parameters: RemotePostCreateParameters) async throws -> RemotePostAutosaveResponse {
64+
let path = self.path(forEndpoint: "sites/\(siteID)/posts/\(postID)/autosave", withVersion: ._1_1)
65+
let parameters = try makeParameters(from: RemotePostCreateParametersWordPressComEncoder(parameters: parameters))
66+
let result = await wordPressComRestApi.perform(.post, URLString: path, parameters: parameters, type: RemotePostAutosaveResponse.self)
67+
return try result.get().body
68+
}
69+
}
70+
71+
public struct RemotePostAutosaveResponse: Decodable {
72+
public let autosaveID: Int
73+
public let previewURL: URL
74+
75+
enum CodingKeys: String, CodingKey {
76+
case autosaveID = "ID"
77+
case previewURL = "preview_URL"
78+
}
6279
}
6380

6481
// Decodes the post in the background.

0 commit comments

Comments
 (0)