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

hyperwallet / java-sdk / #654

01 May 2025 10:10PM CUT coverage: 97.037%. Remained the same
#654

push

grmeyer-hw-dev
Update changelog

5567 of 5737 relevant lines covered (97.04%)

67.05 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
        Multipart multipartList = new Multipart();
5✔
20
        List<JSONObject> documents = new ArrayList<>();
5✔
21
        for (HyperwalletVerificationDocument uploadData : uploadList) {
5✔
22

23
            JSONObject document = new JSONObject();
5✔
24
            addDocumentValue(document, "type", uploadData.getType());
5✔
25
            addDocumentValue(document, "country", uploadData.getCountry());
5✔
26
            addDocumentValue(document, "category", uploadData.getCategory());
5✔
27
            addDocumentValue(document, "status", uploadData.getStatus());
5✔
28

29
            documents.add(document);
5✔
30

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

33
                Path path = Paths.get(entry.getValue());
6✔
34

35
                String fileName = path.getFileName().toString();
6✔
36
                String extension = "";
6✔
37
                int i = fileName.lastIndexOf('.');
6✔
38
                if (i >= 0) {
6✔
39
                    extension = fileName.substring(i + 1);
6✔
40
                }
41
                Map<String, String> entity = new HashMap<>();
6✔
42
                entity.put(entry.getKey(), entry.getValue());
6✔
43
                Multipart.MultipartData multipart1 = new Multipart.MultipartData("Content-Type: image/" + extension + MultipartRequest.CRLF,
6✔
44
                        "Content-Disposition: form-data; name=\"" +
45
                                entry.getKey() + "\"; filename=\"" +
6✔
46
                                fileName + "\" " + MultipartRequest.CRLF,
47
                        entity );
48
                multipartList.add(multipart1);
6✔
49
            }
6✔
50
        }
5✔
51
        JSONObject data = new JSONObject();
5✔
52
        data.put("documents", documents);
5✔
53
        Map<String, String> multiPartUploadData = new HashMap<>();
5✔
54
        multiPartUploadData.put("data", data.toString());
5✔
55

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

61
        return multipartList;
5✔
62
    }
63

64
    private static void addDocumentValue(JSONObject document, String field, String value) {
65
        if (!StringUtils.isEmpty(value)) {
20✔
66
            document.put(field, value);
11✔
67
        }
68
    }
20✔
69
}
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