Skip to content

Commit

Permalink
Merge pull request #64 from micah686/Api-Update
Browse files Browse the repository at this point in the history
Api update
  • Loading branch information
Nikey646 authored Aug 22, 2020
2 parents ff383f1 + e88355e commit 4c27746
Show file tree
Hide file tree
Showing 24 changed files with 383 additions and 12 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: .NET Core

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
- name: Install dependencies
run: dotnet restore
- name: Build VndbSharp
run: |
mkdir ${{ github.workspace }}/build
dotnet build VndbSharp/VndbSharp.csproj -c Release -o --output "${{ github.workspace }}/build"
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: VndbSharp
path: "${{ github.workspace }}/build/"
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ To build the project you need to use Visual Studio 2017 RC3 or newer.
There is no guarantee that anything listed on this will be implemented.

- [ ] Work on the Read Me
- [ ] Provide a default RequestOptions class
- [X] Provide a default RequestOptions class
- [ ] ~~Wiki everything!~~ Document everything (public)!
- [ ] Nuget package?
- [ ] Nuget package (Github actions now builds a version of VndbSharp)

## API Version
Updated to Vndb 2020-07-09 API version
"set ulist" has not been added, because it is experimental
12 changes: 12 additions & 0 deletions VndbConsoleCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public async Task MainAsync(String[] args)
// await this.GetVoteListAsync();
// await this.GetVisualNovelListAsync();
// await this.GetWishlistAsync();
// await this.GetUserListAsync();

// await this.GetFilterExampleAsync();
// await this.GetInvalidFlagsExampleAsync();
Expand Down Expand Up @@ -465,6 +466,17 @@ public async Task GetWishlistAsync()
Console.WriteLine();
}

public async Task GetUserListAsync()
{
var userList = await this._client.GetUserListAsync(VndbFilters.UserId.Equals(0), VndbFlags.FullUserList);

if (userList == null)
{
this.HandleError(this._client.GetLastError());
return; // End method
}
}

