Skip to content

Commit 5027c66

Browse files
committed
Update 1.2.3
added GetToken/OnBehalfOf method added MailList method added MailRead method added MailSend method
1 parent 7aa3a7f commit 5027c66

23 files changed

+365
-23
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
settings.json
22
DevApplication/
3+
build.bat
4+
OnTimeGCApi.nuspec
35

46
## Ignore Visual Studio temporary files, build results, and
57
## files generated by popular Visual Studio add-ons.

OnTimeGCApi.Test/OnTimeGCApi.Test.csproj

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.props')" />
3+
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" />
44
<PropertyGroup>
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -24,25 +24,25 @@
2424
<DebugSymbols>true</DebugSymbols>
2525
<DebugType>full</DebugType>
2626
<Optimize>false</Optimize>
27-
<OutputPath>bin\Debug\</OutputPath>
27+
<OutputPath>..\bin\Debug\</OutputPath>
2828
<DefineConstants>DEBUG;TRACE</DefineConstants>
2929
<ErrorReport>prompt</ErrorReport>
3030
<WarningLevel>4</WarningLevel>
3131
</PropertyGroup>
3232
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3333
<DebugType>pdbonly</DebugType>
3434
<Optimize>true</Optimize>
35-
<OutputPath>bin\Release\</OutputPath>
35+
<OutputPath>..\bin\Release\</OutputPath>
3636
<DefineConstants>TRACE</DefineConstants>
3737
<ErrorReport>prompt</ErrorReport>
3838
<WarningLevel>4</WarningLevel>
3939
</PropertyGroup>
4040
<ItemGroup>
4141
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
42-
<HintPath>..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
42+
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
4343
</Reference>
4444
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
45-
<HintPath>..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
45+
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
4646
</Reference>
4747
<Reference Include="System" />
4848
<Reference Include="System.Core" />
@@ -51,9 +51,7 @@
5151
</ItemGroup>
5252
<ItemGroup>
5353
<Compile Include="Main.cs" />
54-
<Compile Include="Settings.cs">
55-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
56-
</Compile>
54+
<Compile Include="Settings.cs" />
5755
<Compile Include="Properties\AssemblyInfo.cs" />
5856
</ItemGroup>
5957
<ItemGroup>
@@ -72,10 +70,10 @@
7270
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
7371
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
7472
<PropertyGroup>
75-
<ErrorText>Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".</ErrorText>
73+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
7674
</PropertyGroup>
77-
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.props'))" />
78-
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.targets'))" />
75+
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props'))" />
76+
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets'))" />
7977
</Target>
80-
<Import Project="..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.targets')" />
78+
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" />
8179
</Project>

OnTimeGCApi.Test/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="MSTest.TestAdapter" version="1.1.18" targetFramework="net45" />
4-
<package id="MSTest.TestFramework" version="1.1.18" targetFramework="net45" />
3+
<package id="MSTest.TestAdapter" version="1.2.0" targetFramework="net45" />
4+
<package id="MSTest.TestFramework" version="1.2.0" targetFramework="net45" />
55
</packages>

OnTimeGCApi/Client.cs

Lines changed: 124 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,21 @@ public LoginResult Login(string token)
109109
return result;
110110
}
111111

112+
public GetTokenResult GenerateTokenOnBehalfOf(string emailAddress)
113+
{
114+
Dictionary<string, object> parameters = new Dictionary<string, object>();
115+
parameters.Add("ClientTime", DateTime.Now.ToUniversalTime().ToString(DATETIME_FORMATTER));
116+
117+
string payload = (new { Main = this.main, GetToken = parameters }).ToJson();
118+
payload = payload.Replace("{\"Main\":{", $"{{\"Main\":{{\"OnBehalfOf\":\"{emailAddress}\",");
119+
string response = Utilities.Post(this.apiEndpoint, payload);
120+
121+
GetTokenResult result = response.ParseJson<GetTokenResult>();
122+
this.main.UpdateToken(result.Token);
123+
124+
return result;
125+
}
126+
112127
/// <summary>
113128
/// Tell the API that we're logging out. Not critical, more as good behavior and for logging
114129
/// </summary>
@@ -535,15 +550,18 @@ public MailContactsReadResult MailContactsRead(string userId, string unId, List<
535550
MailContactsReadResult result = response.ParseJson<MailContactsReadResult>();
536551
this.main.UpdateToken(result.Token);
537552

538-
if (additionalFields != null)
553+
if (additionalFields != null && additionalFields.Count != 0)
539554
{
540555
Dictionary<string, object> temp = response.ParseJson<Dictionary<string, object>>();
541556
temp = (Dictionary<string, object>)temp["MailContactsRead"];
542557
temp = (Dictionary<string, object>)temp["Contact"];
543558
result.MailContactsRead.Contact.Fields = new Dictionary<string, object>();
544559
foreach (string item in additionalFields)
545560
{
546-
result.MailContactsRead.Contact.Fields.Add(item, temp[item]);
561+
if (temp.ContainsKey(item))
562+
{
563+
result.MailContactsRead.Contact.Fields.Add(item, temp[item]);
564+
}
547565
}
548566
}
549567

@@ -622,6 +640,110 @@ public CalendarsModifiedResult CalendarsModified(string changeKey = null)
622640
return result;
623641
}
624642

