March 2020
Intermediate to advanced
392 pages
10h 10m
English
To return the user model is relatively simple: create a new instance of the output model and assign the values to it. Thanks to Swift's extensions, you can do it like this:
extension UserOutput { init(withUser user: User, accessToken: String, refreshToken: String) { self.userId = user.id self.email = user.email self.firstname = user.firstname self.lastname = user.lastname self.accessToken = accessToken self.refreshToken = refreshToken }}
To return the user, we now only have to call the following:
return UserOutput(withUser: user, ...)
We will complete these models in Chapter 7, Writing the User Service, when we write the User Manager Service.
Read now
Unlock full access