Created
April 5, 2022 06:14
-
-
Save supermanue/0e2715095355ef9622ccf2ead511df1a to your computer and use it in GitHub Desktop.
User in adapter layer
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
import zio.experiment.domain.model.AppError | |
import zio.experiment.domain.model.User.{ User => UserDomain } | |
case class User(id: Int, name: String) | |
object User { | |
implicit class UserConversions(user: User) { | |
def toDomainUser: Either[AppError, UserDomain] = | |
UserDomain.build(user.id, user.name) | |
} | |
def fromDomainUser(domainUser: UserDomain): User = | |
User(domainUser.id.value, domainUser.name.value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment