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);

    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;
  }
}

@@ -922,16 +922,134 @@
 .date);%0A
+    if (s3Headers.encryption != null) %7B%0A      headers.put(%22x-amz-server-side-encryption%22, s3Headers.encryption);%0A    %7D
 %0A    ret
@@ -1402,14 +1402,97 @@
 g date;%0A
+    @SerializedName(%22x-amz-server-side-encryption%22)%0A    private String encryption;%0A
   %7D%0A%7D%0A

Send S3 encryption header