Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
n0900 committed Nov 14, 2024
1 parent ccee819 commit 44e8eb6
Showing 1 changed file with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,18 @@ class RequestParametersFromSerializer<T : RequestParameters>(
JwsSignedElementName in element.jsonObject -> run {
val parameters =
decoder.json.decodeFromJsonElement(parameterSerializer, element.jsonObject[ParametersElementName]!!)
val jwsSignedRaw = decoder.json.decodeFromJsonElement<String>(element.jsonObject[JwsSignedElementName]!!)
val jwsSignedFinal1 = JwsSigned.deserialize(jwsSignedRaw).getOrThrow()
val jws = JwsSigned<T>(
jwsSignedFinal1.header,
parameters,
jwsSignedFinal1.signature,
jwsSignedFinal1.plainSignatureInput
)
val jwsString = decoder.json.decodeFromJsonElement<String>(element.jsonObject[JwsSignedElementName]!!)
val jwsGeneric = JwsSigned.deserialize(jwsString).getOrThrow()
RequestParametersFrom.JwsSigned(
jws,
parameters,
JwsSigned<T>(jwsGeneric.header, parameters, jwsGeneric.signature, jwsGeneric.plainSignatureInput),
parameters
)
}

UriElementName in element.jsonObject ->
RequestParametersFrom.Uri(
decoder.json.decodeFromJsonElement(UrlSerializer, element.jsonObject[UriElementName]!!),
decoder.json.decodeFromJsonElement(parameterSerializer, element.jsonObject[ParametersElementName]!!)
)
UriElementName in element.jsonObject -> RequestParametersFrom.Uri(
decoder.json.decodeFromJsonElement(UrlSerializer, element.jsonObject[UriElementName]!!),
decoder.json.decodeFromJsonElement(parameterSerializer, element.jsonObject[ParametersElementName]!!)
)

else -> throw NotImplementedError("Unknown RequestParametersFrom subclass. Input: $element")
}
Expand Down

0 comments on commit 44e8eb6

Please sign in to comment.