NetworkService
public class NetworkService
                Class responsible for sending all the networking requests, checking for http errors, RPC errors, Decoding the responses and optionally logging progress
- 
                  
                  
Errors that can be returned by the
See moreNetworkServiceDeclaration
Swift
public enum NetworkError : Error 
- 
                  
                  
The
URLSessionused to preform all the networking operationsDeclaration
Swift
public let urlSession: URLSession - 
                  
                  
The
URLSessionused to preform all the networking operationsDeclaration
Swift
public let loggingConfig: LoggingConfig 
- 
                  
                  
Init an
NetworkServicewith aURLSessionDeclaration
Swift
public init(urlSession: URLSession, loggingConfig: LoggingConfig)Parameters
urlSessionA
URLSessionobject 
- 
                  
                  
A generic send function that takes an RPC, with a generic type conforming to
Decodable, executes the request and returns the result.Declaration
Swift
public func send<T>(rpc: RPC<T>, withNodeURLs nodeURLs: [URL], retryCount: Int = 0, completion: @escaping ((Result<T, KukaiError>) -> Void)) where T : DecodableParameters
rpcA instance of
RPC.withNodeURLsAn array of nodeURLs from
TezosNodeConfig.retryCountAn Int denoting the current number of attempts made. 3 is max.
completionA completion callback that will be executed on the main thread.
Return Value
Void
 - 
                  
                  
A generic network request function that takes a URL, optional payload and a
Decodableresponse type. Function will execute the request and attempt to parse the response. Using the Logging config, will auto log (or not) urls, response outputs, or fails to the consoleDeclaration
Swift
public func request<T>(url: URL, isPOST: Bool, withBody body: Data?, forReturnType: T.Type, completion: @escaping ((Result<T, KukaiError>) -> Void)) where T : DecodableParameters
urlThe full url, including query parameters to execute.
isPOSTBool indicating if its a POST or GET request.
withBodyOptional Data to be passed as the body.
forReturnTypeThe Type to parse the response as.
completionA completion block with a
Result<T, Error>T being the supplied decoable type - 
                  
                  
A generic network request function that takes a URL, optional payload and a
Decodableresponse type. Function will execute the request and attempt to parse the response, returning it as a combine publisher. Using the Logging config, will auto log (or not) urls, response outputs, or fails to the consoleDeclaration
Swift
public func request<T>(url: URL, isPOST: Bool, withBody body: Data?, forReturnType: T.Type) -> AnyPublisher<T, KukaiError> where T : DecodableParameters
urlThe full url, including query parameters to execute.
isPOSTBool indicating if its a POST or GET request.
withBodyOptional Data to be passed as the body.
forReturnTypeThe Type to parse the response as.
Return Value
A publisher of the supplied return type, or error response
 - 
                  
                  
Send a HTTP DELETE to a given URL
Declaration
Swift
public func delete(url: URL, completion: @escaping ((Result<Bool, KukaiError>) -> Void)) - 
                  
                  
Send a HTTP DELETE to a given URL
Declaration
Swift
public func delete(url: URL) -> AnyPublisher<Bool, KukaiError> 
- 
                  
                  
Logging details of request failures using
os_logglobal loggingDeclaration
Swift
public static func logRequestFailed(loggingConfig: LoggingConfig?, isPost: Bool, fullURL: URL, payload: Data?, error: Error?, statusCode: Int?, responseData: Data?) - 
                  
                  
Logging details of successful requests using
os_logglobal loggingDeclaration
Swift
public static func logRequestSucceded(loggingConfig: LoggingConfig?, isPost: Bool, fullURL: URL, payload: Data?, responseData: Data?) - 
                  
                  
Logging details when a request starts using
os_logglobal loggingDeclaration
Swift
public static func logRequestStart(loggingConfig: LoggingConfig?, fullURL: URL) 
Install in Dash