Skip to content

Commit a2f61e6

Browse files
✨ add support for page count & mime type in (#263)
1 parent 5fedaef commit a2f61e6

File tree

7 files changed

+37
-14
lines changed

7 files changed

+37
-14
lines changed

src/main/java/com/mindee/parsing/v2/Inference.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public class Inference {
2727
* Model info.
2828
*/
2929
@JsonProperty("model")
30-
private InferenceResultModel model;
30+
private InferenceModel model;
3131

3232
/**
3333
* File info.
3434
*/
3535
@JsonProperty("file")
36-
private InferenceResultFile file;
36+
private InferenceFile file;
3737

3838
/**
3939
* Model result values.
@@ -51,9 +51,7 @@ public String toString() {
5151
.add("=====")
5252
.add(":ID: " + (model != null ? model.getId() : ""))
5353
.add("")
54-
.add("File")
55-
.add("====")
56-
.add(file != null ? file.toString() : "")
54+
.add(file.toString())
5755
.add("")
5856
.add(result != null ? result.toString() : "");
5957
return joiner.toString().trim() + "\n";

src/main/java/com/mindee/parsing/v2/InferenceResultFile.java renamed to src/main/java/com/mindee/parsing/v2/InferenceFile.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
44
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import java.util.StringJoiner;
56
import lombok.AllArgsConstructor;
67
import lombok.EqualsAndHashCode;
78
import lombok.Getter;
@@ -15,7 +16,7 @@
1516
@JsonIgnoreProperties(ignoreUnknown = true)
1617
@AllArgsConstructor
1718
@NoArgsConstructor
18-
public class InferenceResultFile {
19+
public class InferenceFile {
1920
/**
2021
* File name.
2122
*/
@@ -28,7 +29,29 @@ public class InferenceResultFile {
2829
@JsonProperty("alias")
2930
private String alias;
3031

32+
/**
33+
* Page Count.
34+
*/
35+
@JsonProperty("page_count")
36+
private int pageCount;
37+
38+
/**
39+
* Mime type, as read by the server.
40+
*/
41+
@JsonProperty("mime_type")
42+
private String mimeType;
43+
44+
3145
public String toString() {
32-
return ":Name: " + name + "\n:Alias:" + (alias != null ? " " + alias : "");
46+
47+
StringJoiner joiner = new StringJoiner("\n");
48+
joiner
49+
.add("File")
50+
.add("====")
51+
.add(":Name: " + name)
52+
.add(":Alias:" + (alias != null ? " " + alias : ""))
53+
.add(":Page Count: " + pageCount)
54+
.add(":MIME Type: " + mimeType);
55+
return joiner.toString();
3356
}
3457
}

src/main/java/com/mindee/parsing/v2/InferenceResultModel.java renamed to src/main/java/com/mindee/parsing/v2/InferenceModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@JsonIgnoreProperties(ignoreUnknown = true)
1616
@AllArgsConstructor
1717
@NoArgsConstructor
18-
public class InferenceResultModel {
18+
public class InferenceModel {
1919

2020
/**
2121
* The ID of the model.

src/main/java/com/mindee/parsing/v2/Job.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,5 @@ public final class Job {
8080
* Polling URL.
8181
*/
8282
@JsonProperty("webhooks")
83-
private List<JobResponseWebhook> webhooks;
83+
private List<JobWebhook> webhooks;
8484
}

src/main/java/com/mindee/parsing/v2/JobResponseWebhook.java renamed to src/main/java/com/mindee/parsing/v2/JobWebhook.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
import lombok.NoArgsConstructor;
1212

1313
/**
14-
* JobResponseWebhook info.
14+
* JobWebhook info.
1515
*/
1616
@Getter
1717
@EqualsAndHashCode
1818
@JsonIgnoreProperties(ignoreUnknown = true)
1919
@AllArgsConstructor
2020
@NoArgsConstructor
21-
public final class JobResponseWebhook {
21+
public final class JobWebhook {
2222

2323
/**
2424
* ID of the webhook.

src/test/java/com/mindee/parsing/v2/InferenceTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ void asyncPredict_whenComplete_mustExposeAllProperties() throws IOException {
9595
assertNotNull(inf, "Inference must not be null");
9696
assertEquals("12345678-1234-1234-1234-123456789abc", inf.getId(), "Inference ID mismatch");
9797

98-
InferenceResultModel model = inf.getModel();
98+
InferenceModel model = inf.getModel();
9999
assertNotNull(model, "Model must not be null");
100100
assertEquals("12345678-1234-1234-1234-123456789abc", model.getId(), "Model ID mismatch");
101101

102-
InferenceResultFile file = inf.getFile();
102+
InferenceFile file = inf.getFile();
103103
assertNotNull(file, "File must not be null");
104104
assertEquals("complete.jpg", file.getName(), "File name mismatch");
105+
assertEquals(1, file.getPageCount(), "Page count mismatch");
106+
assertEquals("image/jpeg", file.getMimeType(), "MIME type mismatch");
105107
assertNull(file.getAlias(), "File alias must be null for this payload");
106108

107109
InferenceFields fields = inf.getResult().getFields();

0 commit comments

Comments
 (0)