Skip to content

Commit 9511b81

Browse files
Merge pull request #5 from aspose-email-cloud/develop
Develop
2 parents dff3d96 + 417c131 commit 9511b81

File tree

119 files changed

+9913
-504
lines changed

Some content is hidden

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

119 files changed

+9913
-504
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ bin/
66
*.DotSettings.user
77
.idea/
88
private-appsettings.json
9-
.vscode
9+
.vscode
10+
*.DotSettings

Api/EmailApi.cs

Lines changed: 2066 additions & 476 deletions
Large diffs are not rendered by default.

Aspose.Email-Cloud.Tests/Tests/TestFixture.cs

Lines changed: 129 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public void OneTimeSetup()
3838
var apiConfiguration = new Configuration
3939
{
4040
ApiVersion = "v3.0",
41-
ApiBaseUrl = configurationHelper.GetValue("apiBaseUrl", "https://api-qa.aspose.cloud"),
41+
ApiBaseUrl =
42+
configurationHelper.GetValue("apiBaseUrl", "https://api-qa.aspose.cloud"),
4243
AppKey = configurationHelper.GetValue("appKey", string.Empty),
4344
AppSid = configurationHelper.GetValue("appSid", string.Empty),
4445
AuthUrl = configurationHelper.GetValue<string>("authUrl", null)
@@ -130,7 +131,8 @@ public async Task ContactFormatTest()
130131
var extension = format == "vcard" ? ".vcf" : ".msg";
131132
var name = $"{Guid.NewGuid().ToString()}{extension}";
132133
await emailApi.CreateContactAsync(new CreateContactRequest(format, name,
133-
new HierarchicalObjectRequest(new HierarchicalObject("CONTACT", null, new List<BaseObject>()),
134+
new HierarchicalObjectRequest(
135+
new HierarchicalObject("CONTACT", null, new List<BaseObject>()),
134136
new StorageFolderLocation(StorageName, folder))));
135137
var contactExist = await IsFileExist(name);
136138
Assert.IsTrue(contactExist);
@@ -148,7 +150,9 @@ public async Task DateTimeTest()
148150
{
149151
var startDate = DateTime.UtcNow.Date.AddDays(1).AddHours(12);
150152
var calendarFile = await CreateCalendar(startDate);
151-
var calendar = await emailApi.GetCalendarAsync(new GetCalendarRequest(calendarFile, folder, StorageName));
153+
var calendar =
154+
await emailApi.GetCalendarAsync(new GetCalendarRequest(calendarFile, folder,
155+
StorageName));
152156
var startDateProperty = calendar.InternalProperties
153157
.First(property => property.Name == "STARTDATE");
154158
var factStartDate = DateTime
@@ -163,7 +167,8 @@ public async Task DateTimeTest()
163167
[Test]
164168
public async Task AiNameGenderizeTest()
165169
{
166-
var result = await emailApi.AiNameGenderizeAsync(new AiNameGenderizeRequest("John Cane"));
170+
var result =
171+
await emailApi.AiNameGenderizeAsync(new AiNameGenderizeRequest("John Cane"));
167172
Assert.GreaterOrEqual(result.Value.Count, 1);
168173
Assert.True(result.Value.Any(item => item.Gender == "Male"));
169174
}
@@ -247,7 +252,8 @@ public async Task AiBcrParseStorageTest()
247252
// 1) Upload business card image to storage
248253
using (var stream = File.OpenRead(BcrAiTestFilePath))
249254
{
250-
await emailApi.UploadFileAsync(new UploadFileRequest($"{folder}/{fileName}", stream, StorageName));
255+
await emailApi.UploadFileAsync(new UploadFileRequest($"{folder}/{fileName}", stream,
256+
StorageName));
251257
}
252258

253259
var outFolder = Guid.NewGuid().ToString();
@@ -257,7 +263,10 @@ public async Task AiBcrParseStorageTest()
257263
var result = await emailApi.AiBcrParseStorageAsync(new AiBcrParseStorageRequest(
258264
new AiBcrParseStorageRq(null,
259265
new List<AiBcrImageStorageFile>
260-
{new AiBcrImageStorageFile(true, new StorageFileLocation(StorageName, folder, fileName))},
266+
{
267+
new AiBcrImageStorageFile(true,
268+
new StorageFileLocation(StorageName, folder, fileName))
269+
},
261270
new StorageFolderLocation(StorageName, outFolderPath))));
262271
//Check that only one file produced
263272
Assert.True(result.Value.Count == 1);
@@ -275,8 +284,9 @@ public async Task AiBcrParseStorageTest()
275284
}
276285

277286
// 5) Get VCard object properties list, check that there are 3 properties or more
278-
var contactProperties = await emailApi.GetContactPropertiesAsync(new GetContactPropertiesRequest(
279-
"vcard", contactFile.FileName, contactFile.FolderPath, contactFile.Storage));
287+
var contactProperties = await emailApi.GetContactPropertiesAsync(
288+
new GetContactPropertiesRequest(
289+
"vcard", contactFile.FileName, contactFile.FolderPath, contactFile.Storage));
280290
Assert.GreaterOrEqual(contactProperties.InternalProperties.Count, 3);
281291
}
282292

@@ -287,8 +297,10 @@ public async Task AiBcrParseStorageTest()
287297
[Test]
288298
public async Task AiBcrParseTest()
289299
{
290-
var result = await emailApi.AiBcrParseAsync(new AiBcrParseRequest(new AiBcrBase64Rq(null,
291-
new List<AiBcrBase64Image> {new AiBcrBase64Image(true, FileToBase64(BcrAiTestFilePath))})));
300+
var result = await emailApi.AiBcrParseAsync(new AiBcrParseRequest(new AiBcrBase64Rq(
301+
null,
302+
new List<AiBcrBase64Image>
303+
{new AiBcrBase64Image(true, FileToBase64(BcrAiTestFilePath))})));
292304
Assert.AreEqual(1, result.Value.Count);
293305
Assert.True(result.Value
294306
.First()
@@ -298,6 +310,111 @@ public async Task AiBcrParseTest()
298310
.Any(property => property.Value?.Contains("Thomas") ?? false));
299311
}
300312

313+
[Test]
314+
[Pipeline]
315+
public async Task CreateCalendarEmailTest()
316+
{
317+
var calendar = new CalendarDto
318+
{
319+
Attendees = new List<MailAddress>
320+
{
321+
new MailAddress("Attendee Name", "attendee@am.ru", "Accepted")
322+
},
323+
Description = "Some description",
324+
Summary = "Some summary",
325+
Organizer = new MailAddress("Organizer Name", "cloud.em@yandex.ru", null),
326+
StartDate = DateTime.UtcNow.AddDays(1).AddHours(12),
327+
EndDate = DateTime.UtcNow.AddDays(1).AddHours(13),
328+
Location = "Some location"
329+
};
330+
var folderLocation = new StorageFolderLocation(StorageName, folder);
331+
var calendarFile = $"{Guid.NewGuid()}.ics";
332+
await emailApi.SaveCalendarModelAsync(
333+
new SaveCalendarModelRequest(calendarFile, new StorageModelRqOfCalendarDto(
334+
calendar, folderLocation)));
335+
336+
var exists = await IsFileExist(calendarFile);
337+
Assert.True(exists);
338+
339+
var alternate = await emailApi.ConvertCalendarModelToAlternateAsync(
340+
new ConvertCalendarModelToAlternateRequest(
341+
new CalendarDtoAlternateRq(calendar, "Create", null)));
342+
var email = new EmailDto
343+
{
344+
AlternateViews = new List<AlternateView> {alternate},
345+
From = new MailAddress("From address", "cloud.em@yandex.ru", "Accepted"),
346+
To = new List<MailAddress>
347+
{new MailAddress("To address", "cloud.em@yandex.ru", null)},
348+
Subject = "Some subject",
349+
Body = "Some body"
350+
};
351+
var emailFile = $"{Guid.NewGuid().ToString()}.eml";
352+
await emailApi.SaveEmailModelAsync(
353+
new SaveEmailModelRequest("Eml", emailFile,
354+
new StorageModelRqOfEmailDto(email,
355+
folderLocation)));
356+
var emlFile = await emailApi.DownloadFileAsync(
357+
new DownloadFileRequest($"{folder}/{emailFile}", StorageName));
358+
emlFile.Seek(0, SeekOrigin.Begin);
359+
var fileReader = new StreamReader(emlFile);
360+
var emlFileContent = await fileReader.ReadToEndAsync();
361+
Assert.That(emlFileContent.Contains("cloud.em@yandex.ru"));
362+
}
363+
364+
[Test]
365+
[Pipeline]
366+
public async Task ContactModelTest()
367+
{
368+
var contact = new ContactDto
369+
{
370+
Gender = "Male",
371+
Surname = "Thomas",
372+
GivenName = "Alex",
373+
EmailAddresses = new List<EmailAddress>
374+
{
375+
new EmailAddress
376+
{
377+
Category = new EnumWithCustomOfEmailAddressCategory("Work", null),
378+
Address = "alex.thomas@work.com",
379+
Preferred = true,
380+
DisplayName = "Alex Thomas"
381+
}
382+
},
383+
PhoneNumbers = new List<PhoneNumber>
384+
{
385+
new PhoneNumber
386+
{
387+
Category = new EnumWithCustomOfPhoneNumberCategory("Work", null),
388+
Number = "+49211424721",
389+
Preferred = true
390+
}
391+
}
392+
};
393+
394+
var contactFile = $"{Guid.NewGuid().ToString()}.vcf";
395+
await emailApi.SaveContactModelAsync(
396+
new SaveContactModelRequest(
397+
"VCard", contactFile,
398+
new StorageModelRqOfContactDto(contact,
399+
new StorageFolderLocation(StorageName, folder))));
400+
var exists = await IsFileExist(contactFile);
401+
Assert.True(exists);
402+
}
403+
404+
[Test]
405+
public async Task AiBcrParseModelTest()
406+
{
407+
var result = await emailApi.AiBcrParseModelAsync(
408+
new AiBcrParseModelRequest(
409+
new AiBcrBase64Rq(
410+
null,
411+
new List<AiBcrBase64Image>
412+
{
413+
new AiBcrBase64Image(true, FileToBase64(BcrAiTestFilePath))
414+
})));
415+
Assert.AreEqual("Alex Thomas", result.Value.First().DisplayName);
416+
}
417+
301418
private static string FileToBase64(string filePath)
302419
{
303420
var bytes = File.ReadAllBytes(filePath);
@@ -338,7 +455,8 @@ private async Task<string> CreateCalendar(DateTime? startDate = null)
338455
new List<BaseObject>
339456
{
340457
new PrimitiveObject("ADDRESS", null, "attendee@am.ru"),
341-
new PrimitiveObject("DISPLAYNAME", null, "Attendee Name")
458+
new PrimitiveObject("DISPLAYNAME", null,
459+
"Attendee Name")
342460
})
343461
})
344462
}), new StorageFolderLocation(StorageName, folder)));

