[Bugfix] Communications (#7)

This PR contains the work done to implement some bugfixes to the existing source code related to the `Communications` library of this package.

To provide further details about the work done:
- [x] removed an unnecessary function from the `Client` public protocol;
- [x] moved the `MakeURLRequestError` public error to its own file;
- [x] added the `parameters` property to the `Endpoint` public protocol;
- [x] added support for the parameters handling in the `MakeURLRequestUseCase` use case.

Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
2023-04-18 22:55:25 +00:00
parent 6e785b4255
commit d8163ab0de
5 changed files with 63 additions and 23 deletions
@@ -35,6 +35,12 @@ public struct MakeURLRequestUseCase {
urlComponents.port = port
}
if !endpoint.parameters.isEmpty {
urlComponents.queryItems = endpoint.parameters
.map(URLQueryItem.init)
.sorted(by: { $0.name < $1.name })
}
guard let url = urlComponents.url else {
throw MakeURLRequestError.urlNotCreated
}
@@ -49,10 +55,3 @@ public struct MakeURLRequestUseCase {
}
}
// MARK: - Errors
enum MakeURLRequestError: Error {
case urlNotCreated
}