Skip to content

Update the API to v1.4 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions License.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Copyright (c) 2012, Daniel Widegren daniel@widegren.org
Copyright (c) 2012, Daniel Widegren <daniel@widegren.org>
Copyright (c) 2015, Iris Ward <aditu.venyhandottir@gmail.com>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
5 changes: 3 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## C-Sharp-API-Client
This is a simple API Client for WaniKani to speed up projects written in .NET
Current API version is 1.1
Current API version is 1.4

Copyright (c) 2012, Daniel Widegren
All code is licensed under the MIT License, Please read License.txt for more information.
Copyright (c) 2015, Iris Ward
All code is licensed under the ISC License, Please read License.txt for more information.

## How to use:
Include the dll or code into your project.
Expand Down
4 changes: 2 additions & 2 deletions WaniKaniApp.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaniKaniClientDemo", "WaniKaniApp\WaniKaniClientDemo.csproj", "{AC47E8F6-4436-4FFF-AF3D-F3F7A538696F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaniKaniClientLib", "WaniKaniClient\WaniKaniClientLib.csproj", "{6546956C-826B-4A5C-B639-A0F909C68F31}"
Expand Down
20 changes: 2 additions & 18 deletions WaniKaniClient/Models/BaseCharacter.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace WaniKaniClientLib.Models
{
Expand All @@ -13,19 +9,7 @@ public class BaseCharacter
public string Meaning { get; set; }
public int Level { get; set; }

[JsonProperty("unlocked_date")]
public long UnlockTimeStamp { get; set; }
public DateTime UnlockedDate
{
get
{
var date = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return date.AddSeconds(UnlockTimeStamp);
}
}

public string Percentage { get; set; }

[JsonProperty("user_specific")]
public Stats Stats { get; set; }
}
}
9 changes: 3 additions & 6 deletions WaniKaniClient/Models/Kanji.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace WaniKaniClientLib.Models
{
Expand All @@ -14,7 +10,8 @@ public Kanji()
}

public string Onyomi { get; set; }
public string kunyomi { get; set; }
public string Kunyomi { get; set; }
public string Nanori { get; set; }

