Skip to content

Commit

Permalink
Merge pull request #5 from RoavaDev/roava
Browse files Browse the repository at this point in the history
add description to user
  • Loading branch information
StayBlue authored May 18, 2024
2 parents 04b4c68 + 7160880 commit d3728f7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/kotlin/dev/roava/json/user/UserData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ data class UserData(
@JsonProperty("displayName")
val displayName: String?,
@JsonProperty("userId")
val id: Long?
val id: Long?,
@JsonProperty("description")
val description: String?,
)
4 changes: 4 additions & 0 deletions src/main/kotlin/dev/roava/user/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ class User {
val displayName: String
val name: String
val id: Long
val description: String

internal constructor(userData: UserData) {
displayName = userData.displayName!!
name = userData.name!!
id = userData.id!!
description = userData.description ?: ""
}

/**
Expand Down Expand Up @@ -76,6 +78,7 @@ class User {
displayName = userData?.displayName!!
name = userData.name!!
id = userData.id!!
description = userData.description ?: ""
} catch(exception: Exception) {
throw RuntimeException("The provided user ID is invalid!")
}
Expand Down Expand Up @@ -109,6 +112,7 @@ class User {
displayName = userData?.displayName!!
name = userData.name!!
id = userData.id!!
description = userData.description ?:""
} catch(exception: Exception) {
throw RuntimeException("The provided username is invalid!")
}
Expand Down
5 changes: 5 additions & 0 deletions src/test/kotlin/dev/roava/user/UserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ internal class UserTest {

assertTrue(user.hasGamepass(13827472))
}

@Test
fun testDescription() {
assertEquals(testUser.description, "This is a test description")
}
}

0 comments on commit d3728f7

Please sign in to comment.