All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.castle.client.model.CastleResponse Maven / Gradle / Ivy

Go to download

Castle adds real-time monitoring of your authentication stack, instantly notifying you and your users on potential account hijacks.

There is a newer version: 2.4.3
Show newest version
package io.castle.client.model;

import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import io.castle.client.internal.utils.OkHttpExceptionUtil;
import okhttp3.Response;

import java.io.IOException;

public class CastleResponse {
    private final int code;
    private final JsonElement json;

    public CastleResponse(Response response) throws IOException {
        code = response.code();
        String body = response.body().string();
        JsonParser gson = new JsonParser();
        json = gson.parse(body);

        OkHttpExceptionUtil.handle(response);
    }

    public boolean isSuccessful() {
        return this.code >= 200 && this.code < 300;
    }

    public JsonElement json() {
        return json;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy