Skip to content

Instantly share code, notes, and snippets.

@hprobotic
Created November 2, 2016 11:05
Show Gist options
  • Save hprobotic/adf809e9a1a90ae6f48b6526a9504109 to your computer and use it in GitHub Desktop.
Save hprobotic/adf809e9a1a90ae6f48b6526a9504109 to your computer and use it in GitHub Desktop.
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