wip: finish converting some more projects
This commit is contained in:
@@ -5,4 +5,15 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Habittodo.Data\Habittodo.Data.csproj" />
|
||||
<ProjectReference Include="..\Habittodo.Model\Habittodo.Model.csproj" />
|
||||
<ProjectReference Include="..\Habittodo.Service\Habittodo.Service.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,12 +1,56 @@
|
||||
using System;
|
||||
using Habittodo.Data;
|
||||
using Habittodo.Model.Storage;
|
||||
using Habittodo.Service;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Habittodo.Console
|
||||
namespace Habitica.Todoist.Integration.Console
|
||||
{
|
||||
class Program
|
||||
{
|
||||
private static IConfiguration configuration { get; set; }
|
||||
|
||||
private static string habiticaUserId => configuration["habitica:userId"];
|
||||
private static string habiticaApiKey => configuration["habitica:apiKey"];
|
||||
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)
|
||||
{
|
||||
System.Console.WriteLine("Hello World!");
|
||||
ConfigBuild();
|
||||
|
||||
// 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.GetItemChanges(syncToken).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
var changedItems = response.Items;
|
||||
|
||||
/* TESTING */
|
||||
|
||||
// store sync token
|
||||
var todoistSync = new TodoistSync(giosUserId, response.Sync_token);
|
||||
tableStorageClient.InsertOrUpdate(todoistSync).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
static void ConfigBuild()
|
||||
{
|
||||
new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("secrets.json");
|
||||
|
||||
configuration = new ConfigurationBuilder()
|
||||
.AddJsonFile("secrets.json", true, true)
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user