Response
public final class Response : CustomDebugStringConvertible, Equatable
Represents a response to a MoyaProvider.request.
-
The status code of the response.
Declaration
Swift
public let statusCode: Int -
The response data.
Declaration
Swift
public let data: Data -
The original URLRequest for the response.
Declaration
Swift
public let request: URLRequest? -
The HTTPURLResponse object.
Declaration
Swift
public let response: HTTPURLResponse? -
Undocumented
Declaration
Swift
public init(statusCode: Int, data: Data, request: URLRequest? = nil, response: HTTPURLResponse? = nil) -
A text description of the
Response.Declaration
Swift
public var description: String { get } -
A text description of the
Response. Suitable for debugging.Declaration
Swift
public var debugDescription: String { get } -
Declaration
Swift
public static func == (lhs: Response, rhs: Response) -> Bool
-
Returns the
Responseif thestatusCodefalls within the specified range.Throws
MoyaError.statusCodewhen others are encountered.Declaration
Swift
func filter<R>(statusCodes: R) throws -> Response where R : RangeExpression, R.Bound == IntParameters
statusCodesThe range of acceptable status codes.
-
Returns the
Responseif it has the specifiedstatusCode.Throws
MoyaError.statusCodewhen others are encountered.Declaration
Swift
func filter(statusCode: Int) throws -> ResponseParameters
statusCodeThe acceptable status code.
-
Returns the
Responseif thestatusCodefalls within the range 200 - 299.Throws
MoyaError.statusCodewhen others are encountered.Declaration
Swift
func filterSuccessfulStatusCodes() throws -> Response -
Returns the
Responseif thestatusCodefalls within the range 200 - 399.Throws
MoyaError.statusCodewhen others are encountered.Declaration
Swift
func filterSuccessfulStatusAndRedirectCodes() throws -> Response -
Maps data received from the signal into an Image.
Declaration
Swift
func mapImage() throws -> Image -
Maps data received from the signal into a JSON object.
Declaration
Swift
func mapJSON(failsOnEmptyData: Bool = true) throws -> AnyParameters
failsOnEmptyDataA Boolean value determining whether the mapping should fail if the data is empty.
-
Maps data received from the signal into a String.
Declaration
Swift
func mapString(atKeyPath keyPath: String? = nil) throws -> StringParameters
atKeyPathOptional key path at which to parse string.
-
Maps data received from the signal into a Decodable object.
Declaration
Swift
func map<D>(_ type: D.Type, atKeyPath keyPath: String? = nil, using decoder: JSONDecoder = JSONDecoder(), failsOnEmptyData: Bool = true) throws -> D where D : DecodableParameters
atKeyPathOptional key path at which to parse object.
usingA
JSONDecoderinstance which is used to decode data to an object.
Response Class Reference