package retrofit2; import java.util.Objects; import okhttp3.Headers; import okhttp3.Protocol; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; import org.bouncycastle.asn1.x509.DisplayText; import retrofit2.OkHttpCall; /* loaded from: classes.dex */ public final class Response { private final T body; private final ResponseBody errorBody; private final okhttp3.Response rawResponse; public static Response success(T t) { return success(t, new Response.Builder().code(DisplayText.DISPLAY_TEXT_MAXIMUM_SIZE).message("OK").protocol(Protocol.HTTP_1_1).request(new Request.Builder().url("http://localhost/").build()).build()); } public static Response success(int i, T t) { if (i < 200 || i >= 300) { throw new IllegalArgumentException("code < 200 or >= 300: ".concat(String.valueOf(i))); } return success(t, new Response.Builder().code(i).message("Response.success()").protocol(Protocol.HTTP_1_1).request(new Request.Builder().url("http://localhost/").build()).build()); } public static Response success(T t, Headers headers) { Objects.requireNonNull(headers, "headers == null"); return success(t, new Response.Builder().code(DisplayText.DISPLAY_TEXT_MAXIMUM_SIZE).message("OK").protocol(Protocol.HTTP_1_1).headers(headers).request(new Request.Builder().url("http://localhost/").build()).build()); } public static Response success(T t, okhttp3.Response response) { Objects.requireNonNull(response, "rawResponse == null"); if (!response.isSuccessful()) { throw new IllegalArgumentException("rawResponse must be successful response"); } return new Response<>(response, t, null); } public static Response error(int i, ResponseBody responseBody) { Objects.requireNonNull(responseBody, "body == null"); if (i < 400) { throw new IllegalArgumentException("code < 400: ".concat(String.valueOf(i))); } return error(responseBody, new Response.Builder().body(new OkHttpCall.NoContentResponseBody(responseBody.contentType(), responseBody.contentLength())).code(i).message("Response.error()").protocol(Protocol.HTTP_1_1).request(new Request.Builder().url("http://localhost/").build()).build()); } public static Response error(ResponseBody responseBody, okhttp3.Response response) { Objects.requireNonNull(responseBody, "body == null"); Objects.requireNonNull(response, "rawResponse == null"); if (response.isSuccessful()) { throw new IllegalArgumentException("rawResponse should not be successful response"); } return new Response<>(response, null, responseBody); } private Response(okhttp3.Response response, T t, ResponseBody responseBody) { this.rawResponse = response; this.body = t; this.errorBody = responseBody; } public final int code() { return this.rawResponse.code(); } public final String message() { return this.rawResponse.message(); } public final Headers headers() { return this.rawResponse.headers(); } public final boolean isSuccessful() { return this.rawResponse.isSuccessful(); } public final String toString() { return this.rawResponse.toString(); } public final okhttp3.Response raw() { return this.rawResponse; } public final ResponseBody errorBody() { return this.errorBody; } public final T body() { return this.body; } }