Fleshed out the table storage service and started syncing logic
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
@@ -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
|
||||
{
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user