Skip to content

Commit ec8a3fd

Browse files
committed
📝 move HTTP client customizations to the guide
1 parent 303aa71 commit ec8a3fd

File tree

2 files changed

+47
-53
lines changed

2 files changed

+47
-53
lines changed

README.md

-51
Original file line numberDiff line numberDiff line change
@@ -79,57 +79,6 @@ Document<CustomV1Inference> customDocument = mindeeClient.parse(
7979
);
8080
```
8181

82-
Client supports multiple input types:
83-
84-
* java.io.File file
85-
* InputStream fileAsStream, String filename
86-
* byte[] fileAsByteArray, String filename
87-
* String fileAsBase64String, String filename
88-
89-
### HttpClient Customizations
90-
Mindee's API lives on the internet and many internal applications on corporate networks may therefore need to configure an HTTP proxy to access it. This is possble by using a `MindeeClient` configured to use a user provided instance of the `com.mindee.parsing.MindeeApi` interface. There are a few layers to this:
91-
92-
* The default implementation of `com.mindee.parsing.MindeeApi` interface is `com.mindee.http.MindeeHttpApi`
93-
* `MindeeHttpApi` can be initialized with an Apache HttpComponents `HttpClientBuilder`.
94-
* `HttpClientBuilder` can be configured for use cases like proxying requests, custom authentication schemes, setting SSL Context etc.
95-
96-
To Configure a `MindeeClient` to use a proxy, the following code can be referenced.
97-
```java
98-
import org.apache.http.HttpHost;
99-
import org.apache.http.impl.client.HttpClientBuilder;
100-
import org.apache.http.impl.client.HttpClients;
101-
import org.apache.http.impl.conn.DefaultProxyRoutePlanner;
102-
import com.mindee.parsing;
103-
import com.mindee.parsing.invoice;
104-
import com.mindee.MindeeClient;
105-
import com.mindee.MindeeClientInit;
106-
import com.mindee.DocumentToParse;
107-
import com.mindee.MindeeSettings;
108-
import com.mindee.http.MindeeHttpApi;
109-
import com.mindee.parsing.common.Document;
110-
import com.mindee.parsing.invoice.InvoiceV4Inference;
111-
112-
// you can also configure things like caching, custom HTTPS certs,
113-
// timeouts and connection pool sizes here.
114-
// See: https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.html
115-
HttpHost proxy = new HttpHost("<proxy-host>", <proxy-port>);
116-
DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
117-
HttpClientBuilder httpclientBuilder = HttpClients.custom().setRoutePlanner(routePlanner);
118-
119-
// Build MindeeHttpAPI using the HtppClientBuilder
120-
MindeeHttpApi mindeeHttpApi = MindeeHttpApi.builder()
121-
.mindeeSettings(new MindeeSettings("<my-api-key>"))
122-
.httpClientBuilder(httpclientBuilder)
123-
.build();
124-
125-
MindeeClient mindeeClient = MindeeClientInit.create(mindeeHttpApi);
126-
Document<InvoiceV4Inference> invoiceDocument = mindeeClient.parse(
127-
InvoiceV4Inference.class,
128-
documentToParse
129-
);
130-
131-
```
132-
13382
## Further Reading
13483
Complete details on the working of the library are available in the following guides:
13584

docs/java-getting-started.md

+47-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ and [installed](https://maven.apache.org/install.html)
1212

1313
### Maven
1414
The easiest way to use the Mindee client library for your project is by adding
15-
the maven dependency in your projects POM:
15+
the maven dependency in your project's POM:
1616

1717
```shell
1818
<dependencies>
@@ -25,7 +25,7 @@ the maven dependency in your projects POM:
2525
</dependency>
2626
<properties>
2727
...
28-
<mindee.sdk.version>1.0.0</mindee.sdk.version>
28+
<mindee.sdk.version>3.x.x</mindee.sdk.version>
2929
</properties>
3030
```
3131
For the latest version of the Library please refer to our [maven central repository](https://mvnrepository.com/artifact/com.mindee.sdk/mindee-api-java)
@@ -94,6 +94,51 @@ Then in your code:
9494
MindeeClient client = MindeeClientInit.create();
9595
```
9696

97+
### HttpClient Customizations
98+
Mindee's API lives on the internet and many internal applications on corporate networks may therefore need to configure an HTTP proxy to access it.
99+
This is possible by using a `MindeeClient` configured to use a user provided instance of the `com.mindee.parsing.MindeeApi` interface.
100+
101+
There are a few layers to this:
102+
* The default implementation of `com.mindee.parsing.MindeeApi` interface is `com.mindee.http.MindeeHttpApi`
103+
* `MindeeHttpApi` can be initialized with an Apache HttpComponents `HttpClientBuilder`.
104+
* `HttpClientBuilder` can be configured for use cases like proxying requests, custom authentication schemes, setting SSL Context etc.
105+
106+
To Configure a `MindeeClient` to use a proxy, the following code can be referenced.
107+
```java
108+
import org.apache.http.HttpHost;
109+
import org.apache.http.impl.client.HttpClientBuilder;
110+
import org.apache.http.impl.client.HttpClients;
111+
import org.apache.http.impl.conn.DefaultProxyRoutePlanner;
112+
import com.mindee.parsing;
113+
import com.mindee.parsing.invoice;
114+
import com.mindee.MindeeClient;
115+
import com.mindee.MindeeClientInit;
116+
import com.mindee.DocumentToParse;
117+
import com.mindee.MindeeSettings;
118+
import com.mindee.http.MindeeHttpApi;
119+
import com.mindee.parsing.common.Document;
120+
import com.mindee.parsing.invoice.InvoiceV4Inference;
121+
122+
// you can also configure things like caching, custom HTTPS certs,
123+
// timeouts and connection pool sizes here.
124+
// See: https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.html
125+
HttpHost proxy = new HttpHost("<proxy-host>", <proxy-port>);
126+
DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
127+
HttpClientBuilder httpclientBuilder = HttpClients.custom().setRoutePlanner(routePlanner);
128+
129+
// Build MindeeHttpAPI using the HtppClientBuilder
130+
MindeeHttpApi mindeeHttpApi = MindeeHttpApi.builder()
131+
.mindeeSettings(new MindeeSettings("<my-api-key>"))
132+
.httpClientBuilder(httpclientBuilder)
133+
.build();
134+
135+
MindeeClient mindeeClient = MindeeClientInit.create(mindeeHttpApi);
136+
Document<InvoiceV4Inference> invoiceDocument = mindeeClient.parse(
137+
InvoiceV4Inference.class,
138+
documentToParse
139+
);
140+
```
141+
97142
### Loading a Document File
98143
Before being able to send a document to the API, it must first be loaded.
99144

0 commit comments

Comments
 (0)