Skip to content

Instantly share code, notes, and snippets.

@Gurpartap
Forked from ivangodfather/gist:9f3ad527198ee513308e
Last active September 15, 2015 07:48
Show Gist options
  • Save Gurpartap/ed302142f9afcac6ff49 to your computer and use it in GitHub Desktop.
Save Gurpartap/ed302142f9afcac6ff49 to your computer and use it in GitHub Desktop.
For @Godfather_ on IRC
request(.GET, CUSTOMER_URL, parameters: params, encoding: .URL).responseJSON { (request, response, result) -> Void in
if let message = JSON(result.value ?? "")["message"].string ?? "Default value to make it nonOptional" {
switch(result) {
case .Success(let json):
if let customer = JSON(json)["customer"].dictionaryObject {
GlobalCache.sharedInstance.setCustomer(customer)
}
completion(succeed: response?.statusCode == 200, message: message)
case .Failure(_,_):
completion(succeed: false, message: message)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment