Skip to content

Instantly share code, notes, and snippets.

@canapio
Created December 28, 2016 22:50
Show Gist options
  • Save canapio/1968ced4acf5dc1f82140f61ec36c630 to your computer and use it in GitHub Desktop.
Save canapio/1968ced4acf5dc1f82140f61ec36c630 to your computer and use it in GitHub Desktop.
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