-
-
Save duraiganesh0/d4c1612e73c08548f234ab4ca132e48f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let employee : [String: AnyObject] = ["first_name": firstNameTextField.text! as AnyObject, "last_name": lastNameTextField.text! as AnyObject, "middle_name": middleNameTextField.text! as AnyObject, "email_id": emailTextField.text! as AnyObject, "encrypted_password": passwordTextField.text! as AnyObject] | |
let organization : [String: AnyObject] = ["org_name": orgNameTextField.text! as AnyObject, "location_id": (selectedCountry?.value)! as AnyObject, "address": orgAddressTextField.text! as AnyObject, "city": cityTextField.text! as AnyObject, "state": stateTextField.text! as AnyObject, "country": countryTextField.text! as AnyObject, "email": orgEmailTextField.text! as AnyObject] | |
let params : [String: [String: AnyObject]] = ["employee": employee as [String: AnyObject], "organisation": organization as [String: AnyObject]] | |
// this is the alamofire api call | |
Alamofire.request(signUpUrl, method: .post, parameters: params, encoding: URLEncoding.default, headers: nil).responseJSON { (responseData) -> Void in | |
print(responseData.response) | |
print(responseData.result.value) | |
switch responseData.result { | |
case .failure(let error): | |
print(error.localizedDescription) | |
case .success( _): | |
if((responseData.result.value) != nil) { | |
let swiftyJsonVar = JSON(responseData.result.value!) | |
print(swiftyJsonVar) | |
//self.showAndHideViews(view: 4) | |
} | |
} | |
} | |
// this is the urlDataTask api call | |
var jsonDict = [String: AnyObject]() | |
Utils.makeHTTPPostRequest(path: signUpUrl, body: params as [String : AnyObject], onCompletion: { JSON, error -> Void in | |
guard error == nil else { | |
DispatchQueue.main.async(execute: { | |
print("error") | |
}) | |
return | |
} | |
print(JSON) | |
if let dictJson = JSON.dictionaryObject { | |
jsonDict = dictJson as [String : AnyObject] | |
} | |
if let err = jsonDict["error"] { | |
DispatchQueue.main.async(execute: { | |
print("error") | |
}) | |
return | |
} else { | |
print("success") | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment