I am migrating an old method I had using Alamofire where I have a function like this:
protocol httpRequestSwiftDelegate {
func httpRequestSwiftError(_ error: NSError, tag: Int)
func httpRequestSwiftResponse(_ response: JSON, tag: Int)
}
class httpRequestSwift {
func requestURL(method: HTTPMethod, url : String, params: [String: String], tag: Int)
}
Then I would delegate the response or the error to the Controller that invoked it.
Now that I want to use Alamofire 5, and take advantage of the Decodable and Encodable features, I am having problems defining the parameters.
In my mind it should be somehting like this:
func requestURL(method: HTTPMethod, url : String, params: Encodable, decodable: Decodable, tag: Int) {
session.request(keychain.string(forKey: K.Api.baseUrl)! + url, method: method, parameters: params)
}
but I get an error:
Value of protocol type 'Encodable' cannot conform to 'Encodable'; only struct/enum/class types can conform to protocols
Thanks.