Skip to content

Commit f8c9f6f

Browse files
authored
Merge pull request #63 from futuredapp/feature/url-query-as-KeyValuePairs
Use KeyValuePairs instead of Dictionary for url query
2 parents 69baa18 + 084abcb commit f8c9f6f

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

Sources/FTAPIKit/Endpoint.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ public protocol Endpoint {
1717

1818
var headers: [String: String] { get }
1919

20-
var query: [String: String] { get }
20+
var query: KeyValuePairs<String, String> { get }
2121

2222
/// HTTP method/verb describing the action.
2323
var method: HTTPMethod { get }
2424
}
2525

2626
public extension Endpoint {
2727
var headers: [String: String] { [:] }
28-
var query: [String: String] { [:] }
28+
var query: KeyValuePairs<String, String> { [:] }
2929
var method: HTTPMethod { .get }
3030
}
3131

@@ -42,7 +42,7 @@ public protocol MultipartEndpoint: Endpoint {
4242
}
4343

4444
public protocol URLEncodedEndpoint: Endpoint {
45-
var body: [String: String] { get }
45+
var body: KeyValuePairs<String, String> { get }
4646
}
4747

4848
/// Endpoint protocol extending `Endpoint` having decodable associated type, which is used

Sources/FTAPIKit/URLRequestBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct URLRequestBuilder<S: URLServer> {
5151
}
5252
}
5353

54-
private func queryItems(parameters: [String: String]) -> [URLQueryItem] {
54+
private func queryItems(parameters: KeyValuePairs<String, String>) -> [URLQueryItem] {
5555
parameters.compactMap { key, value in
5656
guard let encodedKey = key.addingPercentEncoding(withAllowedCharacters: .urlQueryNameValueAllowed),
5757
let encodedValue = value.addingPercentEncoding(withAllowedCharacters: .urlQueryNameValueAllowed) else {

Tests/FTAPIKitTests/Mockups/Endpoints.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct TestMultipartEndpoint: MultipartEndpoint {
7878
struct TestURLEncodedEndpoint: URLEncodedEndpoint {
7979
let path = "post"
8080
let method: HTTPMethod = .post
81-
let body: [String: String] = [
81+
let body: KeyValuePairs<String, String> = [
8282
"param1": "value1",
8383
"param2": "value2"
8484
]

0 commit comments

Comments
 (0)