Skip to content

Commit 109f730

Browse files
committed
Adopt wprs alpha-20250926
1 parent ed66ce6 commit 109f730

File tree

5 files changed

+56
-44
lines changed

5 files changed

+56
-44
lines changed

Modules/Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ let package = Package(
5252
.package(url: "https://github.com/wordpress-mobile/NSURL-IDN", revision: "b34794c9a3f32312e1593d4a3d120572afa0d010"),
5353
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
5454
// We can't use wordpress-rs branches nor commits here. Only tags work.
55-
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20250925"),
55+
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20250926"),
5656
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.8.1-alpha.2"),
5757
.package(
5858
url: "https://github.com/Automattic/color-studio",

Modules/Sources/WordPressCore/Users/User+Extensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import WordPressAPIInternal // Required for `UserRole` Equatable conformance –
33

44
public extension UserRole {
55
var displayString: String {
6-
"" // TODO: This should use .rawValue
6+
self.rawValue.capitalized
77
}
88
}
99

@@ -16,7 +16,7 @@ extension UserRole: @retroactive Codable {
1616

1717
public func encode(to encoder: any Encoder) throws {
1818
var container = encoder.singleValueContainer()
19-
try container.encode("") // TODO: Use `.rawValue` here
19+
try container.encode(self.rawValue)
2020
}
2121
}
2222

WordPress/Classes/Services/CommentServiceRemoteCoreRESTAPI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private extension RemoteComment {
149149
self.postID = NSNumber(value: comment.post)
150150

151151
self.status = comment.status.commentStatusType?.description
152-
self.type = comment.commentType.type
152+
self.type = comment.commentType.rawValue
153153

154154
if let ext = try? comment.additionalFields.parseWpcomCommentsExtension() {
155155
self.postTitle = ext.post?.title

WordPress/Classes/Services/TaxonomyServiceRemoteCoreREST.swift

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import WordPressAPI
2020
public func createCategory(_ category: RemotePostCategory, success: ((RemotePostCategory) -> Void)?, failure: ((any Error) -> Void)? = nil) {
2121
Task { @MainActor in
2222
do {
23-
let params = CategoryCreateParams(
23+
let params = TermCreateParams(
2424
name: category.name ?? "",
2525
parent: category.parentID?.int64Value
2626
)
27-
let response = try await client.api.categories.create(params: params)
27+
let response = try await client.api.terms.create(termEndpointType: .categories, params: params)
2828
let remoteCategory = RemotePostCategory(category: response.data)
2929
success?(remoteCategory)
3030
} catch {
@@ -36,7 +36,10 @@ import WordPressAPI
3636
public func getCategoriesWithSuccess(_ success: @escaping ([RemotePostCategory]) -> Void, failure: ((any Error) -> Void)? = nil) {
3737
Task { @MainActor in
3838
do {
39-
let sequence = await client.api.categories.sequenceWithEditContext(params: CategoryListParams(perPage: 100))
39+
let sequence = await client.api.terms.sequenceWithEditContext(
40+
type: .categories,
41+
params: TermListParams(perPage: 100)
42+
)
4043
let categories: [RemotePostCategory] = try await sequence.reduce(into: []) {
4144
let page = $1.map(RemotePostCategory.init(category:))
4245
$0.append(contentsOf: page)
@@ -51,14 +54,17 @@ import WordPressAPI
5154
public func getCategoriesWith(_ paging: RemoteTaxonomyPaging, success: @escaping ([RemotePostCategory]) -> Void, failure: ((any Error) -> Void)? = nil) {
5255
Task { @MainActor in
5356
do {
54-
let params = CategoryListParams(
57+
let params = TermListParams(
5558
page: paging.page?.uint32Value,
5659
perPage: paging.number?.uint32Value,
5760
offset: paging.offset?.uint32Value,
58-
order: .init(paging.order),
59-
orderby: .init(paging.orderBy)
61+
order: WpApiParamOrder(paging.order),
62+
orderby: WpApiParamTermsOrderBy(paging.orderBy)
63+
)
64+
let response = try await client.api.terms.listWithEditContext(
65+
termEndpointType: .categories,
66+
params: params
6067
)
61-
let response = try await client.api.categories.listWithEditContext(params: params)
6268
let categories = response.data.map(RemotePostCategory.init(category:))
6369
success(categories)
6470
} catch {
@@ -70,8 +76,11 @@ import WordPressAPI
7076
public func searchCategories(withName nameQuery: String, success: @escaping ([RemotePostCategory]) -> Void, failure: ((any Error) -> Void)? = nil) {
7177
Task { @MainActor in
7278
do {
73-
let params = CategoryListParams(search: nameQuery)
74-
let response = try await client.api.categories.listWithEditContext(params: params)
79+
let params = TermListParams(search: nameQuery)
80+
let response = try await client.api.terms.listWithEditContext(
81+
termEndpointType: .categories,
82+
params: params
83+
)
7584
let categories = response.data.map(RemotePostCategory.init(category:))
7685
success(categories)
7786
} catch {
@@ -83,12 +92,15 @@ import WordPressAPI
8392
public func createTag(_ tag: RemotePostTag, success: ((RemotePostTag) -> Void)?, failure: ((any Error) -> Void)? = nil) {
8493
Task { @MainActor in
8594
do {
86-
let params = TagCreateParams(
95+
let params = TermCreateParams(
8796
name: tag.name ?? "",
8897
description: tag.tagDescription,
8998
slug: tag.slug
9099
)
91-
let response = try await client.api.tags.create(params: params)
100+
let response = try await client.api.terms.create(
101+
termEndpointType: .tags,
102+
params: params
103+
)
92104
let remoteTag = RemotePostTag(tag: response.data)
93105
success?(remoteTag)
94106
} catch {
@@ -105,12 +117,16 @@ import WordPressAPI
105117

106118
Task { @MainActor in
107119
do {
108-
let params = TagUpdateParams(
120+
let params = TermUpdateParams(
109121
name: tag.name,
110122
description: tag.tagDescription,
111123
slug: tag.slug
112124
)
113-
let response = try await client.api.tags.update(tagId: TagId(tagID.int64Value), params: params)
125+
let response = try await client.api.terms.update(
126+
termEndpointType: .tags,
127+
termId: tagID.int64Value,
128+
params: params
129+
)
114130
let remoteTag = RemotePostTag(tag: response.data)
115131
success?(remoteTag)
116132
} catch {
@@ -127,7 +143,7 @@ import WordPressAPI
127143

128144
Task { @MainActor in
129145
do {
130-
let _ = try await client.api.tags.delete(tagId: TagId(tagID.int64Value))
146+
let _ = try await client.api.terms.delete(termEndpointType: .tags, termId: tagID.int64Value)
131147
success?()
132148
} catch {
133149
failure?(error)
@@ -138,7 +154,10 @@ import WordPressAPI
138154
public func getTagsWithSuccess(_ success: @escaping ([RemotePostTag]) -> Void, failure: ((any Error) -> Void)? = nil) {
139155
Task { @MainActor in
140156
do {
141-
let response = try await client.api.tags.listWithEditContext(params: TagListParams())
157+
let response = try await client.api.terms.listWithEditContext(
158+
termEndpointType: .tags,
159+
params: TermListParams()
160+
)
142161
let tags = response.data.map(RemotePostTag.init(tag:))
143162
success(tags)
144163
} catch {
@@ -150,14 +169,17 @@ import WordPressAPI
150169
public func getTagsWith(_ paging: RemoteTaxonomyPaging, success: @escaping ([RemotePostTag]) -> Void, failure: ((any Error) -> Void)? = nil) {
151170
Task { @MainActor in
152171
do {
153-
let params = TagListParams(
172+
let params = TermListParams(
154173
page: paging.page?.uint32Value,
155174
perPage: paging.number?.uint32Value,
156175
offset: paging.offset?.uint32Value,
157-
order: .init(paging.order),
158-
orderby: .init(paging.orderBy)
176+
order: WpApiParamOrder(paging.order),
177+
orderby: WpApiParamTermsOrderBy(paging.orderBy)
178+
)
179+
let response = try await client.api.terms.listWithEditContext(
180+
termEndpointType: .tags,
181+
params: params
159182
)
160-
let response = try await client.api.tags.listWithEditContext(params: params)
161183
let tags = response.data.map(RemotePostTag.init(tag:))
162184
success(tags)
163185
} catch {
@@ -169,7 +191,10 @@ import WordPressAPI
169191
public func searchTags(withName nameQuery: String, success: @escaping ([RemotePostTag]) -> Void, failure: ((any Error) -> Void)? = nil) {
170192
Task { @MainActor in
171193
do {
172-
let response = try await client.api.tags.listWithEditContext(params: TagListParams(search: nameQuery))
194+
let response = try await client.api.terms.listWithEditContext(
195+
termEndpointType: .tags,
196+
params: TermListParams(search: nameQuery)
197+
)
173198
let tags = response.data.map(RemotePostTag.init(tag:))
174199
success(tags)
175200
} catch {
@@ -180,16 +205,16 @@ import WordPressAPI
180205
}
181206

182207
private extension RemotePostCategory {
183-
convenience init(category: CategoryWithEditContext) {
208+
convenience init(category: AnyTermWithEditContext) {
184209
self.init()
185210
self.categoryID = NSNumber(value: category.id)
186211
self.name = category.name
187-
self.parentID = NSNumber(value: category.parent)
212+
self.parentID = NSNumber(value: category.parent ?? 0)
188213
}
189214
}
190215

191216
private extension RemotePostTag {
192-
convenience init(tag: TagWithEditContext) {
217+
convenience init(tag: AnyTermWithEditContext) {
193218
self.init()
194219
self.tagID = NSNumber(value: tag.id)
195220
self.name = tag.name
@@ -212,20 +237,7 @@ private extension WpApiParamOrder {
212237
}
213238
}
214239

215-
private extension WpApiParamCategoriesOrderBy {
216-
init(_ other: RemoteTaxonomyPagingResultsOrdering) {
217-
switch other {
218-
case .byName:
219-
self = .name
220-
case .byCount:
221-
self = .count
222-
@unknown default:
223-
self = .name
224-
}
225-
}
226-
}
227-
228-
private extension WpApiParamTagsOrderBy {
240+
private extension WpApiParamTermsOrderBy {
229241
init(_ other: RemoteTaxonomyPagingResultsOrdering) {
230242
switch other {
231243
case .byName:

0 commit comments

Comments
 (0)