Fleshed out the table storage service and started syncing logic

This commit is contained in:
2020-03-19 19:09:03 -04:00
parent 59377a7749
commit 0bfab99f1b
22 changed files with 630 additions and 131 deletions

View File

@@ -57,6 +57,10 @@
<assemblyIdentity name="Microsoft.Extensions.Configuration.FileExtensions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.2.0" newVersion="3.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -13,6 +13,8 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -34,6 +36,15 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.Cosmos.Table, Version=1.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.Cosmos.Table.1.0.6\lib\netstandard2.0\Microsoft.Azure.Cosmos.Table.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.DocumentDB.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.DocumentDB.Core.2.1.3\lib\netstandard1.6\Microsoft.Azure.DocumentDB.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
@@ -61,24 +72,121 @@
<Reference Include="Microsoft.Extensions.Primitives, Version=3.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Primitives.3.1.2\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll</HintPath>
</Reference>
<Reference Include="Microsoft.OData.Core, Version=7.5.0.20627, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.OData.Core.7.5.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.OData.Edm, Version=7.5.0.20627, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.OData.Edm.7.5.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Spatial, Version=7.5.0.20627, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Spatial.7.5.0\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.165\lib\net45\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.165\lib\net45\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Win32.Primitives.4.0.1\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=9.3.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAzure.Storage.9.3.3\lib\net45\Microsoft.WindowsAzure.Storage.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.AppContext, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.AppContext.4.1.0\lib\net463\System.AppContext.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Collections.NonGeneric, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.NonGeneric.4.0.1\lib\net46\System.Collections.NonGeneric.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Collections.Specialized, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Specialized.4.0.1\lib\net46\System.Collections.Specialized.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Console.4.0.0\lib\net46\System.Console.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.4.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Diagnostics.TraceSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.TraceSource.4.0.0\lib\net46\System.Diagnostics.TraceSource.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Diagnostics.Tracing, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.Tracing.4.1.0\lib\net462\System.Diagnostics.Tracing.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Globalization.Calendars, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Globalization.Calendars.4.0.1\lib\net46\System.Globalization.Calendars.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Compression, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.4.1.0\lib\net46\System.IO.Compression.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.IO.Compression.ZipFile, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.ZipFile.4.0.1\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.FileSystem.4.0.1\lib\net46\System.IO.FileSystem.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Linq, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Linq.4.1.0\lib\net463\System.Linq.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Linq.Expressions.4.1.0\lib\net463\System.Linq.Expressions.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Net.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.4.1.0\lib\net46\System.Net.Http.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Extensions, Version=2.2.22.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Extensions.dll</HintPath>
</Reference>
@@ -86,19 +194,100 @@
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Net.NameResolution, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.NameResolution.4.0.0\lib\net46\System.Net.NameResolution.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.NetworkInformation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.NetworkInformation.4.1.0\lib\net46\System.Net.NetworkInformation.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Security, Version=4.0.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Sockets, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Sockets.4.1.0\lib\net46\System.Net.Sockets.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Reflection, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.4.1.0\lib\net462\System.Reflection.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Extensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.Extensions.4.1.0\lib\net462\System.Runtime.Extensions.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.InteropServices, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.4.1.0\lib\net462\System.Runtime.InteropServices.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.0.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Runtime.Serialization.Primitives, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.Serialization.Primitives.4.1.1\lib\net46\System.Runtime.Serialization.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.SecureString, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.SecureString.4.0.0\lib\net46\System.Security.SecureString.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.4.7.0\lib\netstandard2.0\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.4.7.1\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.RegularExpressions.4.1.0\lib\net463\System.Text.RegularExpressions.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
@@ -110,7 +299,6 @@
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
@@ -140,4 +328,11 @@
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<Import Project="..\packages\Microsoft.Azure.DocumentDB.Core.2.1.3\build\Microsoft.Azure.DocumentDB.Core.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.Core.2.1.3\build\Microsoft.Azure.DocumentDB.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<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>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Azure.DocumentDB.Core.2.1.3\build\Microsoft.Azure.DocumentDB.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Azure.DocumentDB.Core.2.1.3\build\Microsoft.Azure.DocumentDB.Core.targets'))" />
</Target>
</Project>

