From 5898b20326465411a7afc9d753b039291c8683af Mon Sep 17 00:00:00 2001 From: anastasizzz Date: Tue, 16 Jul 2024 16:37:57 +0300 Subject: [PATCH] #3 add mappers --- .../java/by/eapp/musicroom/data/Mappers.kt | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 android/app/src/main/java/by/eapp/musicroom/data/Mappers.kt diff --git a/android/app/src/main/java/by/eapp/musicroom/data/Mappers.kt b/android/app/src/main/java/by/eapp/musicroom/data/Mappers.kt new file mode 100644 index 0000000..3d258ae --- /dev/null +++ b/android/app/src/main/java/by/eapp/musicroom/data/Mappers.kt @@ -0,0 +1,43 @@ +package by.eapp.musicroom.data + +import by.eapp.musicroom.domain.model.LoginData +import by.eapp.musicroom.domain.model.RefreshToken +import by.eapp.musicroom.domain.model.RegistrationData +import by.eapp.musicroom.domain.model.SubmitData +import by.eapp.musicroom.domain.model.Tokens +import by.eapp.musicroom.network.model.LoginDataDto +import by.eapp.musicroom.network.model.RefreshTokenDto +import by.eapp.musicroom.network.model.RegistrationDataDto +import by.eapp.musicroom.network.model.SubmitDataDto +import by.eapp.musicroom.network.model.TokensDto + +//Registration +fun RegistrationData.toDto() = RegistrationDataDto( + email = email, + password = password, + nickname = nickname +) + +fun LoginData.toDto() = LoginDataDto( + email = email, + password = password +) + +fun SubmitData.toDto() = SubmitDataDto( + userId = userId, + code = code +) + +fun TokensDto.toDomain() = Tokens( + accessToken = accessToken, + refreshToken = refreshToken +) + +fun RefreshToken.toDto() = RefreshTokenDto( + refreshToken = token +) + + + + +