Skip to content

Commit 3deefaa

Browse files
committed
add utility calls
1 parent 5e93607 commit 3deefaa

File tree

13 files changed

+479
-11
lines changed

13 files changed

+479
-11
lines changed

.github/workflows/_test-code-samples.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ env:
1212
MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
1313
MINDEE_V2_SE_TESTS_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
1414
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
15+
MINDEE_V2_SE_TESTS_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
1516

1617
jobs:
1718
test_sample_code:

.github/workflows/_test-integrations.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ on:
44
workflow_call:
55
workflow_dispatch:
66

7+
env:
8+
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
9+
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}
10+
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
11+
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
12+
MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
13+
MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
14+
MINDEE_V2_SE_TESTS_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
15+
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
16+
MINDEE_V2_SE_TESTS_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
17+
718
jobs:
819
integration_tests:
920
name: Run Integration Tests
@@ -31,11 +42,5 @@ jobs:
3142
cache: "maven"
3243

3344
- name: Verify with Maven
34-
env:
35-
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
36-
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}
37-
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
38-
MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
39-
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
4045
run: |
4146
mvn clean test-compile failsafe:integration-test failsafe:verify
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import com.mindee.MindeeClientV2;
2+
import com.mindee.input.LocalInputSource;
3+
import com.mindee.v2.product.classification.ClassificationClassifier;
4+
import com.mindee.v2.product.classification.ClassificationResponse;
5+
import com.mindee.v2.product.classification.ClassificationResult
6+
import com.mindee.v2.product.classification.params.ClassificationParameters;
7+
import java.io.File;
8+
import java.io.IOException;
9+
10+
public class SimpleMindeeClientV2 {
11+
12+
public static void main(String[] args)
13+
throws IOException, InterruptedException
14+
{
15+
String apiKey = "MY_API_KEY";
16+
String filePath = "/path/to/the/file.ext";
17+
String modelId = "MY_MODEL_ID";
18+
19+
// Init a new client
20+
MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey);
21+
22+
// Set inference parameters
23+
// Note: modelId is mandatory.
24+
ClassificationParameters classificationParams = ClassificationParameters
25+
// ID of the model, required.
26+
.builder(modelId)
27+
.build();
28+
29+
// Load a file from disk
30+
LocalInputSource inputSource = new LocalInputSource(filePath);
31+
32+
// Send for processing
33+
ClassificationResponse response = mindeeClient.enqueueAndGetResult(
34+
ClassificationResponse.class,
35+
inputSource,
36+
classificationParams
37+
);
38+
39+
// Print a summary of the response
40+
System.out.println(response.getInference().toString());
41+
42+
// Access the classification result
43+
ClassificationResult result = response.getInference().getResult();
44+
ClassificationClassifier classification = result.getClassification();
45+
}
46+
}

docs/code_samples/v2_crop.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import com.mindee.MindeeClientV2;
2+
import com.mindee.input.LocalInputSource;
3+
import com.mindee.v2.product.crop.CropResponse;
4+
import com.mindee.v2.product.crop.params.CropParameters;
5+
import java.io.File;
6+
import java.io.IOException;
7+
8+
public class SimpleMindeeClientV2 {
9+
10+
public static void main(String[] args)
11+
throws IOException, InterruptedException
12+
{
13+
String apiKey = "MY_API_KEY";
14+
String filePath = "/path/to/the/file.ext";
15+
String modelId = "MY_MODEL_ID";
16+
17+
// Init a new client
18+
MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey);
19+
20+
// Set inference parameters
21+
// Note: modelId is mandatory.
22+
CropParameters cropParams = CropParameters
23+
// ID of the model, required.
24+
.builder(modelId)
25+
.build();
26+
27+
// Load a file from disk
28+
LocalInputSource inputSource = new LocalInputSource(filePath);
29+
30+
// Send for processing
31+
CropResponse response = mindeeClient.enqueueAndGetResult(
32+
CropResponse.class,
33+
inputSource,
34+
cropParams
35+
);
36+
37+
// Print a summary of the response
38+
System.out.println(response.getInference().toString());
39+
}
40+
}

