ResponseHandler

public enum ResponseHandler

Utility methods for common response handling

  • Make sure the response is successful (status code 2xx) and deserialize the response body into the appropriate type.

    Declaration

    Swift

    public static func `default`<T>(wrapping completion: @escaping Callback<T>) -> Callback<BoxResponse> where T : BoxModel

    Parameters

    completion

    The user-specified completion block to call with the resulting deserialized object

  • Make sure the response is successful (status code 2xx) and deserialize the response body into the appropriate type.

    Declaration

    Swift

    public static func `default`<T>(wrapping completion: @escaping Callback<T>) -> Callback<BoxResponse> where T : Decodable

    Parameters

    completion

    The user-specified completion block to call with the resulting deserialized object

  • Ensure the response was successful (status code 2xx) and transform to void result, for operations that do not return meaningful results — just success vs. failure.

    Declaration

    Swift

    public static func `default`(wrapping completion: @escaping Callback<Void>) -> Callback<BoxResponse>

    Parameters

    completion

    The user-specified completion block to call with the result

  • This will help the user unwrap a response object that comes back as a collection where the collection is only of size one. This will give the user an Entry Container containing the Box Model expected.

    Declaration

    Swift

    public static func unwrapCollection<T>(wrapping completion: @escaping Callback<T>) -> Callback<BoxResponse> where T : BoxModel

    Parameters

    completion

    The user-specified completion block to call with the result