Created
November 2, 2016 11:05
-
-
Save hprobotic/adf809e9a1a90ae6f48b6526a9504109 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func checkGuarantee() -> Promise<JSON> { | |
return Promise { fulfill, reject in | |
for index in 1...3 { | |
let typeOfId = index | |
let parameters = [ | |
"u": "solarbkgo", | |
"p": "c8453f377e716b46ca29b321a20767c4", | |
"type": typeOfId, | |
"code": "33252" | |
] as [String : Any] | |
Alamofire.request(SLBKAPIRouter.getGuarantee(parameters)) | |
.validate() | |
.responseJSON { response in | |
switch response.result { | |
case .success(_): | |
let results = JSON(response.result.value) | |
if results != JSON(404) { | |
fulfill(results) | |
break | |
} else { | |
fulfill(nil) | |
} | |
case .failure(let err): | |
print(err) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment