APIRequest

open class APIRequest<Model, ErrorModel> : BaseRequest<Model, ErrorModel> where ErrorModel : ErrorSerializable

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

  • Serializes received response into Result

    Declaration

    Swift

    open var responseParser: ResponseParser
  • Serializes received error into APIError

    Declaration

    Swift

    open var errorParser: ErrorParser
  • Closure that is applied to request before it is sent. Defaults to { $0.validate() }

    Declaration

    Swift

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

    Declaration

    Swift

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

    Parameters

    validation

    validation to perform.

    Return Value

    configured request.

  • Creates APIRequest, filling responseParser and errorParser properties

    Declaration

    Swift

    public init<Serializer: DataResponseSerializerProtocol>(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) -> Alamofire.DataRequest
  • Undocumented

    Declaration

    Swift

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

    Declaration

    Swift

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