NetworkHelperProtocol
public protocol NetworkHelperProtocol
Protocol defining methods for common network operations.
-
Just sends a GET request to the
NetworkClientDeclaration
Swift
func get(url: URLConvertible, etag: String?, additionalHeaders: [String: String]?, completion: @escaping (NetworkResult) -> Void) -> 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) -> 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 a gzipped JSON body.Declaration
Swift
func post(url: URLConvertible, body: DataObject, additionalHeaders: [String: String]?, completion: @escaping (NetworkResult) -> Void) -> DisposableParameters
urlthe
URLConvertibleinstance to build theURLto sendbodythe
DataObjectto be sent as a gzipped 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) -> 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) -> 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 a gzipped JSON body.Declaration
Swift
func post(url: URLConvertible, body: DataObject, completion: @escaping (NetworkResult) -> Void) -> DisposableParameters
urlthe
URLConvertibleinstance to build theURLto sendbodythe
DataObjectto be sent as a gzipped 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