View File

@@ -1,4 +1,6 @@
using Habitica.Todoist.Integration.Model.Habitica;
using Habitica.Todoist.Integration.Model.Habitica.Enums;
using Habitica.Todoist.Integration.Model.Storage;
using Habitica.Todoist.Integration.Model.Todoist;
using Habitica.Todoist.Integration.Services;
using Microsoft.Extensions.Configuration;
@@ -20,30 +22,79 @@ namespace Habitica.Todoist.Integration.Console
private static string habiticaApiUrl => "https://habitica.com/api/v3/";
private static string habiticaUserId => configuration["habitica:userId"];
private static string habiticaApiKey => configuration["habitica:apiKey"];
private static string todoistApiUrl => "https://api.todoist.com/sync/v8/";
private static string todoistApiKey => configuration["todoist:apiKey"];
private static string tableStorageConnectionString => configuration["tableStorage:connectionString"];
private static string giosUserId => "0b6ec4eb-8878-4b9e-8585-7673764a6541";
static void Main(string[] args)
{
ConfigBuild();
var todoistClient = new TodoistClientService(todoistApiKey);
var syncResponse = todoistClient.GetUpdatedItems().ConfigureAwait(false).GetAwaiter().GetResult();
foreach (var item in syncResponse.Items)
{
var newTask = new Task
{
Text = item.GetCleanContent(),
Type = TaskType.Todo,
Date = item.Due?.ToJavaScriptDateStr(),
Priority = GetHabiticaDifficulty(item.GetDifficulty().GetValueOrDefault())
};
//var habiticaClient2 = new HabiticaServiceClient(habiticaUserId, habiticaApiKey);
var habiticaClient = new HabiticaClientService(habiticaUserId, habiticaApiKey);
var task = habiticaClient.CreateUserTask(newTask).ConfigureAwait(false).GetAwaiter().GetResult();
//var tasks = habiticaClient2.ReadTasks().ConfigureAwait(false).GetAwaiter().GetResult().Data;
//foreach (var task in tasks)
// habiticaClient2.DeleteTask(task.Id).ConfigureAwait(false).GetAwaiter().GetResult();
//return;
// initialize all the clients
var habiticaClient = new HabiticaServiceClient(habiticaUserId, habiticaApiKey);
var todoistClient = new TodoistServiceClient(todoistApiKey);
var tableStorageClient = new TableStorageClient(tableStorageConnectionString);
// get todoist sync token if available
var syncToken = "";
try { syncToken = tableStorageClient.Query<TodoistSync>().Where(x => x.PartitionKey == giosUserId).ToList()
.OrderByDescending(x => x.Timestamp).First().RowKey; } catch { }
// get all changed items from todoist
var response = todoistClient.GetChangedItems(syncToken).ConfigureAwait(false).GetAwaiter().GetResult();
var changedItems = response.Items;
// filter out items by actions
var addItems = changedItems.Where(x => !tableStorageClient.Exists<TodoHabitLink>(giosUserId, x.Id)
.ConfigureAwait(false).GetAwaiter().GetResult() && x.Is_deleted == 0).ToList();
var updateItems = changedItems.Where(x => tableStorageClient.Exists<TodoHabitLink>(giosUserId, x.Id)
.ConfigureAwait(false).GetAwaiter().GetResult() && x.Is_deleted == 0 && x.Date_completed == null).ToList();
var completeItems = changedItems.Where(x => x.Is_deleted == 0 && x.Date_completed != null).ToList();
var deleteItems = changedItems.Where(x => tableStorageClient.Exists<TodoHabitLink>(giosUserId, x.Id)
.ConfigureAwait(false).GetAwaiter().GetResult() && x.Is_deleted == 1).ToList();
foreach (var addItem in addItems)
{
var task = habiticaClient.CreateTask(TaskFromTodoistItem(addItem)).ConfigureAwait(false).GetAwaiter().GetResult().Data;
var link = new TodoHabitLink(giosUserId, addItem.Id, task.Id);
tableStorageClient.InsertOrUpdate(link).ConfigureAwait(false).GetAwaiter().GetResult();
tableStorageClient.InsertOrUpdate(link.Reverse()).ConfigureAwait(false).GetAwaiter().GetResult();
}
foreach (var updateItem in updateItems)
{
var habiticaId = tableStorageClient.Query<TodoHabitLink>().Where(x => x.PartitionKey == giosUserId && x.RowKey == updateItem.Id)
.ToList().First().HabiticaId;
habiticaClient.UpdateTask(TaskFromTodoistItem(updateItem, habiticaId)).ConfigureAwait(false).GetAwaiter().GetResult();
}
foreach (var completeItem in completeItems)
{
var habiticaId = tableStorageClient.Query<TodoHabitLink>().Where(x => x.PartitionKey == giosUserId && x.RowKey == completeItem.Id)
.ToList().First().HabiticaId;
habiticaClient.ScoreTask(habiticaId, ScoreAction.Up).ConfigureAwait(false).GetAwaiter().GetResult();
}
foreach (var deleteItem in deleteItems)
{
var habiticaId = tableStorageClient.Query<TodoHabitLink>().Where(x => x.PartitionKey == giosUserId && x.RowKey == deleteItem.Id)
.ToList().First().HabiticaId;
habiticaClient.DeleteTask(habiticaId).ConfigureAwait(false).GetAwaiter().GetResult();
}
// store sync token
var todoistSync = new TodoistSync(giosUserId, response.Sync_token);
tableStorageClient.InsertOrUpdate(todoistSync).ConfigureAwait(false).GetAwaiter().GetResult();
}
public static string GetHabiticaDifficulty(int todoistDifficulty)
@@ -62,6 +113,21 @@ namespace Habitica.Todoist.Integration.Console
return null;
}
public static Task TaskFromTodoistItem(Item item, string id = null)
{
var taskTypeStr = Enum.GetName(typeof(TaskType), TaskType.Todo).ToLower();
var task = new Task
{
Id = id,
Text = item.Content,
Type = taskTypeStr,
Date = item.Due?.ToJavaScriptDateStr(),
Priority = GetHabiticaDifficulty(item.Priority)
};
return task;
}
static void ConfigBuild()
{
new ConfigurationBuilder()

View File

@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.Cosmos.Table" version="1.0.6" targetFramework="net472" />
<package id="Microsoft.Azure.DocumentDB.Core" version="2.1.3" targetFramework="net472" />
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net472" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net471" />
<package id="Microsoft.Bcl.Async" version="1.0.165" targetFramework="net471" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.0" targetFramework="net472" />
@@ -13,13 +16,75 @@
<package id="Microsoft.Extensions.FileSystemGlobbing" version="3.1.2" targetFramework="net472" />
<package id="Microsoft.Extensions.Primitives" version="3.1.2" targetFramework="net472" />
<package id="Microsoft.Net.Http" version="2.2.22" targetFramework="net471" />
<package id="Microsoft.NETCore.Platforms" version="1.0.1" targetFramework="net472" />
<package id="Microsoft.OData.Core" version="7.5.0" targetFramework="net472" />
<package id="Microsoft.OData.Edm" version="7.5.0" targetFramework="net472" />
<package id="Microsoft.Spatial" version="7.5.0" targetFramework="net472" />
<package id="Microsoft.Win32.Primitives" version="4.0.1" targetFramework="net472" />
<package id="NETStandard.Library" version="1.6.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="System.AppContext" version="4.1.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.0" targetFramework="net472" />
<package id="System.Collections" version="4.0.11" targetFramework="net472" />
<package id="System.Collections.Concurrent" version="4.0.12" targetFramework="net472" />
<package id="System.Collections.NonGeneric" version="4.0.1" targetFramework="net472" />
<package id="System.Collections.Specialized" version="4.0.1" targetFramework="net472" />
<package id="System.Console" version="4.0.0" targetFramework="net472" />
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="4.0.0" targetFramework="net472" />
<package id="System.Diagnostics.Tools" version="4.0.1" targetFramework="net472" />
<package id="System.Diagnostics.TraceSource" version="4.0.0" targetFramework="net472" />
<package id="System.Diagnostics.Tracing" version="4.1.0" targetFramework="net472" />
<package id="System.Dynamic.Runtime" version="4.0.11" targetFramework="net472" />
<package id="System.Globalization" version="4.0.11" targetFramework="net472" />
<package id="System.Globalization.Calendars" version="4.0.1" targetFramework="net472" />
<package id="System.IO" version="4.3.0" targetFramework="net472" />
<package id="System.IO.Compression" version="4.1.0" targetFramework="net472" />
<package id="System.IO.Compression.ZipFile" version="4.0.1" targetFramework="net472" />
<package id="System.IO.FileSystem" version="4.0.1" targetFramework="net472" />
<package id="System.IO.FileSystem.Primitives" version="4.0.1" targetFramework="net472" />
<package id="System.Linq" version="4.1.0" targetFramework="net472" />
<package id="System.Linq.Expressions" version="4.1.0" targetFramework="net472" />
<package id="System.Linq.Queryable" version="4.0.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.3" targetFramework="net472" />
<package id="System.Net.Http" version="4.1.0" targetFramework="net472" />
<package id="System.Net.NameResolution" version="4.0.0" targetFramework="net472" />
<package id="System.Net.NetworkInformation" version="4.1.0" targetFramework="net472" />
<package id="System.Net.Primitives" version="4.0.11" targetFramework="net472" />
<package id="System.Net.Requests" version="4.0.11" targetFramework="net472" />
<package id="System.Net.Security" version="4.3.2" targetFramework="net472" />
<package id="System.Net.Sockets" version="4.1.0" targetFramework="net472" />
<package id="System.Net.WebHeaderCollection" version="4.0.1" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.ObjectModel" version="4.0.12" targetFramework="net472" />
<package id="System.Reflection" version="4.1.0" targetFramework="net472" />
<package id="System.Reflection.Extensions" version="4.0.1" targetFramework="net472" />
<package id="System.Reflection.Primitives" version="4.0.1" targetFramework="net472" />
<package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="net472" />
<package id="System.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.0" targetFramework="net472" />
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net472" />
<package id="System.Runtime.Handles" version="4.0.1" targetFramework="net472" />
<package id="System.Runtime.InteropServices" version="4.1.0" targetFramework="net472" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" targetFramework="net472" />
<package id="System.Runtime.Numerics" version="4.0.1" targetFramework="net472" />
<package id="System.Runtime.Serialization.Primitives" version="4.1.1" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net472" />
<package id="System.Security.SecureString" version="4.0.0" targetFramework="net472" />
<package id="System.Text.Encoding" version="4.0.11" targetFramework="net472" />
<package id="System.Text.Encoding.Extensions" version="4.0.11" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="4.7.0" targetFramework="net472" />
<package id="System.Text.Json" version="4.7.1" targetFramework="net472" />
<package id="System.Text.RegularExpressions" version="4.1.0" targetFramework="net472" />
<package id="System.Threading" version="4.0.11" targetFramework="net472" />
<package id="System.Threading.Tasks" version="4.0.11" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net472" />
<package id="System.Threading.Timer" version="4.0.1" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
<package id="System.Xml.ReaderWriter" version="4.0.11" targetFramework="net472" />
<package id="System.Xml.XDocument" version="4.0.11" targetFramework="net472" />
<package id="WindowsAzure.Storage" version="9.3.3" targetFramework="net472" />
</packages>

View File

@@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Model.Habitica.Enums
{
public enum ScoreAction
{
Up = 0,
Down = 1
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Model.Habitica.Enums
{
public enum TaskType
{
Habit = 0,
Daily = 1,
Todo = 2,
Reward = 3
}
}

View File

@@ -0,0 +1,17 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Model.Habitica.Responses
{
public class HabiticaReponse<T>
{
[JsonProperty("success")]
public bool Success { get; set; }
[JsonProperty("data")]
public T Data { get; set; }
[JsonProperty("notifications")]
public object Notifications { get; set; }
}
}

View File

@@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Model.Habitica
{
public static class TaskType
{
public static string Habit = "habit";
public static string Daily = "daily";
public static string Todo = "todo";
public static string Reward = "reward";
}
}

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Model.Storage
namespace Habitica.Todoist.Integration.Model.Storage.Enum
{
public enum TodoAction
{

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Model.Storage
namespace Habitica.Todoist.Integration.Model.Storage.Enum
{
public enum TodoApp
{

View File

@@ -1,12 +1,26 @@
using System;
using Microsoft.Azure.Cosmos.Table;
using System;
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Model.Storage
{
public class HabitTodoLink
public class HabitTodoLink : TableEntity
{
public string HabiticaId { get; set; }
public HabitTodoLink() { }
public HabitTodoLink(string userId, string habiticaId, string todoistId)
{
PartitionKey = userId;
RowKey = habiticaId;
TodoistId = todoistId;
}
public string TodoistId { get; set; }
public TodoHabitLink Reverse()
{
return new TodoHabitLink(PartitionKey, TodoistId, RowKey);
}
}
}

View File

@@ -1,12 +1,22 @@
using System;
using Habitica.Todoist.Integration.Model.Storage.Enum;
using Microsoft.Azure.Cosmos.Table;
using System;
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Model.Storage
{
public class TodoChange
/* TODO: Rework structure */
public class TodoChange : TableEntity
{
public string Id { get; set; }
public TodoChange() { }
public TodoChange(string userId, string todoId)
{
PartitionKey = userId;
RowKey = todoId;
}
public TodoApp Application { get; set; }
public TodoAction Action { get; set; }
public bool Applied { get; set; }

View File

@@ -1,12 +1,26 @@
using System;
using Microsoft.Azure.Cosmos.Table;
using System;
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Model.Storage
{
public class TodoHabitLink
public class TodoHabitLink : TableEntity
{
public string TodoistId { get; set; }
public TodoHabitLink() { }
public TodoHabitLink(string userId, string todoistId, string habiticaId)
{
PartitionKey = userId;
RowKey = todoistId;
HabiticaId = habiticaId;
}
public string HabiticaId { get; set; }
public HabitTodoLink Reverse()
{
return new HabitTodoLink(PartitionKey, HabiticaId, RowKey);
}
}
}

View File

@@ -1,11 +1,18 @@
using System;
using Microsoft.Azure.Cosmos.Table;
using System;
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Model.Storage
{
public class TodoistSync
public class TodoistSync : TableEntity
{
public string SyncToken { get; set; }
public TodoistSync() { }
public TodoistSync(string userId, string syncToken)
{
PartitionKey = userId;
RowKey = syncToken;
}
}
}

View File

@@ -6,27 +6,17 @@ namespace Habitica.Todoist.Integration.Model.Todoist
{
public class Item
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("content")]
public string Content { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("due")]
public Due Due { get; set; }
[JsonProperty("priority")]
public int Priority { get; set; }
[JsonProperty("is_deleted")]
public int Is_deleted { get; set; }
[JsonProperty("date_completed")]
public string Date_completed { get; set; }
public int? GetDifficulty()
{
try { return int.Parse(Content.Split('-').Last().Last().ToString()); } catch { }
return null;
}
public string GetCleanContent()
{
try { return Content.Split('-').First(); } catch { }
return null;
}
}
}

View File

@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Model.Todoist
namespace Habitica.Todoist.Integration.Model.Todoist.Responses
{
public class SyncResponse
{
@@ -11,7 +11,7 @@ namespace Habitica.Todoist.Integration.Model.Todoist
public string Sync_token { get; set; }
[JsonProperty("full_sync")]
public bool Full_sync { get; set; }
[JsonProperty("itmes")]
[JsonProperty("items")]
public List<Item> Items { get; set; }
}
}

View File

@@ -1,23 +0,0 @@
using Habitica.Todoist.Integration.Model.Storage;
using Microsoft.Azure.Cosmos.Table;
using System;
using System.Collections.Generic;
using System.Text;
namespace Habitica.Todoist.Integration.Services
{
public class HabitTodoStorageClient
{
private CloudStorageAccount storageAccount { get; set; }
public HabitTodoStorageClient(string connectionString)
{
this.storageAccount = CloudStorageAccount.Parse(connectionString);
}
//public TodoLink CreateTodoLink(TodoLink todoLink)
//{
// return null;
//}
}
}

View File

@@ -1,45 +0,0 @@
using HabiticaTask = Habitica.Todoist.Integration.Model.Habitica.Task;
using System;
using System.Net;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Habitica.Todoist.Integration.Services
{
public class HabiticaClientService
{
private string userId { get; set; }
private string apiKey { get; set; }
private string baseUrl => "https://habitica.com/api/v3/";
public HabiticaClientService(string userId, string apiKey)
{
this.userId = userId;
this.apiKey = apiKey;
}
public async Task<HabiticaTask> CreateUserTask(HabiticaTask task)
{
using (var client = CreateWebClient())
{
var request = JsonConvert.SerializeObject(task);
var json = await client.UploadStringTaskAsync($"{baseUrl}/tasks/user", "POST", request);
return JsonConvert.DeserializeObject<HabiticaTask>(json);
}
}
private WebClient CreateWebClient()
{
var client = new WebClient();
client.Headers[HttpRequestHeader.ContentType] = "application/json";
client.Headers["x-api-user"] = userId;
client.Headers["x-api-key"] = apiKey;
client.Headers["x-client"] = "dotnet-habitica-client";
return client;
}
}
}

View File

@@ -0,0 +1,85 @@
using HabiticaTask = Habitica.Todoist.Integration.Model.Habitica.Task;
using System.Net;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Collections.Generic;
using Habitica.Todoist.Integration.Model.Habitica.Responses;
using Habitica.Todoist.Integration.Model.Habitica.Enums;
using System;
namespace Habitica.Todoist.Integration.Services
{
public class HabiticaServiceClient
{
private string userId { get; set; }
private string apiKey { get; set; }
private string baseUrl => "https://habitica.com/api/v3/";
public HabiticaServiceClient(string userId, string apiKey)
{
this.userId = userId;
this.apiKey = apiKey;
}
public async Task<HabiticaReponse<HabiticaTask>> CreateTask(HabiticaTask task)
{
using (var client = CreateWebClient())
{
var request = JsonConvert.SerializeObject(task);
var json = await client.UploadStringTaskAsync($"{baseUrl}/tasks/user", "POST", request);
return JsonConvert.DeserializeObject<HabiticaReponse<HabiticaTask>>(json);
}
}
public async Task<HabiticaReponse<List<HabiticaTask>>> ReadTasks(TaskType taskType = TaskType.Todo)
{
var taskTypeStr = Enum.GetName(taskType.GetType(), taskType).ToLower();
using (var client = CreateWebClient())
{
var json = await client.DownloadStringTaskAsync($"{baseUrl}/tasks/user");
var response = JsonConvert.DeserializeObject<HabiticaReponse<List<HabiticaTask>>>(json);
response.Data.RemoveAll(x => x.Type != taskTypeStr);
return response;
}
}
public async Task<HabiticaTask> UpdateTask(HabiticaTask task)
{
using (var client = CreateWebClient())
{
var request = JsonConvert.SerializeObject(task);
var json = await client.UploadStringTaskAsync($"{baseUrl}/tasks/{task.Id}", "PUT", request);
return JsonConvert.DeserializeObject<HabiticaTask>(json);
}
}
public async Task DeleteTask(string taskId)
{
using (var client = CreateWebClient())
await client.UploadStringTaskAsync($"{baseUrl}/tasks/{taskId}", "DELETE", "");
}
public async Task ScoreTask(string taskId, ScoreAction action)
{
var actionStr = Enum.GetName(action.GetType(), action).ToLower();
using (var client = CreateWebClient())
await client.UploadStringTaskAsync($"{baseUrl}/tasks/{taskId}/score/{actionStr}", "POST", "");
}
private WebClient CreateWebClient()
{
var client = new WebClient();
client.Headers[HttpRequestHeader.ContentType] = "application/json";
client.Headers["x-api-user"] = userId;
client.Headers["x-api-key"] = apiKey;
client.Headers["x-client"] = "dotnet-habitica-client";
return client;
}
}
}

View File

@@ -0,0 +1,83 @@
using Habitica.Todoist.Integration.Model.Storage;
using Microsoft.Azure.Cosmos.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Habitica.Todoist.Integration.Services
{
public class TableStorageClient
{
private CloudStorageAccount storageAccount { get; set; }
private CloudTableClient tableClient { get; set; }
/* TODO: change this so it reads from classes available instead of hardcoding */
private static List<string> tableNames = new List<string>()
{
"habittodolink",
"todohabitlink",
"todochange",
"todoistsync"
};
private Dictionary<string, CloudTable> tables = new Dictionary<string, CloudTable>();
public TableStorageClient(string connectionString)
{
storageAccount = CloudStorageAccount.Parse(connectionString);
tableClient = storageAccount.CreateCloudTableClient(new TableClientConfiguration());
// initialize all tables to use
foreach (var tableName in tableNames)
{
var table = tableClient.GetTableReference(tableName);
table.CreateIfNotExists();
tables[tableName] = table;
}
}
public async Task<T> InsertOrUpdate<T>(T entity) where T : TableEntity, new()
{
var tableName = typeof(T).Name.ToLower();
var table = tables[tableName];
var operation = TableOperation.InsertOrReplace(entity); // TODO: InsertOrReplace vs InsertOrMerge
var result = await table.ExecuteAsync(operation);
return result.Result as T;
}
public async Task<bool> Exists<T>(string partitionKey, string rowKey) where T : TableEntity, new()
{
var tableName = typeof(T).Name.ToLower();
var table = tables[tableName];
var operation = TableOperation.Retrieve(partitionKey, rowKey);
var result = await table.ExecuteAsync(operation);
return result.Result != null;
}
//public async Task<List<T>> Read<T>(string partitionKey, string rowKey) where T : TableEntity
//{
// var tableName = typeof(T).Name.ToLower();
// var table = tables[tableName];
// var operation = TableOperation.Retrieve(partitionKey, rowKey);
// var result = await table.ExecuteAsync(operation);
// return result.Result != null;
//}
public TableQuery<T> Query<T>() where T : TableEntity, new()
{
var tableName = typeof(T).Name.ToLower();
var table = tables[tableName];
return table.CreateQuery<T>();
}
}
}

View File

@@ -1,4 +1,5 @@
using Habitica.Todoist.Integration.Model.Todoist;
using Habitica.Todoist.Integration.Model.Todoist.Responses;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -8,18 +9,21 @@ using System.Threading.Tasks;
namespace Habitica.Todoist.Integration.Services
{
public class TodoistClientService
public class TodoistServiceClient
{
private string apiKey { get; set; }
private string baseUrl => "https://api.todoist.com/sync/v8/";
public TodoistClientService(string apiKey)
public TodoistServiceClient(string apiKey)
{
this.apiKey = apiKey;
}
public async Task<SyncResponse> GetUpdatedItems(string syncToken = "*")
public async Task<SyncResponse> GetChangedItems(string syncToken = null)
{
if (string.IsNullOrEmpty(syncToken))
syncToken = "*";
using (var client = CreateWebClient())
{
var body = InitializeRequestBody();