Created
February 8, 2018 10:08
-
-
Save harshvishu/366b2dbf6aadd8faa4e6c82ca8123165 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
struct User: ResponseObjectSerializable, ResponseCollectionSerializable, CustomStringConvertible { | |
let username: String | |
let name: String | |
var description: String { | |
return "User: { username: \(username), name: \(name) }" | |
} | |
init?(response: HTTPURLResponse, representation: Any) { | |
guard | |
let username = response.url?.lastPathComponent, | |
let representation = representation as? [String: Any], | |
let name = representation["name"] as? String | |
else { return nil } | |
self.username = username | |
self.name = name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment