Skip to content

Commit 65e8c7e

Browse files
Merge pull request #11 from aspose-email-cloud/develop
Develop
2 parents 85f8513 + db2e08b commit 65e8c7e

File tree

176 files changed

+20090
-833
lines changed

Some content is hidden

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

176 files changed

+20090
-833
lines changed

.github/workflows/pythonapp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
appKey: ${{secrets.appKey}}
2525
apiBaseUrl: "https://api-qa.aspose.cloud"
2626
run: |
27-
python -m pytest -m pipeline tests
27+
python -m pytest --verbose --color=yes -m pipeline tests

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ nosetests.xml
4444
coverage.xml
4545
*,cover
4646
.hypothesis/
47-
venv/
4847
.python-version
4948

5049
# Translations
@@ -69,4 +68,5 @@ target/
6968
#PyCharm
7069
.idea/
7170
.vscode/
72-
.pytest_cache/
71+
.pytest_cache/
72+
.venv/

README.md

Lines changed: 42 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,49 @@
1-
# Aspose.Email Cloud SDK for Python [![PYPI](https://img.shields.io/pypi/v/aspose-email-cloud)](https://pypi.org/project/aspose-email-cloud/) [![License](https://img.shields.io/github/license/aspose-email-cloud/aspose-email-cloud-python)](https://pypi.org/project/aspose-email-cloud/) ![tests](https://github.com/aspose-email-cloud/aspose-email-cloud-python/workflows/tests/badge.svg)
1+
# Aspose.Email Cloud SDK for Python
2+
[![PYPI](https://img.shields.io/pypi/v/aspose-email-cloud)](https://pypi.org/project/aspose-email-cloud/) [![License](https://img.shields.io/github/license/aspose-email-cloud/aspose-email-cloud-python)](https://pypi.org/project/aspose-email-cloud/) ![tests](https://github.com/aspose-email-cloud/aspose-email-cloud-python/workflows/tests/badge.svg)
3+
24
This repository contains Aspose.Email Cloud SDK for Python source code. This SDK allows you to work with Aspose.Email Cloud REST APIs in your Python applications quickly and easily, with zero initial cost.
35

46
[Aspose.Email Cloud home](https://products.aspose.cloud/email/family "Aspose.Email Cloud")
57
[API Reference](https://apireference.aspose.cloud/email/)
68

79
# Key features
8-
910
Aspose.Email Cloud is a REST API for creating email applications that work with standard email file formats. This SDK:
1011
- Lets developers manipulate different emails’ formats such as Outlook MSG, EML, VCard, and iCalendar files
11-
- Has a built-in email client
12-
- Supports AI functionalities:
12+
- Lets developers manipulate different emails' formats such as Outlook MSG, EML, VCard, and iCalendar files
13+
- Supports AI functions:
1314
- The Business card recognition
1415
- The Name API for parsing and handling personal names
16+
- Has a built-in email client. This client provides:
17+
- Unified REST API for different email protocols: IMAP, POP3, SMTP, EWS, WebDav
18+
- Virtual multi-account
19+
- Message threads (POP3 accounts are also supported)
20+
- Email configuration discovery
21+
- Disposable email address detection
22+
23+
## New features in version 20.7
24+
- New MAPI message files API with models:
25+
- `MapiMessageDto` - represents the Microsoft Outlook message.
26+
- `MapiCalendarDto` - represents the Microsoft Outlook calendar object.
27+
- `MapiContactDto` - represents the Microsoft Outlook contact information.
28+
- Improved Recurrence pattern support for CalendarDto.
29+
30+
See [Release notes](https://docs.aspose.cloud/display/emailcloud/Aspose.Email+Cloud+20.7+Release+Notes)
1531

1632
## How to use the SDK?
1733
The complete source code is available in the GIT repository.
18-
Use [SDK tutorials](https://docs.aspose.cloud/display/emailcloud/SDK+Tutorials), [reference documentation](https://github.com/aspose-email-cloud/aspose-email-cloud-python/blob/master/sdk/docs/README.md) and [examples from this document](#usage-examples)
34+
35+
Use [SDK tutorials](https://docs.aspose.cloud/display/emailcloud/SDK+Tutorials):
36+
- [SDK setup](https://docs.aspose.cloud/display/emailcloud/SDK+setup) - installation, account setup, first API calls
37+
- [Business Cards Recognition API](https://docs.aspose.cloud/display/emailcloud/Business+Cards+Recognition+API) - convert captured business cards and name card images, into a vCard format
38+
- [Working with Name API](https://docs.aspose.cloud/display/emailcloud/Working+with+Name+API) - format, genderize, compare, parse, autocomplete names
39+
- [Email Message Files](https://docs.aspose.cloud/display/emailcloud/Email+Message+Files) - Convert EML to MSG and back, edit EML files, etc.
40+
- [Quick Start With iCalendar API](https://docs.aspose.cloud/display/emailcloud/Quick+Start+With+iCalendar+API) - Crate and edit iCalendar files
41+
- [Quick Start With VCard API](https://docs.aspose.cloud/display/emailcloud/Quick+Start+With+VCard+API) - Create and edit VCard files, business card recognition
42+
- [Quick Start With Email Client](https://docs.aspose.cloud/display/emailcloud/Quick+Start+With+Email+Client) - Setup builtin email client, search/fetch/send/move/delete messages
43+
- [Email Client Threads](https://docs.aspose.cloud/display/emailcloud/Email+Client+Threads) - Fetch/Move/Delete email message threads using builtin email client
44+
- [File converters](https://docs.aspose.cloud/display/emailcloud/Convert+Email%2C+Calendar+and+Contact+Files)
45+
46+
SDK reference documentation is available in [this README](sdk/docs/README.md)
1947

2048
### Prerequisites
2149

@@ -27,6 +55,7 @@ You can use it directly in your project via the source code or get a [PYPI Packa
2755

2856
pip install aspose-email-cloud
2957

58+
See more details about SDK installation in this tutorial: [SDK setup](https://docs.aspose.cloud/display/emailcloud/SDK+setup)
3059

3160
### Usage examples
3261

@@ -42,178 +71,18 @@ app_key = 'Your App Key'
4271
email_api = api.EmailApi(app_key, app_sid)
4372
```
4473

45-
API calls can be synchronous or asynchronous (using ThreadPool from multiprocessing.pool):
46-
```python
47-
result = email_api.get_calendar(
48-
requests.GetCalendarRequest(
49-
calendar_file,
50-
folder,
51-
storage))
52-
# or
53-
async_result = email_api.get_calendar_async( #returns multiprocessing.pool.AsyncResult
54-
requests.GetCalendarRequest(
55-
calendar_file,
56-
folder,
57-
storage))
58-
result = async_result.get()
59-
```
60-
6174
#### Business cards recognition API
62-
See examples below:
63-
64-
<details open>
65-
<summary>Parse business card images to VCard contact files</summary>
66-
75+
Use `AiBcrParseModel` method to parse business card image to VCard DTO:
6776
```python
68-
storage = 'First Storage' # Your storage name
69-
file_name = 'some_file_name.png' #Supports different image formats: PNG, JPEG, BMP, TIFF, GIF, etc.
70-
image_file = 'some/business/card/image/file/on/disk.png'
71-
folder = 'some/folder/path/on/storage'
72-
# Upload business card image to storage
73-
storage_location = folder + '/' + file_name
74-
email_api.upload_file(
75-
requests.UploadFileRequest(storage_location, image_file, storage))
76-
77-
out_folder_path = 'some/other/folder/path/on/storage' # Business card recognition results will be saved here
78-
email_api.create_folder(requests.CreateFolderRequest(out_folder_path, storage))
79-
# Call business card recognition action
80-
result = email_api.ai_bcr_parse_storage(requests.AiBcrParseStorageRequest(
81-
models.AiBcrParseStorageRq(
82-
images=[
83-
models.AiBcrImageStorageFile(
84-
True, #Flag isSingle determines that image contains single VCard or more.
85-
#Only single VCard on image variant is supported in current version.
86-
models.StorageFileLocation(storage, folder, file_name))],
87-
out_folder=models.StorageFolderLocation(storage, out_folder_path))))
88-
# Get file name from recognition result
89-
contact_file = result.value[0] # result.value can contain multiple files, if we sent multicard images or multiple images
90-
# You can download the VCard file, which produced by the recognition method ...
91-
downloaded = email_api.download_file(requests.DownloadFileRequest(
92-
contact_file.folder_path + '/' + contact_file.file_name,
93-
storage))
94-
# ... and print it to console
95-
with open(downloaded, 'r') as f:
96-
file_data = f.read()
97-
print(file_data)
98-
# Also, you can get VCard object properties’ list using Contact API
99-
contact_properties = email_api.get_contact_properties(
100-
requests.GetContactPropertiesRequest(
101-
'VCard',
102-
contact_file.file_name,
103-
contact_file.folder_path,
104-
contact_file.storage))
105-
# All VCard’s properties are available as a list. Complex properties are represented as hierarchical structures.
106-
# Let's print all primitive properties’ values:
107-
primitives = (prop for prop in contact_properties.internal_properties
108-
if prop.type == 'PrimitiveObject')
109-
for prop in primitives:
110-
print('Property name: ' + prop.name + ' value: ' + prop.value)
111-
```
112-
</details>
113-
114-
<details>
115-
<summary>Parse images directly, without the using of a storage</summary>
116-
117-
```python
118-
# Read image from file and convert it to Base64 string
119-
image_file = 'some/business/card/image/file/on/disk.png'
12077
image_data = None
121-
with open(image_file, 'rb') as f:
122-
file_data = f.read()
123-
image_data = str(base64.b64encode(file_data), 'utf-8')
124-
result = email_api.ai_bcr_parse(requests.AiBcrParseRequest(
125-
models.AiBcrBase64Rq(images=[
126-
models.AiBcrBase64Image(True, image_data)])))
127-
# Result contains all recognized VCard objects (only the one in our case)
128-
contact_properties = result.value[0]
129-
# VCard object is available as a list of properties, without any external calls:
130-
primitives = (prop for prop in contact_properties.internal_properties
131-
if prop.type == 'PrimitiveObject')
132-
for prop in primitives:
133-
print('Property name: ' + prop.name + ' value: ' + prop.value)
134-
```
135-
</details>
136-
137-
#### Name API
138-
See examples below:
139-
<details open>
140-
<summary>Detect a person's gender by name</summary>
141-
142-
```python
143-
result = email_api.ai_name_genderize(
144-
requests.AiNameGenderizeRequest('John Cane'))
145-
# the result contains a list of hypothesis about a person's gender.
146-
# all hypothesis include score, so you can use the most scored version,
147-
# which will be the first in a list:
148-
print(result.value[0].gender) # prints 'Male'
149-
```
150-
</details>
151-
152-
<details>
153-
<summary>Format person's name using defined format</summary>
154-
155-
```python
156-
result = email_api.ai_name_format(
157-
requests.AiNameFormatRequest(
158-
'Mr. John Michael Cane',
159-
format='%t%L%f%m'))
160-
print(result.name) # prints 'Mr. Cane J. M.'
161-
```
162-
</details>
163-
164-
<details>
165-
<summary>Compare the names to find out if they belong to the same person or not</summary>
166-
167-
```python
168-
first = 'John Michael Cane'
169-
second = 'Cane J.'
170-
result = email_api.ai_name_match(
171-
requests.AiNameMatchRequest(first, second))
172-
print(result.similarity >= 0.5) # prints 'True', names look similar
173-
```
174-
</details>
175-
176-
<details>
177-
<summary>Expand a person's name into a list of possible alternatives</summary>
178-
179-
```python
180-
name = 'Smith Bobby'
181-
result = email_api.ai_name_expand(
182-
requests.AiNameExpandRequest(name))
183-
expanded_names = list(weighted.name for weighted in result.names)
184-
for (expanded_name in expanded_names):
185-
print expanded_name # prints 'Mr. Smith', 'B. Smith', etc.
186-
```
187-
</details>
188-
189-
<details>
190-
<summary>Get k most probable names for given starting characters</summary>
191-
192-
```python
193-
prefix = 'Dav'
194-
result = email_api.ai_name_complete(
195-
requests.AiNameCompleteRequest(prefix))
196-
names = list(prefix + weighted.name for weighted in result.names)
197-
for (name in names):
198-
print(name) # prints 'David', 'Dave', 'Davis', etc.
199-
```
200-
</details>
201-
202-
<details>
203-
<summary>Parse out a person's name from an email address.</summary>
204-
205-
```python
206-
address = 'john-cane@gmail.com'
207-
result = email_api.ai_name_parse_email_address(
208-
requests.AiNameParseEmailAddressRequest(address))
209-
names = (extracted.name for extracted in result.value)
210-
extracted_values = list(functools.reduce(lambda a,b: a+b, names))
211-
given_name = next((x for x in extracted_values if x.category == 'GivenName'))
212-
surname = next((x for x in extracted_values if x.category == 'Surname'))
213-
print(given_name.value) # prints 'John'
214-
print(surname.value) # prints 'Cane'
78+
with open('/tmp/alex.png', 'rb') as f:
79+
filedata = f.read()
80+
image_data = str(base64.b64encode(filedata), 'utf-8')
81+
result = email_api.ai_bcr_parse_model(requests.AiBcrParseModelRequest(
82+
models.AiBcrBase64Rq(images=[models.AiBcrBase64Image(True, image_data)])))
83+
contact = result.value[0]
21584
```
216-
</details>
85+
See more details [here](https://docs.aspose.cloud/display/emailcloud/Parse+Image+To+VCard+File) and [here](https://docs.aspose.cloud/display/emailcloud/Business+Cards+Recognition+API)
21786

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

0 commit comments

Comments
 (0)