package com.filestack.internal.responses;

import com.google.gson.annotations.SerializedName;

import java.util.HashMap;
import java.util.Map;

/** Response object from multipart upload endpoint. */
public class UploadResponse {
  private String url;
  @SerializedName("location_url")
  private String locationUrl;
  @SerializedName("headers")
  private S3Headers s3Headers;

  public String getUrl() {
    return url;
  }

  public String getLocationUrl() {
    return locationUrl;
  }

  /**
   * Return {@link Map} of S3 headers.
   */
  public Map<String, String> getS3Headers() {
    HashMap<String, String> headers = new HashMap<>();
    headers.put("Authorization", s3Headers.auth);
    if (s3Headers.acl != null) {
      headers.put("x-amz-acl", s3Headers.acl);
    }
    headers.put("Content-MD5", s3Headers.md5);
    headers.put("x-amz-content-sha256", s3Headers.sha256);
    headers.put("x-amz-date", s3Headers.date);
    if (s3Headers.encryption != null) {
      headers.put("x-amz-server-side-encryption", s3Headers.encryption);
    }
    return headers;
  }

  private class S3Headers {
    @SerializedName("Authorization")
    private String auth;
    @SerializedName("x-amz-acl")
    private String acl;
    @SerializedName("Content-MD5")
    private String md5;
    @SerializedName("x-amz-content-sha256")
    private String sha256;
    @SerializedName("x-amz-date")
    private String date;
    @SerializedName("x-amz-server-side-encryption")
    private String encryption;
  }
}

@@ -36,16 +36,51 @@
 onses;%0A%0A
+import com.google.gson.JsonObject;%0A
 import c
@@ -382,25 +382,26 @@
 private 
-S3Headers
+JsonObject
  s3Heade
@@ -642,23 +642,19 @@
 String%3E 
-headers
+out
  = new H
@@ -673,854 +673,122 @@
     
-headers.put(%22Authorization%22, s3Headers.auth);%0A    if (s3Headers.acl != null) %7B%0A      headers.put(%22x-amz-acl%22, s3Headers.acl);%0A    %7D%0A    headers.put(%22Content-MD5%22, s3Headers.md5);%0A    headers.put(%22x-amz-content-sha256%22, s3Headers.sha256);%0A    headers.put(%22x-amz-date%22, s3Headers.date);%0A    if (s3Headers.encryption != null) %7B%0A      headers.put(%22x-amz-server-side-encryption%22, s3Headers.encryption);%0A    %7D%0A    return headers;%0A  %7D%0A%0A  private class S3Headers %7B%0A    @SerializedName(%22Authorization%22)%0A    private String auth;%0A    @SerializedName(%22x-amz-acl%22)%0A    private String acl;%0A    @SerializedName(%22Content-MD5%22)%0A    private String md5;%0A    @SerializedName(%22x-amz-content-sha256%22)%0A    private String sha256;%0A    @SerializedName(%22x-amz-date%22)%0A    private String date;%0A    @SerializedName(%22x-amz-server-side-encryption%22)%0A    private String encryption
+for (String key : s3Headers.keySet()) %7B%0A      out.put(key, s3Headers.get(key).getAsString());%0A    %7D%0A    return out
 ;%0A  

Replace S3Headers class with JsonObject