-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Info/GetEntryTags of the new API #45
- Loading branch information
Showing
11 changed files
with
154 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Azuria.Api.v1.DataModels.Info; | ||
|
||
namespace Azuria.AnimeManga.Properties | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public class Tag | ||
{ | ||
internal Tag(EntryTagDataModel dataModel) | ||
{ | ||
this.TagType = dataModel.Tag; | ||
this.IsRated = dataModel.IsRated; | ||
this.IsSpoiler = dataModel.IsSpoiler; | ||
} | ||
|
||
#region Properties | ||
|
||
/// <summary> | ||
/// </summary> | ||
public bool IsRated { get; set; } | ||
|
||
/// <summary> | ||
/// </summary> | ||
public bool IsSpoiler { get; set; } | ||
|
||
/// <summary> | ||
/// </summary> | ||
public TagType TagType { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace Azuria.Api.v1.Converters | ||
{ | ||
internal class IntToBoolConverter : JsonConverter | ||
{ | ||
#region | ||
|
||
/// <summary> | ||
/// Determines whether this instance can convert the specified object type. | ||
/// </summary> | ||
/// <param name="objectType">Type of the object.</param> | ||
/// <returns> | ||
/// <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>. | ||
/// </returns> | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(int); | ||
} | ||
|
||
/// <summary>Reads the JSON representation of the object.</summary> | ||
/// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param> | ||
/// <param name="objectType">Type of the object.</param> | ||
/// <param name="existingValue">The existing value of object being read.</param> | ||
/// <param name="serializer">The calling serializer.</param> | ||
/// <returns>The object value.</returns> | ||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, | ||
JsonSerializer serializer) | ||
{ | ||
return Convert.ToInt32(reader.Value) == 1; | ||
} | ||
|
||
/// <summary>Writes the JSON representation of the object.</summary> | ||
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param> | ||
/// <param name="value">The value.</param> | ||
/// <param name="serializer">The calling serializer.</param> | ||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
writer.WriteValue((bool) value ? 1 : 0); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Azuria.AnimeManga.Properties; | ||
using Azuria.Api.v1.Converters; | ||
using Newtonsoft.Json; | ||
|
||
namespace Azuria.Api.v1.DataModels.Info | ||
{ | ||
internal class EntryTagDataModel : IDataModel | ||
{ | ||
#region Properties | ||
|
||
[JsonProperty("id")] | ||
internal int Id { get; set; } | ||
|
||
[JsonProperty("rate_flag"), JsonConverter(typeof(IntToBoolConverter))] | ||
internal bool IsRated { get; set; } | ||
|
||
[JsonProperty("spoiler_flag"), JsonConverter(typeof(IntToBoolConverter))] | ||
internal bool IsSpoiler { get; set; } | ||
|
||
[JsonProperty("tid")] | ||
internal TagType Tag { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters