Skip to content

Commit

Permalink
release: 0.1.8 (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb authored May 11, 2024
2 parents 454540b + 0043275 commit d30847e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.gitanimals.coupon.controller.response

import org.gitanimals.coupon.domain.Coupon
import java.time.LocalDateTime
import java.time.ZoneOffset

data class CouponResponse(
val id: String,
Expand All @@ -16,7 +17,7 @@ data class CouponResponse(
id = coupon.id.toString(),
userId = coupon.userId.toString(),
code = coupon.code,
usedAt = LocalDateTime.from(coupon.usedAt),
usedAt = LocalDateTime.ofInstant(coupon.usedAt, ZoneOffset.UTC),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ class RestIdentityApi : IdentityApi {
.uri("/users")
.header(HttpHeaders.AUTHORIZATION, token)
.exchange { _, response ->
response.bodyTo(UserResponse::class.java)
?: throw IllegalArgumentException("Authorization failed")
runCatching {
response.bodyTo(UserResponse::class.java)
}.getOrElse {
throw IllegalArgumentException("Authorization failed", it)
}
}
}
}
13 changes: 10 additions & 3 deletions src/main/kotlin/org/gitanimals/gotcha/infra/RestRenderApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ class RestRenderApi(
)
.exchange { _, response ->
if (response.statusCode.is2xxSuccessful) {
return@exchange response.bodyTo(object :
ParameterizedTypeReference<Map<String, String>>() {})?.get("id")
?: throw IllegalStateException("Create persona success but, cannot get persona-id")
return@exchange runCatching {
response.bodyTo(object :
ParameterizedTypeReference<Map<String, String>>() {})?.get("id")
}.getOrElse {
throw IllegalStateException(
"Create persona success but, cannot get persona-id", it
)
} ?: throw IllegalStateException(
"Create persona success but, cannot get persona-id cause it's null"
)
}
throw IllegalArgumentException("Cannot add persona name \"$personaName\" to user")
}
Expand Down
7 changes: 5 additions & 2 deletions src/main/kotlin/org/gitanimals/gotcha/infra/RestUserApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ class RestUserApi(
.uri("/users")
.header(HttpHeaders.AUTHORIZATION, token)
.exchange { _, response ->
response.bodyTo(UserResponse::class.java)
?: throw IllegalArgumentException("Authorization failed")
runCatching {
response.bodyTo(UserResponse::class.java)
}.getOrElse {
throw IllegalArgumentException("Authorization failed", it)
}
}
}

Expand Down

0 comments on commit d30847e

Please sign in to comment.