Derek Berner
05/15/2019, 4:19 PMfx {
val response = !effect {
call("$accountsHost/private/${accountId.value}/signup_notifications/${notificationId.value}") {
method = Get
headers.appendAll(this@AccountsGateway.headers)
}.response
}
Try<Unit> {
when (response.status) {
InternalServerError -> throw AccountsGatewayException("Failed to get info for notification_id ${notificationId.value} on account ${accountId.value}. ${response.status.description}")
Gone -> throw NotificationDeletedException()
}
}.fromTry { e -> e }.bind()
!effect {
try {
response.receive<SignupNotificationInfo>()
} catch(e: NoTransformationFoundException) {
throw AccountsGatewayException("The accounts service did not return valid json for notification_id ${notificationId.value} in account ${accountId.value}")
}
}
}.attempt()
into this? fx {
!effect {
val response = call("$accountsHost/private/${accountId.value}/signup_notifications/${notificationId.value}") {
method = Get
headers.appendAll(this@AccountsGateway.headers)
}.response
when (response.status) {
InternalServerError -> throw AccountsGatewayException("Failed to get info for notification_id ${notificationId.value} on account ${accountId.value}. ${response.status.description}")
Gone -> throw NotificationDeletedException()
}
try {
response.receive<SignupNotificationInfo>()
} catch(e: NoTransformationFoundException) {
throw AccountsGatewayException("The accounts service did not return valid json for notification_id ${notificationId.value} in account ${accountId.value}")
}
}
}.attempt()