NetworkHelperProtocol
public protocol NetworkHelperProtocol
Protocol defining methods for common, uncompressed network operations.
Implementations are a short-circuit for standard requests only; bodies are never compressed.
For gzip or otherwise customized requests, use NetworkClient with a RequestBuilder.
-
Just sends a GET request to the
NetworkClientDeclaration
Swift
func get(url: URLConvertible, etag: String?, additionalHeaders: [String: String]?, completion: @escaping (NetworkResult) -> Void) -> any DisposableParameters
urlthe
URLConvertibleinstance to build theURLto sendetagthe etag to be added in order to avoid fetching a cached resource
additionalHeadersoptional dictionary of additional headers to add to the request
completionthe block that is executed when the request is completed with the
NetworkResultReturn Value
the
Disposableto cancel the in flight operation. -
getJsonAsObject(url:Default implementationetag: additionalHeaders: completion: ) Sends a GET request to the
NetworkClientand tries to convert the result into a Codable model.Default Implementation
Sends a GET request to the
NetworkClientand tries to convert the result into a Codable model. Same as using thegetmethod with nil as theetagparameter.Declaration
Swift
func getJsonAsObject<T: Codable>(url: URLConvertible, etag: String?, additionalHeaders: [String: String]?, completion: @escaping (ObjectResult<T>) -> Void) -> any DisposableParameters
urlthe
URLConvertibleinstance to build theURLto sendetagthe etag to be added in order to avoid fetching a cached resource
additionalHeadersoptional dictionary of additional headers to add to the request
completionthe block that is executed when the request is completed with the
CodableResultReturn Value
the
Disposableto cancel the in flight operation. -
Sends a POST request to the
NetworkClientwith an uncompressed JSON body.The body is never gzipped. For gzip compression, build a
RequestBuilderwithgzip()and send it throughNetworkClient.Declaration
Swift
func post(url: URLConvertible, body: DataObject, additionalHeaders: [String: String]?, completion: @escaping (NetworkResult) -> Void) -> any DisposableParameters
urlthe
URLConvertibleinstance to build theURLto sendbodythe
DataObjectto be sent as uncompressed JSON dataadditionalHeadersoptional dictionary of additional headers to add to the request
completionthe block that is executed when the request is completed with the
NetworkResultReturn Value
the
Disposableto cancel the in flight operation. -
get(url:Extension methodadditionalHeaders: completion: ) Just sends a GET request to the
NetworkClientDeclaration
Swift
func get(url: URLConvertible, additionalHeaders: [String: String]? = nil, completion: @escaping (NetworkResult) -> Void) -> any DisposableParameters
urlthe
URLConvertibleinstance to build theURLto sendadditionalHeadersoptional dictionary of additional headers to add to the request
completionthe block that is executed when the request is completed with the
NetworkResultReturn Value
the
Disposableto cancel the in flight operation. -
getJsonAsDataObject(url:Extension methodetag: additionalHeaders: completion: ) Sends a GET request to the
NetworkClientand tries to convert the result the returned JSON into aDataObject.Declaration
Swift
func getJsonAsDataObject(url: URLConvertible, etag: String? = nil, additionalHeaders: [String: String]? = nil, completion: @escaping (ObjectResult<DataObject>) -> Void) -> any DisposableParameters
urlthe
URLConvertibleinstance to build theURLto sendetagthe etag to be added in order to avoid fetching a cached resource
additionalHeadersoptional dictionary of additional headers to add to the request
completionthe block that is executed when the request is completed with the
ObjectResultReturn Value
the
Disposableto cancel the in flight operation. -
post(url:Extension methodbody: completion: ) Sends a POST request to the
NetworkClientwith an uncompressed JSON body.The body is never gzipped. For gzip compression, build a
RequestBuilderwithgzip()and send it throughNetworkClient.Declaration
Swift
func post(url: URLConvertible, body: DataObject, completion: @escaping (NetworkResult) -> Void) -> any DisposableParameters
urlthe
URLConvertibleinstance to build theURLto sendbodythe
DataObjectto be sent as uncompressed JSON datacompletionthe block that is executed when the request is completed with the
NetworkResultReturn Value
the
Disposableto cancel the in flight operation.
View on GitHub