Skip to content

Commit 73f48e6

Browse files
Merge pull request #4 from aspose-email-cloud/develop
Develop
2 parents b7d5d3e + ab84686 commit 73f48e6

File tree

174 files changed

+8488
-501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+8488
-501
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ build
3535

3636
# BlueJ files
3737
*.ctxt
38+
.vscode

README.md

Lines changed: 213 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,220 @@
1-
Aspose.Email Cloud is a REST API for creating email applications that work with common email file formats. It lets developers manipulate message formats such as Outlook MSG, EML and MHT files.
1+
# Aspose.Email Cloud SDK for Java [![Maven](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Frepository.aspose.cloud%2Frepo%2Fcom%2Faspose%2Faspose-email-cloud%2Fmaven-metadata.xml)](https://repository.aspose.cloud/repo/com/aspose/aspose-email-cloud/) [![License](https://img.shields.io/github/license/aspose-email-cloud/aspose-email-cloud-java)](https://repository.aspose.cloud/repo/com/aspose/aspose-email-cloud/)
2+
This repository contains Aspose.Email Cloud SDK for Java source code. This SDK allows you to work with Aspose.Email Cloud REST APIs in your Java applications quickly and easily, with zero initial cost.
3+
4+
[Aspose.Email Cloud home](https://products.aspose.cloud/email/family "Aspose.Email Cloud")
5+
[API Reference](https://apireference.aspose.cloud/email/)
6+
7+
28

3-
To use these SDKs, you will need App SID and App Key which can be looked up at [Aspose Cloud Dashboard](https://dashboard.aspose.cloud/#/apps) (free registration in Aspose Cloud is required for this).
49

510
## How to use the SDK?
6-
The complete source code is available in the GIT repository.
11+
The complete source code is available in the GIT repository.
12+
13+
Use reference documentation, available [**here**](docs/README.md)
14+
15+
### Prerequisites
16+
To use these SDK, you need an App SID and an App Key; they can be looked up at [Aspose Cloud Dashboard](https://dashboard.aspose.cloud/#/apps) (it requires free registration in Aspose Cloud for this).
17+
18+
### Installation
19+
You can either directly use it in your project via jar file or add it as Maven dependency ([see repo](https://repository.aspose.cloud/repo/com/aspose/aspose-email-cloud/)):
20+
21+
First, you should add a repository:
22+
```xml
23+
<repository>
24+
<id>aspose-cloud</id>
25+
<name>Aspose.Cloud repository</name>
26+
<url>https://repository.aspose.cloud</url>
27+
</repository>
28+
```
29+
Then, add a dependency:
30+
```xml
31+
<dependency>
32+
<groupId>com.aspose</groupId>
33+
<artifactId>aspose-email-cloud</artifactId>
34+
</dependency>
35+
```
36+
37+
### Usage examples
38+
To use the API, you should create an EmailApi object:
39+
```java
40+
EmailApi api = new EmailApi("Your App Key", "Your App SID");
41+
```
42+
43+
#### Business cards recognition API
44+
See examples below:
45+
46+
<details open>
47+
<summary>Parse business card images to VCard contact files</summary>
48+
49+
```java
50+
// Upload business card image to storage
51+
String storage = "First Storage"; //Your storage name
52+
String fileName = "someFileName.png"; //Supports different image formats: PNG, JPEG, BMP, TIFF, GIF, etc.
53+
String folder = "some/folder/path/on/storage";
54+
String filePath = folder + "/" + fileName;
55+
byte[] fileBytes = IOUtils.toByteArray(
56+
new FileInputStream("some/business/card/image/on/disk.png"));
57+
api.uploadFile(new UploadFileRequestData(
58+
filePath,
59+
fileBytes,
60+
storage));
61+
String outFolderPath = "some/other/folder/path/on/storage"; //Business card recognition results will be saved here
62+
api.createFolder(new CreateFolderRequestData(outFolderPath, storage));
63+
// Call business card recognition action
64+
ListResponseOfStorageFileLocation result = api.aiBcrParseStorage(new AiBcrParseStorageRequestData(
65+
new AiBcrParseStorageRq(
66+
null,
67+
//We can process multiple images in one request
68+
Arrays.asList(new AiBcrImageStorageFile(
69+
true, //Flag isSingle determines that image contains single VCard or more.
70+
//Only single VCard on image variant is supported in current version.
71+
new StorageFileLocation(storage, folder, fileName))),
72+
new StorageFolderLocation(storage, outFolderPath))));
73+
// Get file name from recognition result
74+
StorageFileLocation contactFile = result.getValue().get(0); //result.getValue() can contain multiple files, if we sent multicard images or multiple images
75+
// You can download the VCard file, which produced by the recognition method ...
76+
byte[] contactBytes = api.downloadFile(new DownloadFileRequestData(
77+
contactFile.getFolderPath() + "/" + contactFile.getFileName(),
78+
contactFile.getStorage(),
79+
null));
80+
String contactFileContent = new String(contactBytes, StandardCharsets.UTF_8);
81+
//... and print it
82+
System.out.println(contactFileContent);
83+
// Also, you can get VCard object properties’ list using Contact API
84+
HierarchicalObject contactProperties = api.getContactProperties(
85+
new GetContactPropertiesRequestData(
86+
"VCard",
87+
contactFile.getFileName(),
88+
contactFile.getFolderPath(),
89+
contactFile.getStorage()));
90+
//All VCard’s properties are available as a list. Complex properties are represented as hierarchical structures.
91+
//Let's print all primitive properties’ values:
92+
for (BaseObject property: contactProperties.getInternalProperties()) {
93+
if (property.getType().equals("PrimitiveObject")) {
94+
PrimitiveObject primitive = (PrimitiveObject)property;
95+
System.out.println("Property name: " +
96+
primitive.getName() +
97+
" value: " +
98+
primitive.getValue());
99+
}
100+
}
101+
```
102+
</details>
103+
104+
105+
<details>
106+
<summary>Parse images directly, without the using of a storage</summary>
107+
108+
```java
109+
//Read image from file and convert it to Base64 string
110+
byte[] fileBytes = IOUtils.toByteArray(
111+
new FileInputStream("some/business/card/image/on/disk.png"));
112+
String fileBase64 = Base64.encodeToString(fileBytes, false);
113+
ListResponseOfHierarchicalObject result = api.aiBcrParse(new AiBcrParseRequestData(
114+
new AiBcrBase64Rq(null, Arrays.asList(new AiBcrBase64Image(true, fileBase64)))));
115+
//Result contains all recognized VCard objects (only the one in our case)
116+
HierarchicalObject contactProperties = result.getValue().get(0);
117+
//VCard object is available as a list of properties, without any external calls:
118+
for (BaseObject property: contactProperties.getInternalProperties()) {
119+
if (property.getType().equals("PrimitiveObject")) {
120+
PrimitiveObject primitive = (PrimitiveObject)property;
121+
System.out.println("Property name: " +
122+
primitive.getName() +
123+
" value: " +
124+
primitive.getValue());
125+
}
126+
}
127+
```
128+
</details>
129+
130+
131+
#### Name API
132+
See examples below:
133+
<details open>
134+
<summary>Detect a person's gender by name</summary>
135+
136+
```java
137+
ListResponseOfAiNameGenderHypothesis result = api
138+
.aiNameGenderize(new AiNameGenderizeRequestData("John Cane", null, null, null, null, null));
139+
// the result contains a list of hypothesis about a person's gender.
140+
// all hypothesis include score, so you can use the most scored version,
141+
// which will be the first in a list:
142+
System.out.println(result.getValue().get(0).getGender()); //prints "Male"
143+
```
144+
</details>
145+
146+
<details>
147+
<summary>Format person's name using defined format</summary>
148+
149+
```java
150+
AiNameFormatted result = api.aiNameFormat(
151+
new AiNameFormatRequestData("Mr. John Michael Cane", null, null, null, null, "%t%L%f%m", null));
152+
System.out.println(result.getName()) // prints "Mr. Cane J. M."
153+
```
154+
</details>
155+
156+
<details>
157+
<summary>Compare the names to find out if they belong to the same person or not</summary>
158+
159+
```java
160+
final String first = "John Michael Cane";
161+
final String second = "Cane J.";
162+
AiNameMatchResult result = api
163+
.aiNameMatch(new AiNameMatchRequestData(first, second, null, null, null, null, null));
164+
System.out.println(result.getSimilarity() >= 0.5); //prints "true", names look similar
165+
```
166+
</details>
167+
168+
<details>
169+
<summary>Expand a person's name into a list of possible alternatives</summary>
170+
171+
172+
```java
173+
String name = "Smith Bobby";
174+
AiNameWeightedVariants result = api
175+
.aiNameExpand(new AiNameExpandRequestData(name, null, null, null, null, null));
176+
for (AiNameWeighted weighted : result.getNames()) {
177+
System.out.println(weighted.getName()); //prints "Mr. Smith", "B. Smith", etc.
178+
}
179+
```
180+
</details>
181+
182+
<details>
183+
<summary>Get k most probable names for given starting characters</summary>
184+
185+
```java
186+
String prefix = "Dav";
187+
AiNameWeightedVariants result = api
188+
.aiNameComplete(new AiNameCompleteRequestData(prefix, null, null, null, null, null));
189+
for (AiNameWeighted weighted : result.getNames()) {
190+
System.out.println(prefix + weighted.getName()); //prints "David", "Dave", "Davis", etc.
191+
}
192+
```
193+
</details>
194+
195+
<details>
196+
<summary>Parse out a person's name from an email address.</summary>
7197

8-
### Install Aspose.Email for Cloud
9-
You can either directly use it in your project via jar file or add it as Maven dependency.
198+
```java
199+
String address = "john-cane@gmail.com";
200+
ListResponseOfAiNameExtracted result = api
201+
.aiNameParseEmailAddress(new AiNameParseEmailAddressRequestData(address, null, null, null, null, null));
202+
String givenName = null;
203+
String surname = null;
204+
for(AiNameExtracted extracted: result.getValue()) {
205+
for(AiNameExtractedComponent component: extracted.getName()) {
206+
if (component.getCategory().equals("GivenName")) {
207+
givenName = component.getValue();
208+
}
209+
if (component.getCategory().equals("Surname")) {
210+
surname = component.getValue();
211+
}
212+
}
213+
}
214+
System.out.println("Given name is " + givenName); // "John"
215+
System.out.println("Surname is " + surname); // "Cane"
216+
```
217+
</details>
10218

11219
# Licensing
12220
All Aspose.Email for Cloud SDKs, helper scripts and templates are licensed under [MIT License](LICENSE).

docs/AccountBaseRequest.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
## Properties
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
7-
**firstAccount** | **String** | |
8-
**secondAccount** | **String** | | [optional]
9-
**storageFolder** | [**StorageFolderLocation**](StorageFolderLocation.md) | | [optional]
7+
**firstAccount** | **String** | First account storage file name for receiving emails (or universal one) |
8+
**secondAccount** | **String** | Second account storage file name for sending emails (ignored if first is universal) | [optional]
9+
**storageFolder** | [**StorageFolderLocation**](StorageFolderLocation.md) | Storage folder location of account files | [optional]
1010

1111

1212
[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to API README]](README.md)

docs/AddAttachmentRequest.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
## Properties
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
7-
**documentFolder** | [**StorageFolderLocation**](StorageFolderLocation.md) | Storage folder location of document | [optional]
8-
**attachmentFolder** | [**StorageFolderLocation**](StorageFolderLocation.md) | Storage folder location of an attachment | [optional]
7+
**documentFolder** | [**StorageFolderLocation**](StorageFolderLocation.md) | Storage folder location of document | [optional]
8+
**attachmentFolder** | [**StorageFolderLocation**](StorageFolderLocation.md) | Storage folder location of an attachment | [optional]
99

1010

1111
[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to API README]](README.md)

docs/AiBcrBase64Image.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
# com.aspose.email.cloud.sdk.model.AiBcrBase64Image
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**base64Data** | **String** | Image data in base64 | [optional]
8+
9+
10+
[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to API README]](README.md)
11+

docs/AiBcrBase64Rq.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
# com.aspose.email.cloud.sdk.model.AiBcrBase64Rq
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**images** | [**List&lt;AiBcrBase64Image&gt;**](AiBcrBase64Image.md) | Images to recognize | [optional]
8+
9+
10+
[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to API README]](README.md)
11+

docs/AiBcrImage.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
# com.aspose.email.cloud.sdk.model.AiBcrImage
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**isSingle** | **Boolean** | Determines that image contains single VCard or more. Ignored in current version. Multiple cards on image support will be added soon |
8+
9+
10+
[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to API README]](README.md)
11+

docs/AiBcrImageStorageFile.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
# com.aspose.email.cloud.sdk.model.AiBcrImageStorageFile
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**file** | [**StorageFileLocation**](StorageFileLocation.md) | Image location | [optional]
8+
9+
10+
[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to API README]](README.md)
11+

docs/AiBcrOcrData.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
# com.aspose.email.cloud.sdk.model.AiBcrOcrData
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**id** | **String** | Image identifier | [optional]
8+
**image** | **String** | Image with possible pre-processing in Base64 | [optional]
9+
**details** | **Map&lt;String, String&gt;** | Additional details from OCR engine | [optional]
10+
**data** | [**List&lt;AiBcrOcrDataPart&gt;**](AiBcrOcrDataPart.md) | OCR results | [optional]
11+
12+
13+
[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to API README]](README.md)
14+

docs/AiBcrOcrDataPart.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
# com.aspose.email.cloud.sdk.model.AiBcrOcrDataPart
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**x** | **Double** | X position of text block |
8+
**y** | **Double** | Y position of text block |
9+
**width** | **Double** | Width of text block |
10+
**height** | **Double** | Height of text block |
11+
**text** | **String** | Recognized text | [optional]
12+
**details** | **Map&lt;String, String&gt;** | Additional recognition result details | [optional]
13+
14+
15+
[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to API README]](README.md)
16+

0 commit comments

Comments
 (0)