• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hyperwallet / java-sdk / 758

pending completion
758

Pull #118

travis-ci

web-flow
Merge 3d0155505 into 749a99397
Pull Request #118: Dev v3

359 of 359 new or added lines in 7 files covered. (100.0%)

4346 of 4449 relevant lines covered (97.68%)

63.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.06
/src/main/java/com/hyperwallet/clientsdk/util/HyperwalletMultipartUtils.java
1
package com.hyperwallet.clientsdk.util;
2

3
import com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument;
4
import net.minidev.json.JSONObject;
5
import org.apache.commons.lang3.StringUtils;
6

7
import java.io.IOException;
8
import java.nio.file.Path;
9
import java.nio.file.Paths;
10
import java.util.ArrayList;
11
import java.util.HashMap;
12
import java.util.List;
13
import java.util.Map;
14

15
public class HyperwalletMultipartUtils {
×
16

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

19
        JSONObject document = new JSONObject();
1✔
20
        Multipart multipartList = new Multipart();
1✔
21
        for (HyperwalletVerificationDocument uploadData : uploadList) {
1✔
22

23
            addDocumentValue(document, "type", uploadData.getType());
1✔
24
            addDocumentValue(document, "country", uploadData.getCountry());
1✔
25
            addDocumentValue(document, "category", uploadData.getCategory());
1✔
26
            addDocumentValue(document, "status", uploadData.getStatus());
1✔
27
            List<JSONObject> documents = new ArrayList<>();
1✔
28
            documents.add(document);
1✔
29
            JSONObject data = new JSONObject();
1✔
30
            data.put("documents", documents);
1✔
31
            Map<String, String> multiPartUploadData = new HashMap<>();
1✔
32
            multiPartUploadData.put("data", data.toString());
1✔
33

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

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

41
                Path path = Paths.get(entry.getValue());
2✔
42

43
                String fileName = path.getFileName().toString();
2✔
44
                String extension = "";
2✔
45
                int i = fileName.lastIndexOf('.');
2✔
46
                if (i >= 0) {
2✔
47
                    extension = fileName.substring(i + 1);
2✔
48
                }
49
                Map<String, String> entity = new HashMap<>();
2✔
50
                entity.put(entry.getKey(), entry.getValue());
2✔
51
                Multipart.MultipartData multipart1 = new Multipart.MultipartData("Content-Type: image/" + extension + MultipartRequest.CRLF,
2✔
52
                        "Content-Disposition: form-data; name=\"" +
53
                                entry.getKey() + "\"; filename=\"" +
2✔
54
                                fileName + "\" " + MultipartRequest.CRLF,
55
                        entity );
56
                multipartList.add(multipart1);
2✔
57
            }
2✔
58
        }
1✔
59

60
        return multipartList;
1✔
61
    }
62

63
    private static void addDocumentValue(JSONObject document, String field, String value) {
64
        if (!StringUtils.isEmpty(value)) {
4✔
65
            document.put(field, value);
3✔
66
        }
67
    }
4✔
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc