001package com.box.sdkgen.networking.fetchresponse;
002
003import com.fasterxml.jackson.databind.JsonNode;
004import java.io.InputStream;
005import java.util.Map;
006
007/** Response of the fetch call */
008public class FetchResponse {
009
010  /** URL of the response */
011  public String url;
012
013  /** HTTP status code of the response */
014  public final int status;
015
016  /** Response body of the response */
017  public JsonNode data;
018
019  /** Streamed content of the response */
020  public InputStream content;
021
022  /** HTTP headers of the response */
023  public final Map<String, String> headers;
024
025  public FetchResponse(int status, Map<String, String> headers) {
026    this.status = status;
027    this.headers = headers;
028  }
029
030  protected FetchResponse(Builder builder) {
031    this.url = builder.url;
032    this.status = builder.status;
033    this.data = builder.data;
034    this.content = builder.content;
035    this.headers = builder.headers;
036  }
037
038  public String getUrl() {
039    return url;
040  }
041
042  public int getStatus() {
043    return status;
044  }
045
046  public JsonNode getData() {
047    return data;
048  }
049
050  public InputStream getContent() {
051    return content;
052  }
053
054  public Map<String, String> getHeaders() {
055    return headers;
056  }
057
058  public static class Builder {
059
060    protected String url;
061
062    protected final int status;
063
064    protected JsonNode data;
065
066    protected InputStream content;
067
068    protected final Map<String, String> headers;
069
070    public Builder(int status, Map<String, String> headers) {
071      this.status = status;
072      this.headers = headers;
073    }
074
075    public Builder url(String url) {
076      this.url = url;
077      return this;
078    }
079
080    public Builder data(JsonNode data) {
081      this.data = data;
082      return this;
083    }
084
085    public Builder content(InputStream content) {
086      this.content = content;
087      return this;
088    }
089
090    public FetchResponse build() {
091      return new FetchResponse(this);
092    }
093  }
094}