APIotaClient
public protocol APIotaClient
Defines an API Client.
The definition includes a session, a decoder and a baseURLComponents.
that should be used when sending URLRequests to the REST API server specified.
-
A
URLSessionto use for sendingURLRequests from the Client to the REST API.Declaration
Swift
var session: URLSession { get } -
A
JSONDecoderto use for decoding the responses received by the Client from the REST API.Declaration
Swift
var decoder: JSONDecoder { get } -
Used to define the base URL (i.e.
host), and any other root-level components of the REST API.Declaration
Swift
var baseUrlComponents: URLComponents { get } -
sendRequest(for:Default implementationcallback: ) Send a
URLRequestto the specified REST API, returning a response via a callback closure.Default Implementation
Declaration
Swift
func sendRequest<T: APIotaCodableEndpoint>(for endpoint: T, callback: @escaping (Result<T.SuccessResponse, Error>) -> Void)Parameters
endpointAn
APIotaCodableEndpointdefining the format of theURLRequestto be sent.callbackA closure executed when a response (or an error) is returned as a result of sending the
URLRequestto the REST API. -
sendRequest(for:Default implementation) Send a
URLRequestto the specified REST API, returning a response via a CombineAnyPublisher.Default Implementation
Declaration
Swift
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) func sendRequest<T>(for endpoint: T) -> AnyPublisher<T.SuccessResponse, Error> where T : APIotaCodableEndpointParameters
endpointAn
APIotaCodableEndpointdefining the format of theURLRequestto be sent.Return Value
An
AnyPublisherwhich can be integrated with SwiftUI or Combine code paths.
View on GitHub
Install in Dash
APIotaClient Protocol Reference