Requestable

public protocol Requestable

A Requestable is an interfaces for types that express the details of an HTTP request

Types that conform to Requestable can be used as a paramater in RequestManager‘s makeRequest method, to create an observable combine publisher. Requestable is a generic procol that requires to you specify the request body, respose body, and error model.

Depending on what types you use to specialize the protocol, parts of the interface maybe already implemented for you. See the documentation on each protocol requirement for more information.

Generic Constraints

  • The body type to be sent with this request

    Declaration

    Swift

    associatedtype RequestBody
  • The body type to expect from the response

    Declaration

    Swift

    associatedtype ResponseBody
  • Error generated by a response

    Declaration

    Swift

    associatedtype ResponseError : Error

Typealiases

Requirements

  • The path to request

    Declaration

    Swift

    var path: String { get }
  • query Default implementation

    The URL query to request A default empty url query is implemented for you

    Default Implementation

    Declaration

    Swift

    var query: [URLQueryItem] { get }
  • The HTTP method to use

    Declaration

    Swift

    var method: RequestMethod { get }
  • The HTTP headers to send

    Declaration

    Swift

    var headers: RequestHeaders { get }
  • The body to append to the request

    Declaration

    Swift

    var body: RequestBody? { get }
  • authentication Default implementation

    Undocumented

    Default Implementation

    Undocumented

    Declaration

    Swift

    var authentication: RequestAuthentication? { get }
  • fallbackResponse Default implementation

    The response to use if the request fails A default fallback response of nil is implemented for you.

    Default Implementation

    Declaration

    Swift

    var fallbackResponse: Response? { get }
  • Encoder used to encode RequestBody into Data A default encoder is provided for you when RequestBody is one of the following:

    Declaration

    Swift

    var requestEncoder: BodyEncoder<RequestBody> { get }
  • Decoder used to decode Data into ResponseBody A default decoder is provided for you when ResponseBody is one of the following:

    Declaration

    Swift

    var responseDecoder: BodyDecoder<ResponseBody> { get }
  • responseValidator Default implementation

    Validator used to check a fully constructoed RequestResponse for errors A default validator is implemented for you that automatically accepts all response as valid and makes no manipulations

    Default Implementation

    Declaration

    Swift

    var responseValidator: ResponseValidator<ResponseBody, ResponseError> { get }
  • timeoutInterval Default implementation

    Interval before the RequestManager times out. A default timeout interval of 120 seconds is implemented for you

    Default Implementation

    Declaration

    Swift

    var timeoutInterval: TimeInterval { get }