Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

PPPLMER-92206 fix for multipart upload #128

Merged
merged 1 commit into from
Jun 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.hyperwallet.clientsdk.util;

import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument;
import net.minidev.json.JSONObject;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand All @@ -19,25 +16,17 @@ public class HyperwalletMultipartUtils {

public static Multipart convert(List<HyperwalletVerificationDocument> uploadList) throws IOException {

JSONObject document = new JSONObject();
Multipart multipartList = new Multipart();
List<JSONObject> documents = new ArrayList<>();
for (HyperwalletVerificationDocument uploadData : uploadList) {

JSONObject document = new JSONObject();
addDocumentValue(document, "type", uploadData.getType());
addDocumentValue(document, "country", uploadData.getCountry());
addDocumentValue(document, "category", uploadData.getCategory());
addDocumentValue(document, "status", uploadData.getStatus());
List<JSONObject> documents = new ArrayList<>();
documents.add(document);
JSONObject data = new JSONObject();
data.put("documents", documents);
Map<String, String> multiPartUploadData = new HashMap<>();
multiPartUploadData.put("data", data.toString());

Multipart.MultipartData multipart = new Multipart.MultipartData("Content-Type: application/json" + MultipartRequest.CRLF,
"Content-Disposition: form-data; name=\"" + "data" + "\"" + MultipartRequest.CRLF,
multiPartUploadData);
multipartList.add(multipart);
documents.add(document);

for (Map.Entry<String, String> entry : uploadData.getUploadFiles().entrySet()) {

Expand All @@ -59,6 +48,15 @@ public static Multipart convert(List<HyperwalletVerificationDocument> uploadList
multipartList.add(multipart1);
}
}
JSONObject data = new JSONObject();
data.put("documents", documents);
Map<String, String> multiPartUploadData = new HashMap<>();
multiPartUploadData.put("data", data.toString());

Multipart.MultipartData multipart = new Multipart.MultipartData("Content-Type: application/json" + MultipartRequest.CRLF,
"Content-Disposition: form-data; name=\"" + "data" + "\"" + MultipartRequest.CRLF,
multiPartUploadData);
multipartList.add(multipart);

return multipartList;
}
Expand Down