// TODO: WIP
public async Task GetFilterExampleAsync()
{
Expand Down
3 changes: 3 additions & 0 deletions VndbSharp/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ internal static class Constants
public const String GetVotelistCommand = "get votelist";
public const String GetVisualNovelListCommand = "get vnlist";
public const String GetWishlistCommand = "get wishlist";
public const String GetUserListCommand = "get ulist";
public const String GetUserListLabelsCommand = "get ulist-labels";
public const String GetStaffCommand = "get staff";
#endregion

#region . Set commands .
public const String SetVotelistCommand = "set votelist";
public const String SetVisualNovelListCommand = "set vnlist";
public const String SetWishlistCommand = "set wishlist";
public const String SetUserListCommand = "set ulist";
#endregion

#region . Result values .
Expand Down
2 changes: 1 addition & 1 deletion VndbSharp/Json/VndbContractResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected override JsonProperty CreateProperty(MemberInfo member, MemberSerializ
#endif

// Need to use JsonProperty.MemberConverter here, not JsonProperty.Converter. Not entirely sure why :s
if (property.HasAttribute<IsUnixTimestampAttribute>() && prop.PropertyType == typeof(DateTime))
if (property.HasAttribute<IsUnixTimestampAttribute>() && (prop.PropertyType == typeof(DateTime)) || (prop.PropertyType == typeof(DateTime?)))
prop.MemberConverter = VndbContractResolver.UnixConverter;

if (property.HasAttribute<IsCsvAttribute>())
Expand Down
12 changes: 12 additions & 0 deletions VndbSharp/Models/Character/BloodType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@
{
public enum BloodType
{
/// <summary>
/// Blood Type A
/// </summary>
A,
/// <summary>
/// Blood Type B
/// </summary>
B,
/// <summary>
/// Blood Type AB
/// </summary>
AB,
/// <summary>
/// Blood Type O
/// </summary>
O
}
}
58 changes: 52 additions & 6 deletions VndbSharp/Models/Character/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,59 @@

namespace VndbSharp.Models.Character
{
/// <summary>
/// Base information about a specific character
/// </summary>
public class Character
{
/// <summary>
/// Character's ID on Vndb
/// </summary>
public UInt32 Id { get; private set; }
/// <summary>
/// Character's Name
/// </summary>
public String Name { get; private set; }
/// <summary>
/// Character's Japanese/Original Name
/// </summary>
[JsonProperty("original")]
public String OriginalName { get; private set; }
public Gender? Gender { get; private set; }
/// <summary>
/// Character's Gender
/// </summary>
public Gender? Gender { get; private set; }
/// <summary>
/// Character's Gender
/// </summary>
[JsonProperty("bloodt")]
public BloodType? BloodType { get; private set; }
public SimpleDate Birthday { get; private set; }
// [JsonConverter(typeof(CommaSeparatedValueConverter<String>))]
[IsCsv]
/// <summary>
/// Character's Birthday
/// </summary>
public SimpleDate Birthday { get; private set; }
/// <summary>
/// Character's Aliases/Nicknames
/// </summary>
[IsCsv]
public ReadOnlyCollection<String> Aliases { get; private set; }
/// <summary>
/// Description of the character
/// </summary>
public String Description { get; private set; }
/// <summary>
/// Url Image of the character
/// </summary>
public String Image { get; private set; }
/// <summary>
/// Properties of the character's image. This determines how violent/sexual it is
/// </summary>
[JsonProperty("image_flagging")]
public ImageRating ImageRating { get; private set; }
/// <summary>
/// Size in Centimeters
/// </summary>
public Int64? Bust { get; private set; }
public Int64? Bust { get; private set; }
/// <summary>
/// Size in Centimeters
/// </summary>
Expand All @@ -41,11 +75,23 @@ public class Character
/// Weight in Kilograms
/// </summary>
public Int64? Weight { get; private set; }
/// <summary>
/// List of traits the character has
/// </summary>
public ReadOnlyCollection<TraitMetadata> Traits { get; private set; }
/// <summary>
/// List of Visual Novels linked to this character
/// </summary>
[JsonProperty("vns")]
public ReadOnlyCollection<VisualNovelMetadata> VisualNovels { get; private set; }
[JsonProperty("voiced")]
/// <summary>
/// List of voice actresses (staff) that voiced this character, per VN
/// </summary>
[JsonProperty("voiced")]
public ReadOnlyCollection<VoiceActorMetadata> VoiceActorMetadata { get; private set; }
/// <summary>
/// List of instances of this character (excluding the character entry itself)
/// </summary>
[JsonProperty("instances")]
public ReadOnlyCollection<CharacterInstances> CharacterInstances { get; private set; }
}
Expand Down
15 changes: 15 additions & 0 deletions VndbSharp/Models/Character/CharacterInstances.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@

namespace VndbSharp.Models.Character
{
/// <summary>
/// List of instances of a character
/// </summary>
public class CharacterInstances
{
/// <summary>
/// Character Id
/// </summary>
public Int32 Id { get; private set; }
/// <summary>
/// Spoiler level
/// </summary>
public SpoilerLevel Spoiler { get; private set; }
/// <summary>
/// Character's Name
/// </summary>
public String Name { get; private set; }
/// <summary>
/// Character's Original/Japanese Name
/// </summary>
[JsonProperty("original")]
public String Kanji { get; private set; }
}
Expand Down
15 changes: 15 additions & 0 deletions VndbSharp/Models/Character/CharacterRole.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
namespace VndbSharp.Models.Character
{
/// <summary>
/// Roles a Character may take
/// </summary>
public enum CharacterRole
{
/// <summary>
/// Main Character
/// </summary>
Main = 0,
/// <summary>
/// Primary Character
/// </summary>
Primary = 1,
/// <summary>
/// Side Character
/// </summary>
Side = 2,
/// <summary>
/// Makes an Appearance
/// </summary>
Appears = 3,
}
}
9 changes: 9 additions & 0 deletions VndbSharp/Models/Character/TraitMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace VndbSharp.Models.Character
{
/// <summary>
/// Metadata about a particular Trait
/// </summary>
public class TraitMetadata
{
internal TraitMetadata(JArray array)
Expand All @@ -12,7 +15,13 @@ internal TraitMetadata(JArray array)
this.SpoilerLevel = (SpoilerLevel) array[1].Value<Int32>();
}

/// <summary>
/// Trait ID
/// </summary>
public UInt32 Id { get; private set; }
/// <summary>
/// Spoiler level of Trait
/// </summary>
public SpoilerLevel SpoilerLevel { get; private set; }
}
}
15 changes: 15 additions & 0 deletions VndbSharp/Models/Character/VisualNovelMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace VndbSharp.Models.Character
{
/// <summary>
/// Metadata about a VN
/// </summary>
public class VisualNovelMetadata
{
internal VisualNovelMetadata(UInt32 Id, UInt32 ReleaseId, SpoilerLevel spoilerLevel, CharacterRole characterRole)
Expand All @@ -22,9 +25,21 @@ internal VisualNovelMetadata(JArray array)
this.Role = (CharacterRole) Enum.Parse(typeof(CharacterRole), array[3].Value<String>(), true);
}

/// <summary>
/// Visual Novel ID
/// </summary>
public UInt32 Id { get; private set; }
/// <summary>
/// Visual Novel Release ID
/// </summary>
public UInt32 ReleaseId { get; private set; }
/// <summary>
/// Visual Novel Spoiler Level
/// </summary>
public SpoilerLevel SpoilerLevel { get; private set; }
/// <summary>
/// Character Role
/// </summary>
public CharacterRole Role { get; private set; }
}
}
15 changes: 15 additions & 0 deletions VndbSharp/Models/Character/VoiceActorMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@

namespace VndbSharp.Models.Character
{
/// <summary>
/// Metadata about a voice actor
/// </summary>
public class VoiceActorMetadata
{
/// <summary>
/// Staff Id
/// </summary>
[JsonProperty("id")]
public Int32 StaffId { get; private set; }
/// <summary>
/// Staff Alias ID
/// </summary>
[JsonProperty("aid")]
public Int32 AliasId { get; private set; }
/// <summary>
/// Visual Novel ID
/// </summary>
[JsonProperty("vid")]
public Int32 VisualNovelId { get; private set; }
/// <summary>
/// Notes
/// </summary>
public String Note { get; private set; }
}
}
1 change: 1 addition & 0 deletions VndbSharp/Models/Common/CommonLinks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace VndbSharp.Models.Common
{
public class CommonLinks
{
[Obsolete("Use WikiData instead")]
[JsonProperty("wikipedia")]
public String Wikipedia { get; private set; }
}
Expand Down
19 changes: 19 additions & 0 deletions VndbSharp/Models/Common/ImageRating.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace VndbSharp.Models.Common
{
public class ImageRating
{
[JsonProperty("votecount")]
public int VoteCount { get; private set; }
[JsonProperty("sexual_avg")]
public double? SexualAvg { get; private set; }
[JsonProperty("violence_avg")]
public double? ViolenceAvg { get; private set; }
}
}
Loading

0 comments on commit 4c27746

Please sign in to comment.