import GeneralUtils import Foundation import Alamofire extension NetWorkUtils { /** The JSONEncoding type creates a JSON representation of the parameters object, which is set as the HTTP body of the request. The Content-Type HTTP header field of an encoded request is set to application/json. import Alamofire let parameters: Parameters = [ "idWorker": getIDWork(), "signboard": signboard == 1, ] */ public static func excutePostTypeRawJSONEncoding(parameters: Parameters, url: String, isShowProgress: Bool? = nil, vc: UIViewController? = nil, responseStringParam: (@escaping (DataResponse) -> Void)) { NetWorkUtils.excutePost(parameters: parameters, url: url, isShowProgress: isShowProgress, vc: vc, encoding: JSONEncoding.default, responseStringParam: responseStringParam) } public static func excutePostTypeFormURLEncoded(parameters: Parameters, url: String, isShowProgress: Bool? = nil, vc: UIViewController? = nil, responseStringParam: @escaping (DataResponse) -> Void) { NetWorkUtils.excutePost(parameters: parameters, url: url, isShowProgress: isShowProgress, vc: vc, encoding: URLEncoding.default, responseStringParam: responseStringParam) } public static func excutePostTypePropertyListEncoding(parameters: Parameters, url: String, isShowProgress: Bool? = nil, vc: UIViewController? = nil, responseStringParam: @escaping (DataResponse) -> Void) { NetWorkUtils.excutePost(parameters: parameters, url: url, isShowProgress: isShowProgress, vc: vc, encoding: PropertyListEncoding.default, responseStringParam: responseStringParam) } public static func excutePost(parameters: Parameters, url: String, isShowProgress: Bool? = nil, vc: UIViewController? = nil, encoding: ParameterEncoding, responseStringParam: @escaping (DataResponse) -> Void) { if isShowProgress == true { vc?.showWaitOverlay(isBlockTouch: true) } println("excutePost: " + url) println(parameters) Alamofire.request(url, method: .post, parameters: parameters, encoding: encoding) .responseString { response in println(response.value) if isShowProgress == true { vc?.removeAllOverlays() } responseStringParam(response) } } }