Classes
The following classes are available globally.
-
BasicNetworkService
handles network request for resources by using a givenNetworkAccess
.Example:
// Just use an URLSession for the networkAccess. let basicNetworkService: NetworkService = BasicNetworkService(networkAccess: URLSession(configuration: .default))
Seealso
NetworkService
Declaration
Swift
public final class BasicNetworkService : NetworkService
-
A task which contains another task which can be updated in fligh. Use this task to compose a chain of requests during the original request. An oAuth Flow would be a good example for this.
Note
Take look atRetryNetworkService
to see how to use it in detail.Declaration
Swift
public final class ContainerNetworkTask : NetworkTask
-
ModifyRequestNetworkService
can be composed with a network service to modify all outgoing requests. One could add auth tokens or API keys for specifics URLs.Example:
let networkService: NetworkService = // let modifyRequestNetworkService = ModifyRequestNetworkService(networkService: networkService, requestModifications: [ { request in return request.added(HTTPHeaderFields: ["API-Key": "SecretKey"]) }])
Note
Requests can only be modified syncronously.Seealso
NetworkService
Declaration
Swift
public final class ModifyRequestNetworkService : NetworkService
-
Mocks a
NetworkService
. You can configure expected results or errors to have a fully functional mock.Example:
See more//Given let networkServiceMock = NetworkServiceMock() let resource: Resource<String> = // //When networkService.request( resource, onCompletion: { string in /*...
Declaration
Swift
public final class NetworkServiceMock : NetworkService
-
Mock implementation for
See moreNetworkTask
.Declaration
Swift
public class NetworkTaskMock : NetworkTask
-
RetryNetworkService
can request resource. When a request fails with a given condtion it can retry the request after a given time interval. The count of retry attemps can be configured as well.Seealso
NetworkService
Declaration
Swift
public final class RetryNetworkService : NetworkService