643+
public MailListResult MailList(string userId, DateTime from, DateTime to)
644+
{
645+
if (this.servletPath == null) { throw new NullReferenceException("servletPath is null"); }
646+
if (userId == null) { throw new ArgumentNullException("userId"); }
647+
if (from == null) { throw new ArgumentNullException("from"); }
648+
if (to == null) { throw new ArgumentNullException("to"); }
649+
650+
Dictionary<string, object> parameters = new Dictionary<string, object>();
651+
parameters.Add("UserID", userId);
652+
parameters.Add("FromDT", from.ToUniversalTime().ToString(DATETIME_FORMATTER));
653+
parameters.Add("ToDT", to.ToUniversalTime().ToString(DATETIME_FORMATTER));
654+
655+
string payload = (new { Main = this.main, MailList = parameters }).ToJson();
656+
string response = Utilities.Post(this.servletEndpoint, payload);
657+
658+
MailListResult result = response.ParseJson<MailListResult>();
659+
this.main.UpdateToken(result.Token);
660+
661+
return result;
662+
}
663+
664+
public MailReadResult MailRead(string userId, string unId, string[] fields, string[] extraItems = null, string[] attachments = null, bool bodyHtml = true, bool bodyMime = false)
665+
{
666+
if (this.servletPath == null) { throw new NullReferenceException("servletPath is null"); }
667+
if (userId == null) { throw new ArgumentNullException("userId"); }
668+
if (unId == null) { throw new ArgumentNullException("unId"); }
669+
if (fields == null) { throw new ArgumentNullException("fields"); }
670+
671+
Dictionary<string, object> parameters = new Dictionary<string, object>();
672+
parameters.Add("UserID", userId);
673+
parameters.Add("UnID", unId);
674+
parameters.Add("Fields", fields);
675+
parameters.Add("BodyHtml", bodyHtml);
676+
parameters.Add("BodyMime", bodyMime);
677+
678+
if (extraItems != null && extraItems.Length != 0) { parameters.Add("ExtraItems", extraItems); }
679+
if (attachments != null && attachments.Length != 0) { parameters.Add("Attachments", attachments); }
680+
681+
string payload = (new { Main = this.main, MailRead = parameters }).ToJson();
682+
string response = Utilities.Post(this.servletEndpoint, payload);
683+
684+
MailReadResult result = response.ParseJson<MailReadResult>();
685+
this.main.UpdateToken(result.Token);
686+
687+
if (fields != null && fields.Length != 0)
688+
{
689+
Dictionary<string, object> temp = response.ParseJson<Dictionary<string, object>>();
690+
temp = (Dictionary<string, object>)temp["MailRead"];
691+
temp = (Dictionary<string, object>)temp["Mail"];
692+
result.MailRead.Mail.Fields = new Dictionary<string, string>();
693+
foreach (string item in fields)
694+
{
695+
if (temp.ContainsKey(item))
696+
{
697+
result.MailRead.Mail.Fields.Add(item, (string)temp[item]);
698+
}
699+
}
700+
}
701+
702+
if (extraItems != null && extraItems.Length != 0)
703+
{
704+
Dictionary<string, object> temp = response.ParseJson<Dictionary<string, object>>();
705+
temp = (Dictionary<string, object>)temp["MailRead"];
706+
temp = (Dictionary<string, object>)temp["Mail"];
707+
temp = (Dictionary<string, object>)temp["ExtraItems"];
708+
709+
result.MailRead.Mail.Extraitems = new Dictionary<string, MailReadExtraItem>();
710+
foreach (string item in fields)
711+
{
712+
if (temp.ContainsKey(item))
713+
{
714+
result.MailRead.Mail.Extraitems.Add(item, temp["Subject"].ToJson().ParseJson<MailReadExtraItem>());
715+
}
716+
}
717+
}
718+
719+
return result;
720+
}
721+
722+
public MailSendResult MailSend(string[] sendTo, string subject, string body, string[] copyTo = null, string[] blindCopyTo = null, MailSendAttachment[] attachments = null)
723+
{
724+
if (this.servletPath == null) { throw new NullReferenceException("servletPath is null"); }
725+
if (sendTo == null || sendTo.Length == 0) { throw new ArgumentNullException("sendTo"); }
726+
if (subject == null) { throw new ArgumentNullException("subject"); }
727+
if (body == null) { throw new ArgumentNullException("body"); }
728+
729+
Dictionary<string, object> parameters = new Dictionary<string, object>();
730+
parameters.Add("SendTo", sendTo);
731+
parameters.Add("Subject", subject);
732+
parameters.Add("Body", body);
733+
734+
if (copyTo != null && copyTo.Length != 0) { parameters.Add("CopyTo", copyTo); }
735+
if (blindCopyTo != null && blindCopyTo.Length != 0) { parameters.Add("BlindCopyTo", blindCopyTo); }
736+
if (attachments != null && attachments.Length != 0) { parameters.Add("Attachments", attachments); }
737+
738+
string payload = (new { Main = this.main, MailSend = parameters }).ToJson();
739+
string response = Utilities.Post(this.servletEndpoint, payload);
740+
741+
MailSendResult result = response.ParseJson<MailSendResult>();
742+
this.main.UpdateToken(result.Token);
743+
744+
return result;
745+
}
746+
625747
private class OtBase
626748
{
627749
public string ApplID { get; set; }

OnTimeGCApi/OnTimeGCApi.csproj

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@
1616
<DebugSymbols>true</DebugSymbols>
1717
<DebugType>full</DebugType>
1818
<Optimize>false</Optimize>
19-
<OutputPath>bin\Debug\</OutputPath>
19+
<OutputPath>..\bin\Debug\</OutputPath>
2020
<DefineConstants>DEBUG;TRACE</DefineConstants>
2121
<ErrorReport>prompt</ErrorReport>
2222
<WarningLevel>4</WarningLevel>
2323
</PropertyGroup>
2424
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2525
<DebugType>pdbonly</DebugType>
2626
<Optimize>true</Optimize>
27-
<OutputPath>bin\Release\</OutputPath>
27+
<OutputPath>..\bin\Release\</OutputPath>
2828
<DefineConstants>TRACE</DefineConstants>
2929
<ErrorReport>prompt</ErrorReport>
3030
<WarningLevel>4</WarningLevel>
31+
<DocumentationFile>..\bin\Release\OnTimeGCApi.xml</DocumentationFile>
3132
</PropertyGroup>
3233
<ItemGroup>
3334
<Reference Include="System" />
@@ -52,6 +53,8 @@
5253
<Compile Include="Value\Calendars\CalendarItem.cs" />
5354
<Compile Include="Value\DatabaseInfo.cs" />
5455
<Compile Include="Value\EventType.cs" />
56+
<Compile Include="Value\GetToken\GetTokenItem.cs" />
57+
<Compile Include="Value\GetToken\GetTokenResult.cs" />
5558
<Compile Include="Value\GroupList\GroupList.cs" />
5659
<Compile Include="Value\GroupList\GroupListItem.cs" />
5760
<Compile Include="Value\GroupList\GroupListResult.cs" />
@@ -73,6 +76,20 @@
7376
<Compile Include="Value\MailContactsRead\MailContactsReadResult.cs" />
7477
<Compile Include="Value\MailContactsRemove\MailContactsRemove.cs" />
7578
<Compile Include="Value\MailContactsRemove\MailContactsRemoveResult.cs" />
79+
<Compile Include="Value\MailList\MailList.cs" />
80+
<Compile Include="Value\MailList\MailListAttachment.cs" />
81+
<Compile Include="Value\MailList\MailListItem.cs" />
82+
<Compile Include="Value\MailList\MailListResult.cs" />
83+
<Compile Include="Value\MailRead\MailRead.cs" />
84+
<Compile Include="Value\MailRead\MailReadAttachment.cs" />
85+
<Compile Include="Value\MailRead\MailReadBodyMime.cs" />
86+
<Compile Include="Value\MailRead\MailReadExtraItem.cs" />
87+
<Compile Include="Value\MailRead\MailReadItem.cs" />
88+
<Compile Include="Value\MailRead\MailReadResult.cs" />
89+
<Compile Include="Value\MailSend\MailSend.cs" />
90+
<Compile Include="Value\MailSend\MailSendAttachment.cs" />
91+
<Compile Include="Value\MailSend\MailSendResult.cs" />
92+
<Compile Include="Value\MailType.cs" />
7693
<Compile Include="Value\Profile.cs" />
7794
<Compile Include="Value\UsersAll\UsersAllResult.cs" />
7895
<Compile Include="Value\User.cs" />

OnTimeGCApi/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
3232
// übernehmen, indem Sie "*" eingeben:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.2.2.0")]
35-
[assembly: AssemblyFileVersion("1.2.2.0")]
34+
[assembly: AssemblyVersion("1.2.3.0")]
35+
[assembly: AssemblyFileVersion("1.2.3.0")]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+

2+
namespace OnTimeGCApi
3+
{
4+
public class GetTokenItem
5+
{
6+
public string Token { get; set; }
7+
public string User { get; set; }
8+
public string ID { get; set; }
9+
public int CurrentTimeout { get; set; }
10+
public int SectionProcessTime { get; set; }
11+
12+
public override string ToString()
13+
{
14+
return $"{{ User: \"{this.User}\" | Id: \"{this.ID}\" | Token: \"{this.Token}\" | CurrenTimeout: \"{this.CurrentTimeout}\" }}";
15+
}
16+
}
17+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+

2+
namespace OnTimeGCApi
3+
{
4+
public class GetTokenResult : BaseResult
5+
{
6+
public GetTokenItem GetToken { get; set; }
7+
}
8+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections.Generic;
2+
3+
namespace OnTimeGCApi
4+
{
5+
public class MailList
6+
{
7+
public List<MailListItem> Items { get; set; }
8+
public int SectionProcessTime { get; set; }
9+
10+
public override string ToString()
11+
{
12+
return $"{{ Items: \"{this.Items?.Count}\" | SectionProcessTime: \"{this.SectionProcessTime}\" }}";
13+
}
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+

2+
namespace OnTimeGCApi
3+
{
4+
public class MailListAttachment
5+
{
6+
public string Name { get; set; }
7+
public int FileSize { get; set; }
8+
public string Source { get; set; }
9+
10+
public override string ToString()
11+
{
12+
return $"{{ Name: \"{this.Name}\" | Size: \"{this.FileSize}\" | Source: \"{this.Source}\" }}";
13+
}
14+
}
15+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace OnTimeGCApi
5+
{
6+
public class MailListItem
7+
{
8+
public string UnID { get; set; }
9+
public int LastMod { get; set; }
10+
public int Size { get; set; }
11+
public DateTime Date { get; set; }
12+
public DateTime? PostedDate { get; set; }
13+
public DateTime? DeliveredDate { get; set; }
14+
public string Subject { get; set; }
15+
public string From { get; set; }
16+
public List<string> SendTo { get; set; }
17+
public List<string> CopyTo { get; set; }
18+
public string BodyAbb { get; set; }
19+
public List<MailListAttachment> Attachments { get; set; }
20+
public MailType Type { get { return (this.DeliveredDate == null ? MailType.Sent : MailType.Received); } }
21+
22+
public override string ToString()
23+
{
24+
return $"{{ Type: \"{this.Type}\" | Subject: \"{this.Subject}\" | Date: \"{this.Date}\" | From: \"{this.From}\" | Attachments: \"{this.Attachments?.Count}\" }}";
25+
}
26+
}
27+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+

2+
namespace OnTimeGCApi
3+
{
4+
public class MailListResult : BaseResult
5+
{
6+
public MailList MailList { get; set; }
7+
}
8+
}

0 commit comments

Comments
 (0)