APIAdapter
public protocol APIAdapter
Protocol describing interface communicating with API resources (most probably over internet). This interface encapsulates executing requests.
Standard implementation of this interface using URLSession is available as
URLSessionAPIAdapter.
-
Delegate used for notificating about the currently running request count and asynchronously signing authorized requests.
Declaration
Swift
var delegate: APIAdapterDelegate? { get set } -
Calls API request endpoint with JSON body and after finishing it calls completion handler with either decoded JSON model or error.
Declaration
Swift
func request<Endpoint: APIResponseEndpoint>(response endpoint: Endpoint, completion: @escaping (Result<Endpoint.Response, Error>) -> Void)Parameters
endpointResponse endpoint
completionCompletion closure receiving result with automatically decoded JSON model taken from reponse endpoint associated type.
-
Calls API endpoint and after finishing it calls completion handler with either data or error.
Declaration
Swift
func request(data endpoint: APIEndpoint, completion: @escaping (Result<Data, Error>) -> Void)Parameters
endpointStandard endpoint with no response associated type.
completionCompletion closure receiving result with data.
View on GitHub
APIAdapter Protocol Reference