docs/code_samples/v2_ocr.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import com.mindee.MindeeClientV2;
2+
import com.mindee.input.LocalInputSource;
3+
import com.mindee.v2.product.ocr.OcrResponse;
4+
import com.mindee.v2.product.ocr.params.OcrParameters;
5+
import java.io.File;
6+
import java.io.IOException;
7+
8+
public class SimpleMindeeClientV2 {
9+
10+
public static void main(String[] args)
11+
throws IOException, InterruptedException
12+
{
13+
String apiKey = "MY_API_KEY";
14+
String filePath = "/path/to/the/file.ext";
15+
String modelId = "MY_MODEL_ID";
16+
17+
// Init a new client
18+
MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey);
19+
20+
// Set inference parameters
21+
// Note: modelId is mandatory.
22+
OcrParameters ocrParams = OcrParameters
23+
// ID of the model, required.
24+
.builder(modelId)
25+
.build();
26+
27+
// Load a file from disk
28+
LocalInputSource inputSource = new LocalInputSource(filePath);
29+
30+
// Send for processing
31+
OcrResponse response = mindeeClient.enqueueAndGetResult(
32+
OcrResponse.class,
33+
inputSource,
34+
ocrParams
35+
);
36+
37+
// Print a summary of the response
38+
System.out.println(response.getInference().toString());
39+
}
40+
}