Aspose.Email-Cloud.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<RepositoryUrl>https://github.com/aspose-email-cloud/aspose-email-cloud-dotnet</RepositoryUrl>
1313
<PackageTags>ASPOSE EMAIL CLOUD SDK Outlook MSG EML MHT</PackageTags>
1414
<RootNamespace>Aspose.Email.Cloud.Sdk</RootNamespace>
15-
<Version>19.12.0</Version>
15+
<Version>19.12.1</Version>
1616
</PropertyGroup>
1717
<ItemGroup Condition=" '$(TargetFramework)' == 'Xamarin.iOS10' OR '$(TargetFramework)' == 'Xamarin.Mac20' OR '$(TargetFramework)' == 'MonoAndroid60'">
1818
<PackageReference Include="Newtonsoft.Json" Version="8.0.3" />

Model/AiBcrParseOcrDataRq.cs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Aspose" file="AiBcrParseOcrDataRq.cs">
3+
// Copyright (c) 2016 Aspose.Email for Cloud
4+
// </copyright>
5+
// <summary>
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
// </summary>
24+
// --------------------------------------------------------------------------------------------------------------------
25+
26+
namespace Aspose.Email.Cloud.Sdk.Model
27+
{
28+
using System;
29+
using System.Collections;
30+
using System.Collections.Generic;
31+
using System.Runtime.Serialization;
32+
using System.Text;
33+
using Newtonsoft.Json;
34+
using Newtonsoft.Json.Converters;
35+
/// <summary>
36+
/// Parse ocr data request
37+
/// </summary>
38+
public class AiBcrParseOcrDataRq : AiBcrRq
39+
{
40+
/// <summary>
41+
/// OCR data
42+
/// </summary>
43+
public List<AiBcrOcrData> Data { get; set; }
44+
45+
/// <summary>AiBcrParseOcrDataRq constructor</summary>
46+
public AiBcrParseOcrDataRq() {}
47+
48+
/// <summary>AiBcrParseOcrDataRq constructor</summary>
49+
/// <param name="options">Recognition options </param>
50+
/// <param name="data">OCR data </param>
51+
public AiBcrParseOcrDataRq(AiBcrOptions options, List<AiBcrOcrData> data)
52+
{
53+
Options = options;
54+
Data = data;
55+
}
56+
/// <summary>
57+
/// Get the string presentation of the object
58+
/// </summary>
59+
/// <returns>String presentation of the object</returns>
60+
public override string ToString()
61+
{
62+
var sb = new StringBuilder();
63+
sb.Append("class AiBcrParseOcrDataRq {\n");
64+
sb.Append(" Options: ").Append(this.Options).Append("\n");
65+
sb.Append(" Data: ").Append(this.Data).Append("\n");
66+
sb.Append("}\n");
67+
return sb.ToString();
68+
}
69+
}
70+
}

Model/AlternateView.cs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Aspose" file="AlternateView.cs">
3+
// Copyright (c) 2016 Aspose.Email for Cloud
4+
// </copyright>
5+
// <summary>
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
// </summary>
24+
// --------------------------------------------------------------------------------------------------------------------
25+
26+
namespace Aspose.Email.Cloud.Sdk.Model
27+
{
28+
using System;
29+
using System.Collections;
30+
using System.Collections.Generic;
31+
using System.Runtime.Serialization;
32+
using System.Text;
33+
using Newtonsoft.Json;
34+
using Newtonsoft.Json.Converters;
35+
/// <summary>
36+
/// Represents the format to view a message.
37+
/// </summary>
38+
public class AlternateView : AttachmentBase
39+
{
40+
/// <summary>
41+
/// Base URI.
42+
/// </summary>
43+
public string BaseUri { get; set; }
44+
45+
/// <summary>
46+
/// Embedded resources referred to by this alternate view.
47+
/// </summary>
48+
public List<LinkedResource> LinkedResources { get; set; }
49+
50+
/// <summary>AlternateView constructor</summary>
51+
public AlternateView() {}
52+
53+
/// <summary>AlternateView constructor</summary>
54+
/// <param name="base64Data">Attachment file content as Base64 string. </param>
55+
/// <param name="contentId">Attachment content id </param>
56+
/// <param name="contentType">Content type </param>
57+
/// <param name="headers">Attachment headers. </param>
58+
/// <param name="baseUri">Base URI. </param>
59+
/// <param name="linkedResources">Embedded resources referred to by this alternate view. </param>
60+
public AlternateView(string base64Data, string contentId, ContentType contentType, Dictionary<string, string> headers, string baseUri, List<LinkedResource> linkedResources)
61+
{
62+
Base64Data = base64Data;
63+
ContentId = contentId;
64+
ContentType = contentType;
65+
Headers = headers;
66+
BaseUri = baseUri;
67+
LinkedResources = linkedResources;
68+
}
69+
/// <summary>
70+
/// Get the string presentation of the object
71+
/// </summary>
72+
/// <returns>String presentation of the object</returns>
73+
public override string ToString()
74+
{
75+
var sb = new StringBuilder();
76+
sb.Append("class AlternateView {\n");
77+
sb.Append(" Base64Data: ").Append(this.Base64Data).Append("\n");
78+
sb.Append(" ContentId: ").Append(this.ContentId).Append("\n");
79+
sb.Append(" ContentType: ").Append(this.ContentType).Append("\n");
80+
sb.Append(" Headers: ").Append(this.Headers).Append("\n");
81+
sb.Append(" BaseUri: ").Append(this.BaseUri).Append("\n");
82+
sb.Append(" LinkedResources: ").Append(this.LinkedResources).Append("\n");
83+
sb.Append("}\n");
84+
return sb.ToString();
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)