|
|
@@ -197,32 +197,49 @@ extension DataRequest {
|
|
|
on: queue)
|
|
|
}
|
|
|
|
|
|
+ @_disfavoredOverload
|
|
|
+ @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
|
|
|
+ @available(*, deprecated, message: "Renamed publishDecodable(type:queue:preprocessor:decoder:emptyResponseCodes:emptyRequestMethods).")
|
|
|
+ public func publishDecodable<T: Decodable>(type: T.Type = T.self,
|
|
|
+ queue: DispatchQueue = .main,
|
|
|
+ preprocessor: DataPreprocessor = DecodableResponseSerializer<T>.defaultDataPreprocessor,
|
|
|
+ decoder: DataDecoder = JSONDecoder(),
|
|
|
+ emptyResponseCodes: Set<Int> = DecodableResponseSerializer<T>.defaultEmptyResponseCodes,
|
|
|
+ emptyResponseMethods: Set<HTTPMethod> = DecodableResponseSerializer<T>.defaultEmptyRequestMethods) -> DataResponsePublisher<T> {
|
|
|
+ publishResponse(using: DecodableResponseSerializer(dataPreprocessor: preprocessor,
|
|
|
+ decoder: decoder,
|
|
|
+ emptyResponseCodes: emptyResponseCodes,
|
|
|
+ emptyRequestMethods: emptyResponseMethods),
|
|
|
+ on: queue)
|
|
|
+ }
|
|
|
+
|
|
|
/// Creates a `DataResponsePublisher` for this instance and uses a `DecodableResponseSerializer` to serialize the
|
|
|
/// response.
|
|
|
///
|
|
|
/// - Parameters:
|
|
|
- /// - type: `Decodable` type to which to decode response `Data`. Inferred from the context by default.
|
|
|
- /// - queue: `DispatchQueue` on which the `DataResponse` will be published. `.main` by default.
|
|
|
- /// - preprocessor: `DataPreprocessor` which filters the `Data` before serialization.
|
|
|
- /// `PassthroughPreprocessor()` by default.
|
|
|
- /// - decoder: `DataDecoder` instance used to decode response `Data`. `JSONDecoder()` by default.
|
|
|
- /// - emptyResponseCodes: `Set<Int>` of HTTP status codes for which empty responses are allowed. `[204, 205]` by
|
|
|
- /// default.
|
|
|
- /// - emptyResponseMethods: `Set<HTTPMethod>` of `HTTPMethod`s for which empty responses are allowed, regardless
|
|
|
- /// of status code. `[.head]` by default.
|
|
|
- ///
|
|
|
- /// - Returns: The `DataResponsePublisher`.
|
|
|
+ /// - type: `Decodable` type to which to decode response `Data`. Inferred from the context by
|
|
|
+ /// default.
|
|
|
+ /// - queue: `DispatchQueue` on which the `DataResponse` will be published. `.main` by default.
|
|
|
+ /// - preprocessor: `DataPreprocessor` which filters the `Data` before serialization.
|
|
|
+ /// `PassthroughPreprocessor()` by default.
|
|
|
+ /// - decoder: `DataDecoder` instance used to decode response `Data`. `JSONDecoder()` by default.
|
|
|
+ /// - emptyResponseCodes: `Set<Int>` of HTTP status codes for which empty responses are allowed. `[204, 205]` by
|
|
|
+ /// default.
|
|
|
+ /// - emptyRequestMethods: `Set<HTTPMethod>` of `HTTPMethod`s for which empty responses are allowed, regardless of
|
|
|
+ /// status code. `[.head]` by default.
|
|
|
+ ///
|
|
|
+ /// - Returns: The `DataResponsePublisher`.
|
|
|
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
|
|
|
public func publishDecodable<T: Decodable>(type: T.Type = T.self,
|
|
|
queue: DispatchQueue = .main,
|
|
|
preprocessor: DataPreprocessor = DecodableResponseSerializer<T>.defaultDataPreprocessor,
|
|
|
decoder: DataDecoder = JSONDecoder(),
|
|
|
emptyResponseCodes: Set<Int> = DecodableResponseSerializer<T>.defaultEmptyResponseCodes,
|
|
|
- emptyResponseMethods: Set<HTTPMethod> = DecodableResponseSerializer<T>.defaultEmptyRequestMethods) -> DataResponsePublisher<T> {
|
|
|
+ emptyRequestMethods: Set<HTTPMethod> = DecodableResponseSerializer<T>.defaultEmptyRequestMethods) -> DataResponsePublisher<T> {
|
|
|
publishResponse(using: DecodableResponseSerializer(dataPreprocessor: preprocessor,
|
|
|
decoder: decoder,
|
|
|
emptyResponseCodes: emptyResponseCodes,
|
|
|
- emptyRequestMethods: emptyResponseMethods),
|
|
|
+ emptyRequestMethods: emptyRequestMethods),
|
|
|
on: queue)
|
|
|
}
|
|
|
|
|
|
@@ -538,7 +555,7 @@ extension DownloadRequest {
|
|
|
on: queue)
|
|
|
}
|
|
|
|
|
|
- /// Creates a `DataResponsePublisher` for this instance and uses a `StringResponseSerializer` to serialize the
|
|
|
+ /// Creates a `DownloadResponsePublisher` for this instance and uses a `StringResponseSerializer` to serialize the
|
|
|
/// response.
|
|
|
///
|
|
|
/// - Parameters:
|
|
|
@@ -567,22 +584,9 @@ extension DownloadRequest {
|
|
|
on: queue)
|
|
|
}
|
|
|
|
|
|
- /// Creates a `DataResponsePublisher` for this instance and uses a `DecodableResponseSerializer` to serialize the
|
|
|
- /// response.
|
|
|
- ///
|
|
|
- /// - Parameters:
|
|
|
- /// - type: `Decodable` type to which to decode response `Data`. Inferred from the context by default.
|
|
|
- /// - queue: `DispatchQueue` on which the `DataResponse` will be published. `.main` by default.
|
|
|
- /// - preprocessor: `DataPreprocessor` which filters the `Data` before serialization.
|
|
|
- /// `PassthroughPreprocessor()` by default.
|
|
|
- /// - decoder: `DataDecoder` instance used to decode response `Data`. `JSONDecoder()` by default.
|
|
|
- /// - emptyResponseCodes: `Set<Int>` of HTTP status codes for which empty responses are allowed. `[204, 205]` by
|
|
|
- /// default.
|
|
|
- /// - emptyResponseMethods: `Set<HTTPMethod>` of `HTTPMethod`s for which empty responses are allowed, regardless
|
|
|
- /// of status code. `[.head]` by default.
|
|
|
- ///
|
|
|
- /// - Returns: The `DownloadResponsePublisher`.
|
|
|
+ @_disfavoredOverload
|
|
|
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
|
|
|
+ @available(*, deprecated, message: "Renamed publishDecodable(type:queue:preprocessor:decoder:emptyResponseCodes:emptyRequestMethods).")
|
|
|
public func publishDecodable<T: Decodable>(type: T.Type = T.self,
|
|
|
queue: DispatchQueue = .main,
|
|
|
preprocessor: DataPreprocessor = DecodableResponseSerializer<T>.defaultDataPreprocessor,
|
|
|
@@ -595,6 +599,35 @@ extension DownloadRequest {
|
|
|
emptyRequestMethods: emptyResponseMethods),
|
|
|
on: queue)
|
|
|
}
|
|
|
+
|
|
|
+ /// Creates a `DownloadResponsePublisher` for this instance and uses a `DecodableResponseSerializer` to serialize
|
|
|
+ /// the response.
|
|
|
+ ///
|
|
|
+ /// - Parameters:
|
|
|
+ /// - type: `Decodable` type to which to decode response `Data`. Inferred from the context by default.
|
|
|
+ /// - queue: `DispatchQueue` on which the `DataResponse` will be published. `.main` by default.
|
|
|
+ /// - preprocessor: `DataPreprocessor` which filters the `Data` before serialization.
|
|
|
+ /// `PassthroughPreprocessor()` by default.
|
|
|
+ /// - decoder: `DataDecoder` instance used to decode response `Data`. `JSONDecoder()` by default.
|
|
|
+ /// - emptyResponseCodes: `Set<Int>` of HTTP status codes for which empty responses are allowed. `[204, 205]` by
|
|
|
+ /// default.
|
|
|
+ /// - emptyRequestMethods: `Set<HTTPMethod>` of `HTTPMethod`s for which empty responses are allowed, regardless
|
|
|
+ /// of status code. `[.head]` by default.
|
|
|
+ ///
|
|
|
+ /// - Returns: The `DownloadResponsePublisher`.
|
|
|
+ @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
|
|
|
+ public func publishDecodable<T: Decodable>(type: T.Type = T.self,
|
|
|
+ queue: DispatchQueue = .main,
|
|
|
+ preprocessor: DataPreprocessor = DecodableResponseSerializer<T>.defaultDataPreprocessor,
|
|
|
+ decoder: DataDecoder = JSONDecoder(),
|
|
|
+ emptyResponseCodes: Set<Int> = DecodableResponseSerializer<T>.defaultEmptyResponseCodes,
|
|
|
+ emptyRequestMethods: Set<HTTPMethod> = DecodableResponseSerializer<T>.defaultEmptyRequestMethods) -> DownloadResponsePublisher<T> {
|
|
|
+ publishResponse(using: DecodableResponseSerializer(dataPreprocessor: preprocessor,
|
|
|
+ decoder: decoder,
|
|
|
+ emptyResponseCodes: emptyResponseCodes,
|
|
|
+ emptyRequestMethods: emptyRequestMethods),
|
|
|
+ on: queue)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
|