Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func apiCall2(anyBaseUrl: String = "", apiFunction: ApiName, method m: HTTPMethod = .get,
- parameters: [String: Any]? = nil, isJsonEncoding: Bool = false,
- completion: @escaping (Bool, Any?, Error?) -> Void) {
- var requestUrl = "(ActiveBaseURL())(apiFunction.rawValue)"
- if anyBaseUrl != "" {
- requestUrl = "(anyBaseUrl)(apiFunction.rawValue)"
- }
- var param = [String: Any]()
- if let p = parameters {
- param = p
- }
- Alamofire.request(requestUrl, method: m, parameters: param, encoding: isJsonEncoding ? JSONEncoding.default: URLEncoding.default)
- .authenticate(user: ApiUserName, password: ApiPassword)
- .responseJSON(options: .allowFragments) { response in
- print("request body: (response.request?.httpBody)")
- if response.result.isSuccess {
- }
- print(response.result.error?.localizedDescription)
- completion(false, nil, response.result.error)
- }
- }
- var parms: Parameters {
- return [
- "uid": "3592",
- "product": [
- ["id": 104,"type":"countryPlan", "qty": 1]
- ],
- "shipping": ["name":"Test", "mobile": "89464633", "address1": "testevhsd",
- "address2": "testfhd", "city": "test city", "state": "sel",
- "postal": "672673", "shipment_code": "YES", "country_id": "129"],
- "discount_code": "",
- "dt":"2018-11-15",
- "giftcard_code": "",
- "iccid": ""]
- }
- Service.shared.apiCall2(apiFunction: .CheckOut, method: .post, parameters: parms, isJsonEncoding: true) { (success, data, _) in
Add Comment
Please, Sign In to add comment