DownloadAPIRequest

open class DownloadAPIRequest<Model, ErrorModel> : BaseRequest<Model, ErrorModel> where ErrorModel : DownloadErrorSerializable

DownloadAPIRequest encapsulates download request creation logic, stubbing options, and response/error parsing.

  • Serialize download response into Result<Model>.

    Declaration

    Swift

    public typealias DownloadResponseParser = (_ request: URLRequest?, _ response: HTTPURLResponse?, _ url: URL?, _ error: Error?) throws -> Model
  • Serializes received failed response into APIError object

    Declaration

    Swift

    public typealias DownloadErrorParser = (_ request: URLRequest?, _ response: HTTPURLResponse?, _ url: URL?, _ error: Error?) -> ErrorModel
  • Serializes received response into Result

    Declaration

    Swift

    open var responseParser: DownloadResponseParser
  • Serializes received error into APIError

    Declaration

    Swift

    open var errorParser: DownloadErrorParser
  • Closure that is applied to request before it is sent.

    Declaration

    Swift

    open var validationClosure: (DownloadRequest) -> DownloadRequest
  • Sets validationClosure to validation parameter and returns configured request

    Declaration

    Swift

    open func validation(_ validation: @escaping (DownloadRequest) -> DownloadRequest) -> Self

    Parameters

    validation

    validation to perform.

    Return Value

    configured request.

  • Creates DownloadAPIRequest with specified type, path and configures it with to be used with tron.

    Declaration

    Swift

    public init<Serializer: DownloadResponseSerializerProtocol>(type: DownloadRequestType, path: String, tron: TRON, responseSerializer: Serializer)
        where Serializer.SerializedObject == Model
  • Undocumented

    Declaration

    Swift

    @discardableResult
    open func perform(withSuccess successBlock: ((Model) -> Void)? = nil, failure failureBlock: ((ErrorModel) -> Void)? = nil) -> DownloadRequest
  • Undocumented

    Declaration

    Swift

    @discardableResult
    open func performCollectingTimeline(withCompletion completion: @escaping ((Alamofire.DownloadResponse<Model, AFError>) -> Void)) -> DownloadRequest
  • Undocumented

    Declaration

    Swift

    func publisher() -> AnyPublisher<Model, ErrorModel>