docs/code_samples/v2_split.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import com.mindee.MindeeClientV2;
2+
import com.mindee.input.LocalInputSource;
3+
import com.mindee.v2.product.split.SplitResponse;
4+
import com.mindee.v2.product.split.params.SplitParameters;
5+
import java.io.File;
6+
import java.io.IOException;
7+
8+
public class SimpleMindeeClientV2 {
9+
10+
public static void main(String[] args)
11+
throws IOException, InterruptedException
12+
{
13+
String apiKey = "MY_API_KEY";
14+
String filePath = "/path/to/the/file.ext";
15+
String modelId = "MY_MODEL_ID";
16+
17+
// Init a new client
18+
MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey);
19+
20+
// Set inference parameters
21+
// Note: modelId is mandatory.
22+
SplitParameters splitParams = SplitParameters
23+
// ID of the model, required.
24+
.builder(modelId)
25+
.build();
26+
27+
// Load a file from disk
28+
LocalInputSource inputSource = new LocalInputSource(filePath);
29+
30+
// Send for processing
31+
SplitResponse response = mindeeClient.enqueueAndGetResult(
32+
SplitResponse.class,
33+
inputSource,
34+
splitParams
35+
);
36+
37+
// Print a summary of the response
38+
System.out.println(response.getInference().toString());
39+
}
40+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.mindee.v2.product.classification.params;
2+
3+
import com.mindee.AsyncPollingOptions;
4+
import com.mindee.v2.clientOptions.BaseParameters;
5+
import com.mindee.v2.http.ProductInfo;
6+
7+
@ProductInfo(slug = "classification")
8+
public class ClassificationParameters extends BaseParameters {
9+
public ClassificationParameters(
10+
String modelId,
11+
String alias,
12+
String[] webhookIds,
13+
AsyncPollingOptions pollingOptions
14+
) {
15+
super(modelId, alias, webhookIds, pollingOptions);
16+
}
17+
18+
/**
19+
* Create a new builder.
20+
*
21+
* @param modelId the mandatory model identifier
22+
* @return a fresh {@link ClassificationParameters.Builder}
23+
*/
24+
public static Builder builder(String modelId) {
25+
return new Builder(modelId);
26+
}
27+
28+
public static final class Builder extends BaseParameters.BaseBuilder<Builder> {
29+
30+
Builder(String modelId) {
31+
super(modelId);
32+
}
33+
34+
/** Build an immutable {@link ClassificationParameters} instance. */
35+
public ClassificationParameters build() {
36+
return new ClassificationParameters(modelId, alias, webhookIds, pollingOptions);
37+
}
38+
}
39+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.mindee.v2.product.crop.params;
2+
3+
import com.mindee.AsyncPollingOptions;
4+
import com.mindee.v2.clientOptions.BaseParameters;
5+
import com.mindee.v2.http.ProductInfo;
6+
7+
@ProductInfo(slug = "crop")
8+
public class CropParameters extends BaseParameters {
9+
10+
public CropParameters(
11+
String modelId,
12+
String alias,
13+
String[] webhookIds,
14+
AsyncPollingOptions pollingOptions
15+
) {
16+
super(modelId, alias, webhookIds, pollingOptions);
17+
}
18+
19+
/**
20+
* Create a new builder.
21+
*
22+
* @param modelId the mandatory model identifier
23+
* @return a fresh {@link CropParameters.Builder}
24+
*/
25+
public static Builder builder(String modelId) {
26+
return new Builder(modelId);
27+
}
28+
29+
public static final class Builder extends BaseParameters.BaseBuilder<Builder> {
30+
31+
Builder(String modelId) {
32+
super(modelId);
33+
}
34+
35+
/** Build an immutable {@link CropParameters} instance. */
36+
public CropParameters build() {
37+
return new CropParameters(modelId, alias, webhookIds, pollingOptions);
38+
}
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.mindee.v2.product.ocr.params;
2+
3+
import com.mindee.AsyncPollingOptions;
4+
import com.mindee.v2.clientOptions.BaseParameters;
5+
import com.mindee.v2.http.ProductInfo;
6+
7+
@ProductInfo(slug = "ocr")
8+
public class OcrParameters extends BaseParameters {
9+
10+
public OcrParameters(
11+
String modelId,
12+
String alias,
13+
String[] webhookIds,
14+
AsyncPollingOptions pollingOptions
15+
) {
16+
super(modelId, alias, webhookIds, pollingOptions);
17+
}
18+
19+
/**
20+
* Create a new builder.
21+
*
22+
* @param modelId the mandatory model identifier
23+
* @return a fresh {@link OcrParameters.Builder}
24+
*/
25+
public static Builder builder(String modelId) {
26+
return new Builder(modelId);
27+
}
28+
29+
public static final class Builder extends BaseParameters.BaseBuilder<Builder> {
30+
31+
Builder(String modelId) {
32+
super(modelId);
33+
}
34+
35+
/** Build an immutable {@link OcrParameters} instance. */
36+
public OcrParameters build() {
37+
return new OcrParameters(modelId, alias, webhookIds, pollingOptions);
38+
}
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.mindee.v2.product.split.params;
2+
3+
import com.mindee.AsyncPollingOptions;
4+
import com.mindee.v2.clientOptions.BaseParameters;
5+
import com.mindee.v2.http.ProductInfo;
6+
7+
@ProductInfo(slug = "split")
8+
public class SplitParameters extends BaseParameters {
9+
10+
public SplitParameters(
11+
String modelId,
12+
String alias,
13+
String[] webhookIds,
14+
AsyncPollingOptions pollingOptions
15+
) {
16+
super(modelId, alias, webhookIds, pollingOptions);
17+
}
18+
19+
/**
20+
* Create a new builder.
21+
*
22+
* @param modelId the mandatory model identifier
23+
* @return a fresh {@link SplitParameters.Builder}
24+
*/
25+
public static Builder builder(String modelId) {
26+
return new Builder(modelId);
27+
}
28+
29+
public static final class Builder extends BaseParameters.BaseBuilder<Builder> {
30+
31+
Builder(String modelId) {
32+
super(modelId);
33+
}
34+
35+
/** Build an immutable {@link SplitParameters} instance. */
36+
public SplitParameters build() {
37+
return new SplitParameters(modelId, alias, webhookIds, pollingOptions);
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)