MNNetworkUtils
open class MNNetworkUtils
Network Utils for v3.
-
Places a synchronous GET method request with the specified parameter
Declaration
Swift
public static func requestGetSync(url: String) -> Data?
Parameters
url
The url of the server
Return Value
Raw data, if any is found.
-
Places a synchronous POST method request with the specified parameter
Declaration
Swift
public static func requestPostSyncWithStatus(url: String, parameters: [String : Any]) -> (Data?, Int?)
Parameters
url
The url of the server
parameters
An optional dicionary of key-value pairs
Return Value
Raw data, if any is found.
-
Declaration
Swift
public static func requestPostSync(url: String, parameters: [String : Any]) -> Data?
-
Places an asynchronous POST method request with the specified parameters
Declaration
Swift
public static func requestPostAsync(url: String, parameters: [String : Any], progress: ((Int) -> ())? = nil, response: ((Data?) -> ())? = nil)
Parameters
url
The url of the server
parameters
An optional dicionary of key-value pairs
progress
A closure to process the progress of the data request operation
response
A completion hanlder to execute after the request finishes.
-
Declaration
Swift
public static func requestGetAsync(url: String, parameters: [String : Any]?, progress: ((Int) -> ())? = nil, response: ((Data?) -> ())? = nil)
-
Attempts to check the validity of a license by logging in to server
Declaration
Swift
public static func login(url: String, email: String, password: String) -> String?
Parameters
url
The url of the server
email
The email associated with the license.
password
The password associated withh the email
-
Attempts to check the property based on login
Declaration
Swift
public static func loginForProperty(url: String, email: String, password: String) -> String?
Parameters
url
The url of the server
email
The email associated with the license.
password
The password associated withh the email
-
Synchronusly retrieves a license with the specified parameters from server
Declaration
Swift
public static func getLicenceFromServerSync(url: String, licenceId: String, userName: String) -> String?
Parameters
url
The url of the server
licenseId
A string identifying the license
userName
The username associated with the license
-
Validate licence api
Declaration
Swift
public static func licenceValidationSync(url: String, file: MNLicenceFile) -> String?
Parameters
file
current licence file
Return Value
A server updated licence string. If validation failed, it will return nil.
-
Declaration
Swift
public static func checkForSuccess(statusCode: Int?) -> Bool
-
Declaration
Swift
public static func requestPostAsync<T:Decodable>(url: String, method: String = "POST", parameters: [String: Any], handler: ((T?, Error?, HTTPURLResponse?)->Void)?)
-
Declaration
Swift
public static func requestGetAsync(url: String, parameters: [String : Any], completed: ((Data?) -> ())? = nil)