Created
December 28, 2016 22:50
-
-
Save canapio/1968ced4acf5dc1f82140f61ec36c630 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
protocol ResponseMapperProtocol { | |
associatedtype Item | |
static func process(obj: AnyObject?) throws -> Item | |
} | |
final class SignInResponseMapper: ResponseMapper<SignInItem>, ResponseMapperProtocol { | |
static func process(obj: AnyObject?) throws -> SignInItem { | |
return try process(obj, parse: { json in | |
let token = json["token"] as? String | |
let uniqueId = json["unique_id"] as? String | |
if let token = token, let uniqueId = uniqueId { | |
return SignInItem(token: token, uniqueId: uniqueId) | |
} | |
return nil | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment