generated from y9vad9/kotlin-project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
108 additions
and
106 deletions.
There are no files selected for viewing
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
11 changes: 6 additions & 5 deletions
11
grpc-engine/src/main/kotlin/io/timemates/api/grpc/mappers/UsersMapper.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
package io.timemates.api.grpc.mappers | ||
|
||
import io.timemates.api.users.types.UserOuterClass.User | ||
import io.timemates.api.users.types.UserOuterClass | ||
import io.timemates.sdk.common.constructor.createOrThrow | ||
import io.timemates.sdk.files.types.value.FileId | ||
import io.timemates.sdk.users.profile.types.Avatar | ||
import io.timemates.sdk.users.profile.types.value.EmailAddress | ||
import io.timemates.sdk.users.profile.types.value.UserDescription | ||
import io.timemates.sdk.users.profile.types.value.UserId | ||
import io.timemates.sdk.users.profile.types.value.UserName | ||
import io.timemates.sdk.users.profile.types.User as SdkUser | ||
|
||
internal class UsersMapper { | ||
fun grpcUserToSdkUser(user: User): SdkUser = with(user) { | ||
fun grpcUserToSdkUser(user: UserOuterClass.User): SdkUser = with(user) { | ||
return SdkUser( | ||
id = UserId.createOrThrow(id), | ||
name = UserName.createOrThrow(name), | ||
description = UserDescription.createOrThrow(description), | ||
avatarFileId = FileId.createOrThrow(avatarId), | ||
emailAddress = email?.takeIf { it.isNotEmpty() }?.let { EmailAddress.createOrThrow(it) } | ||
emailAddress = email?.takeIf { it.isNotEmpty() }?.let { EmailAddress.createOrThrow(it) }, | ||
avatar = gravatarId?.let { Avatar.GravatarId.createOrThrow(it) } ?: | ||
avatarId?.let { Avatar.FileId.createOrThrow(it) } | ||
) | ||
} | ||
} |
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
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
7 changes: 0 additions & 7 deletions
7
grpc-engine/src/main/proto/io/timemates/api/users/requests/SetGravatarRequest.proto
This file was deleted.
Oops, something went wrong.
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
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
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
11 changes: 0 additions & 11 deletions
11
...src/commonMain/kotlin/io/timemates/sdk/users/profile/requests/SetGravatarAvatarRequest.kt
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
sdk/src/commonMain/kotlin/io/timemates/sdk/users/profile/types/Avatar.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.timemates.sdk.users.profile.types | ||
|
||
import io.timemates.sdk.common.constructor.CreationFailure | ||
import io.timemates.sdk.common.constructor.Factory | ||
|
||
public sealed interface Avatar { | ||
@JvmInline | ||
public value class GravatarId private constructor(public val string: String) : Avatar { | ||
public companion object : Factory<GravatarId, String>() { | ||
override fun create(input: String): Result<GravatarId> { | ||
return when { | ||
input.isBlank() -> Result.failure(CreationFailure.ofBlank()) | ||
else -> Result.success(GravatarId(input)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@JvmInline | ||
public value class FileId private constructor(public val string: String) : Avatar { | ||
public companion object : Factory<FileId, String>() { | ||
override fun create(input: String): Result<FileId> { | ||
return when { | ||
input.isBlank() -> Result.failure(CreationFailure.ofBlank()) | ||
else -> Result.success(FileId(input)) | ||
} | ||
} | ||
} | ||
} | ||
} |
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