Skip to content

Commit

Permalink
Fix kotlin spotless check
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <alper_ozturk@proton.me>
  • Loading branch information
alperozturk96 authored and AndyScherzinger committed Feb 12, 2024
1 parent f4535f9 commit 7e4f691
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ class GetHoverCardRemoteOperation(private val userId: String) : OCSRemoteOperati
GetMethod(client.baseUri.toString() + DIRECT_ENDPOINT + userId + JSON_FORMAT, true)
val status = client.execute(getMethod)
if (status == HttpStatus.SC_OK) {
val serverResponse: ServerResponse<HoverCard>? = getServerResponse(
getMethod,
object : TypeToken<ServerResponse<HoverCard>>() {}
)
val serverResponse: ServerResponse<HoverCard>? =
getServerResponse(
getMethod,
object : TypeToken<ServerResponse<HoverCard>>() {}
)

val hoverCard: HoverCard? = serverResponse?.ocs?.data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ import org.apache.commons.httpclient.HttpMethodBase
abstract class OCSRemoteOperation<T> : RemoteOperation<T>() {
private val gson = Gson()

fun <T> getServerResponse(method: HttpMethodBase, type: TypeToken<T>): T? {
fun <T> getServerResponse(
method: HttpMethodBase,
type: TypeToken<T>
): T? {
val response = method.responseBodyAsString
val element = JsonParser.parseString(response).asJsonObject
return gson.fromJson(element, type.type)
}

fun <T> getServerResponse(method: OkHttpMethodBase, type: TypeToken<T>): T? {
fun <T> getServerResponse(
method: OkHttpMethodBase,
type: TypeToken<T>
): T? {
val response = method.getResponseBodyAsString()
val element = JsonParser.parseString(response).asJsonObject
return gson.fromJson(element, type.type)
Expand Down

0 comments on commit 7e4f691

Please sign in to comment.