[JsonProperty("important_reading")]
public string ImportantReading { get; set; }
Expand Down
6 changes: 1 addition & 5 deletions WaniKaniClient/Models/LevelProgression.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace WaniKaniClientLib.Models
{
Expand Down
7 changes: 1 addition & 6 deletions WaniKaniClient/Models/Radical.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WaniKaniClientLib.Models
namespace WaniKaniClientLib.Models
{
public class Radical : BaseCharacter
{
Expand Down
7 changes: 1 addition & 6 deletions WaniKaniClient/Models/SrsDistribution.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WaniKaniClientLib.Models
namespace WaniKaniClientLib.Models
{
public class SrsDistribution
{
Expand Down
7 changes: 1 addition & 6 deletions WaniKaniClient/Models/SrsDistributionItem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WaniKaniClientLib.Models
namespace WaniKaniClientLib.Models
{
public class SrsDistributionItem
{
Expand Down
30 changes: 21 additions & 9 deletions WaniKaniClient/Models/Stats.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using WaniKaniClientLib.Utils;

namespace WaniKaniClientLib.Models
{
public class Stats
{
public string Srs { get; set; }

// The precise stage of SRS the learning item is currently at.
// Stages 1 to 4 fall within "Apprentice"; stages 5 & 6 are "Guru";
// Stages 7, 8 and 9 are "Master", "Enlightened" and "Burned"
// respectively
[JsonProperty("srs_numeric")]
public int SrsLevel { get; set; }

public bool Burned { get; set; }

[JsonProperty("meaning_correct")]
Expand Down Expand Up @@ -44,8 +50,7 @@ public DateTime? UnlockedDate
if (UnlockedTimeStamp == 0)
return null;

var date = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return date.AddSeconds(UnlockedTimeStamp);
return Utilities.UnixEpoch.AddSeconds(UnlockedTimeStamp);
}
}

Expand All @@ -58,8 +63,7 @@ public DateTime? AvailableDate
if (AvailableTimeStamp == 0)
return null;

var date = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return date.AddSeconds(AvailableTimeStamp);
return Utilities.UnixEpoch.AddSeconds(AvailableTimeStamp);
}
}

Expand All @@ -72,10 +76,18 @@ public DateTime? BurnedDate
if (BurnedTimeStamp == 0)
return null;

var date = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return date.AddSeconds(BurnedTimeStamp);
return Utilities.UnixEpoch.AddSeconds(BurnedTimeStamp);
}
}

[JsonProperty("meaning_note")]
public string MeaningNote { get; set; }

[JsonProperty("reading_note")]
public string ReadingNote { get; set; }

[JsonProperty("user_synonyms")]
public string UserSynonyms { get; set; }

}
}
7 changes: 2 additions & 5 deletions WaniKaniClient/Models/StudyQueue.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using WaniKaniClientLib.Utils;

namespace WaniKaniClientLib.Models
{
Expand All @@ -20,8 +18,7 @@ public DateTime NextReviewDate
{
get
{
var date = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return date.AddSeconds(NextReviewTimeStamp);
return Utilities.UnixEpoch.AddSeconds(NextReviewTimeStamp);
}
}

Expand Down
24 changes: 18 additions & 6 deletions WaniKaniClient/Models/UserInformation.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using WaniKaniClientLib.Utils;

namespace WaniKaniClientLib.Models
{
Expand All @@ -24,14 +22,28 @@ public class UserInformation

[JsonProperty("creation_date")]
public long CreationTimeStamp { get; set; }
public DateTime CreatioDate
public DateTime CreationDate
{
get
{
var date = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return date.AddSeconds(CreationTimeStamp);
return Utilities.UnixEpoch.AddSeconds(CreationTimeStamp);
}
}

// We have to use a nullable long here as the vacation date is passed as "null" in the API
// if the user is not on vacation, rather than being omitted as in learning items
[JsonProperty("vacation_date")]
public long? VacationTimeStamp { get; set; }
public DateTime? VacationDate
{
get
{
if (VacationTimeStamp.HasValue)
{
return Utilities.UnixEpoch.AddSeconds(VacationTimeStamp.Value);
}
return null;
}
}
}
}
7 changes: 1 addition & 6 deletions WaniKaniClient/Models/Vocabulary.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WaniKaniClientLib.Models
namespace WaniKaniClientLib.Models
{
public class Vocabulary : BaseCharacter
{
Expand Down
9 changes: 9 additions & 0 deletions WaniKaniClient/Utils/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace WaniKaniClientLib.Utils
{
internal static class Utilities
{
public static DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
}
}
3 changes: 2 additions & 1 deletion WaniKaniClient/WaniKaniClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace WaniKaniClientLib
public class WaniKaniClient
{
public string APIKey { get; private set; }
public static readonly string ApiVersion = "v1.1";
public static readonly string ApiVersion = "v1.4";
public int CacheInMinutes { get; set; }

private UserInformation _cachedUserInformation;
Expand Down Expand Up @@ -262,6 +262,7 @@ private string BuildUrl(string resource = null, string optionalArgument = null)
private JObject Request(string resource = null, string optionalArgument = null)
{
WebClient httpClient = new WebClient();
httpClient.Encoding = Encoding.UTF8;
string responce = httpClient.DownloadString(BuildUrl(resource, optionalArgument));

return JObject.Parse(responce);
Expand Down
1 change: 1 addition & 0 deletions WaniKaniClient/WaniKaniClientLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<Compile Include="Models\StudyQueue.cs" />
<Compile Include="Models\UserInformation.cs" />
<Compile Include="Models\Vocabulary.cs" />
<Compile Include="Utils\Extensions.cs" />
<Compile Include="WaniKaniClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down