// 
// Decompiled by Procyon v0.6.0
// 

package io.sentry.protocol;

import java.util.concurrent.ConcurrentHashMap;
import io.sentry.vendor.gson.stream.JsonToken;
import io.sentry.ObjectReader;
import io.sentry.JsonDeserializer;
import java.io.IOException;
import java.util.Iterator;
import io.sentry.ILogger;
import io.sentry.ObjectWriter;
import io.sentry.util.CollectionUtils;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
import io.sentry.JsonSerializable;
import io.sentry.JsonUnknown;

public final class Response implements JsonUnknown, JsonSerializable
{
    public static final String TYPE = "response";
    @Nullable
    private String cookies;
    @Nullable
    private Map<String, String> headers;
    @Nullable
    private Integer statusCode;
    @Nullable
    private Long bodySize;
    @Nullable
    private Object data;
    @Nullable
    private Map<String, Object> unknown;
    
    public Response() {
    }
    
    public Response(@NotNull final Response response) {
        this.cookies = response.cookies;
        this.headers = CollectionUtils.newConcurrentHashMap(response.headers);
        this.unknown = CollectionUtils.newConcurrentHashMap(response.unknown);
        this.statusCode = response.statusCode;
        this.bodySize = response.bodySize;
        this.data = response.data;
    }
    
    @Nullable
    public String getCookies() {
        return this.cookies;
    }
    
    public void setCookies(@Nullable final String cookies) {
        this.cookies = cookies;
    }
    
    @Nullable
    public Map<String, String> getHeaders() {
        return this.headers;
    }
    
    public void setHeaders(@Nullable final Map<String, String> headers) {
        this.headers = CollectionUtils.newConcurrentHashMap(headers);
    }
    
    @Nullable
    @Override
    public Map<String, Object> getUnknown() {
        return this.unknown;
    }
    
    @Override
    public void setUnknown(@Nullable final Map<String, Object> unknown) {
        this.unknown = unknown;
    }
    
    @Nullable
    public Integer getStatusCode() {
        return this.statusCode;
    }
    
    public void setStatusCode(@Nullable final Integer statusCode) {
        this.statusCode = statusCode;
    }
    
    @Nullable
    public Long getBodySize() {
        return this.bodySize;
    }
    
    public void setBodySize(@Nullable final Long bodySize) {
        this.bodySize = bodySize;
    }
    
    @Nullable
    public Object getData() {
        return this.data;
    }
    
    public void setData(@Nullable final Object data) {
        this.data = data;
    }
    
    @Override
    public void serialize(@NotNull final ObjectWriter writer, @NotNull final ILogger logger) throws IOException {
        writer.beginObject();
        if (this.cookies != null) {
            writer.name("cookies").value(this.cookies);
        }
        if (this.headers != null) {
            writer.name("headers").value(logger, this.headers);
        }
        if (this.statusCode != null) {
            writer.name("status_code").value(logger, this.statusCode);
        }
        if (this.bodySize != null) {
            writer.name("body_size").value(logger, this.bodySize);
        }
        if (this.data != null) {
            writer.name("data").value(logger, this.data);
        }
        if (this.unknown != null) {
            for (final String key : this.unknown.keySet()) {
                final Object value = this.unknown.get(key);
                writer.name(key);
                writer.value(logger, value);
            }
        }
        writer.endObject();
    }
    
    public static final class JsonKeys
    {
        public static final String COOKIES = "cookies";
        public static final String HEADERS = "headers";
        public static final String STATUS_CODE = "status_code";
        public static final String BODY_SIZE = "body_size";
        public static final String DATA = "data";
    }
    
    public static final class Deserializer implements JsonDeserializer<Response>
    {
        @NotNull
        @Override
        public Response deserialize(@NotNull final ObjectReader reader, @NotNull final ILogger logger) throws Exception {
            reader.beginObject();
            final Response response = new Response();
            Map<String, Object> unknown = null;
            while (reader.peek() == JsonToken.NAME) {
                final String nextName2;
                final String nextName = nextName2 = reader.nextName();
                switch (nextName2) {
                    case "cookies": {
                        response.cookies = reader.nextStringOrNull();
                        continue;
                    }
                    case "headers": {
                        final Map<String, String> deserializedHeaders = (Map<String, String>)reader.nextObjectOrNull();
                        if (deserializedHeaders != null) {
                            response.headers = CollectionUtils.newConcurrentHashMap(deserializedHeaders);
                            continue;
                        }
                        continue;
                    }
                    case "status_code": {
                        response.statusCode = reader.nextIntegerOrNull();
                        continue;
                    }
                    case "body_size": {
                        response.bodySize = reader.nextLongOrNull();
                        continue;
                    }
                    case "data": {
                        response.data = reader.nextObjectOrNull();
                        continue;
                    }
                    default: {
                        if (unknown == null) {
                            unknown = new ConcurrentHashMap<String, Object>();
                        }
                        reader.nextUnknown(logger, unknown, nextName);
                        continue;
                    }
                }
            }
            response.setUnknown(unknown);
            reader.endObject();
            return response;
        }
    }
}
