Classes

The following classes are available globally.

  • An HTTPClient that uses Alamofire for sending requests.

    See more

    Declaration

    Swift

    public class AlamofireClient : HTTPClient
  • RestingClient is the core class of RestingKit. It allows sending requests and receiving their responses as promises through a high-level API.

    The RestingClient is configured with the following components:

    • baseUrl: The base URL of the server we want to connect. One client can only connect to a single base URL. Therefore, if you wish to use multiple APIs, you should use different clients for each of them.
    • decoder: The decoder to use for decoding responses.
    • requestConverter: The converter to use for converting RestingRequests to HTTPRequests.
    • interceptors: The interceptors to run for each request and response.
    • httpClient: The client responsible for sending the request and receiving its response.

    There are two function families within the class: perform(_:) and upload(_:), each with several overloads for convenience. Even though they do the same thing in the core, The way to achieve their goal is different. perform(_:) sends the request by loading the request body into memory, while upload(_:) streams the body from a file without loading it. upload(_:) also allows tracking upload progress. For most requests perform(_:) should be good enough, but for cases when the request body is expected to be large, upload(_:) should be preferred.

    The process within a RestingClient is the following:

    1. The request converter converts the RestingRequest into an HTTPRequest.
    2. The interceptors are run with the produced HTTPRequest in the order provided. At this point, one of the interceptors might decide to modify the request or stop the execution chain by returning a response or and error.
    3. If the interceptors doesn’t block the chain, the HTTPClient is called to perform the actual request.
    4. The response from HTTPClient is passed to the interceptors. At this point, an interceptor might decide to change the response or recover from an error.
    5. The response is then converted into an HTTPResponse by decoding the response body.

    Cases when request promises might fail:

    1. The encoding of the request has failed.
    2. The decoding of the response has faied.
    3. Networking errors.
    4. The response status was not 2xx.
    5. An interceptor decided to raise an error.
    See more

    Declaration

    Swift

    open class RestingClient
  • An interceptor that logs requests and responses, including errors if present.

    See more

    Declaration

    Swift

    open class RequestResponseLoggingInterceptor : RestingInterceptor
  • A default implementation of HeaderProvider supporting dynamic header provisioning.

    See more

    Declaration

    Swift

    public class RestingHeaderProvider : HeaderProvider
  • A default implementation of HeaderProvider supporting dynamic variable provisioning.

    See more

    Declaration

    Swift

    public class RestingPathVariableProvider : PathVariableProvider
  • Represents a high-level HTTP Request.

    See more

    Declaration

    Swift

    open class RestingRequest<RequestType, ResponseType>

    Parameters

    RequestType

    The type of the request parameters.

    ResponseType

    The type of response.

  • x A RequestConverter that supports:

    See more

    Declaration

    Swift

    public class RestingRequestConverter : RequestConverter
  • Represents a lower-level HTTP Response.

    See more

    Declaration

    Swift

    public class HTTPDataResponse
  • An error thrown when a response status code is not 2xx.

    See more

    Declaration

    Swift

    public class HTTPError : Error
  • Represents a higher-level HTTP Response.

    See more

    Declaration

    Swift

    public class HTTPResponse<BodyType> : HTTPResponseType
  • An object that encodes Encodable objects into MultipartFormData.

    See more

    Declaration

    Swift

    public class MultipartFormDataEncoder
  • An object that encodes Encodable objects into an array of URLQueryItem.

    See more

    Declaration

    Swift

    public class QueryParameterEncoder
  • Represents a file to be sent through a multipart/form-data request.

    Warning

    Even tough the class is Encodable, it is supposed to be encoded with MultipartFormDataEncoder. Encoding with a different encoder will result in an undefined result.
    See more

    Declaration

    Swift

    public class MultipartFile : Encodable
  • A wrapper around PromiseKit’s Promise class that supports progress callbacks.

    See more

    Declaration

    Swift

    public class ProgressablePromise<T> : AnyProgressablePromise