NetworkClient

public protocol NetworkClient

Protocol for sending network requests and handling responses.

  • Sends a URLRequest as is and completes with a NetworkResult. It returns a Disposable that can be disposed to cancel the request sent.

    Request lifecycle events are sent to the request interceptors and they are retried, when necessary, following the RequestInterceptor logic.

    Declaration

    Swift

    func sendRequest(_ request: URLRequest, completion: @escaping (NetworkResult) -> Void) -> Disposable

    Parameters

    request

    the URLRequest that is sent in the URLSession.dataTask

    completion

    the block that is called once the request is completed either with a success or with an unretryable error

    Return Value

    the Disposable that can be used to dispose the request and cancel the dataTask and future retries.

  • Creates a new NetworkClient from this instance which will use a specific logger.

    Declaration

    Swift

    func newClient(withLogger logger: LoggerProtocol) -> Self

    Parameters

    logger

    The logger that will be used for this instance

    Return Value

    A new NetworkClient instance.