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

Commit dd1dcf2

Browse files
Changes getDomainsSuggestions() to take an object as its input parameter.
1 parent d07fb8c commit dd1dcf2

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

WordPressKit/DomainsServiceRemote.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ public struct DomainSuggestion: Codable {
1717
}
1818
}
1919

20+
/// Allows the construction of a request for domain suggestions.
21+
///
22+
public struct DomainSuggestionRequest: Encodable {
23+
public let query: String
24+
public let segmentID: Int64
25+
26+
init(query: String, segmentID: Int64) {
27+
self.query = query
28+
self.segmentID = segmentID
29+
}
30+
}
31+
2032
public class DomainsServiceRemote: ServiceRemoteWordPressComREST {
2133
public enum ResponseError: Error {
2234
case decodingFailed
@@ -156,14 +168,15 @@ public class DomainsServiceRemote: ServiceRemoteWordPressComREST {
156168
}
157169
}
158170

159-
public func getDomainSuggestions(base query: String,
160-
segmentID: Int64,
171+
public func getDomainSuggestions(request: DomainSuggestionRequest,
161172
success: @escaping ([DomainSuggestion]) -> Void,
162173
failure: @escaping (Error) -> Void) {
163174
let endPoint = "domains/suggestions"
164175
let servicePath = path(forEndpoint: endPoint, withVersion: ._1_1)
165-
var parameters: [String: AnyObject] = ["segment_id": segmentID as AnyObject]
166-
parameters["query"] = query as AnyObject
176+
let parameters: [String: AnyObject] = [
177+
"segment_id": request.segmentID as AnyObject,
178+
"query": request.query as AnyObject
179+
]
167180

168181
wordPressComRestApi.GET(servicePath,
169182
parameters: parameters,

0 commit comments

Comments
 (0)