-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added GetPublishedFileDetails endpoint.
* A custom converter is used to convert the response's awful tag format (list of dictionaries) to a list of the values of the dictionary. This seems to be safe because I've only seen the response be formatted in such way, with the keys always being the string "tag". * An itemcount greater than the size of the list of file ids will return null; processing the request would lead to HTTP 400 anyway. * Only the outer result value is accounted for, returning null when it is not equal to 1 i.e. k_EResultOK (Success). However, it seems to always be 1 anyway. * The inner result value i.e. inside publishedfiledetails is not checked. Therefore, every property of a given details object, excluding publishedfileid and result, may be null if the request fails (the JSON deserialiser is configured to ignore missing members). * These changes requires Steam.Models to include objects to map to: PublishedFileDetailsModel and enum PublishedFileVisibility.
- Loading branch information
Showing
5 changed files
with
191 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
105 changes: 105 additions & 0 deletions
105
src/SteamWebAPI2/Models/PublishedFileDetailsResultContainer.cs
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,105 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Newtonsoft.Json; | ||
|
||
namespace SteamWebAPI2.Models | ||
{ | ||
using SteamWebAPI2.Utilities.JsonConverters; | ||
|
||
internal class PublishedFileDetailsResultContainer | ||
{ | ||
[JsonProperty("response")] | ||
public PublishedFileDetailsResult Result { get; set; } | ||
} | ||
|
||
internal class PublishedFileDetailsResult | ||
{ | ||
[JsonProperty("result")] | ||
public uint Result { get; set; } | ||
|
||
[JsonProperty("resultcount")] | ||
public uint Count { get; set; } | ||
|
||
[JsonProperty("publishedfiledetails")] | ||
public IList<PublishedFileDetails> Details { get; set; } | ||
} | ||
|
||
internal class PublishedFileDetails | ||
{ | ||
[JsonProperty("publishedfileid")] | ||
public ulong PublishedFileId { get; set; } | ||
|
||
[JsonProperty("result")] | ||
public uint Result { get; set; } | ||
|
||
[JsonProperty("creator")] | ||
public ulong Creator { get; set; } | ||
|
||
[JsonProperty("creator_app_id")] | ||
public uint CreatorAppId { get; set; } | ||
|
||
[JsonProperty("consumer_app_id")] | ||
public uint ConsumerAppId { get; set; } | ||
|
||
[JsonProperty("filename")] | ||
public string FileName { get; set; } | ||
|
||
[JsonProperty("file_size")] | ||
public uint FileSize { get; set; } | ||
|
||
[JsonProperty("file_url")] | ||
public string FileUrl { get; set; } | ||
|
||
[JsonProperty("hcontent_file")] | ||
public ulong FileContentHandle { get; set; } | ||
|
||
[JsonProperty("preview_url")] | ||
public string PreviewUrl { get; set; } | ||
|
||
[JsonProperty("hcontent_preview")] | ||
public ulong PreviewContentHandle { get; set; } | ||
|
||
[JsonProperty("title")] | ||
public string Title { get; set; } | ||
|
||
[JsonProperty("description")] | ||
public string Description { get; set; } | ||
|
||
[JsonProperty("time_created")] | ||
[JsonConverter(typeof(UnixTimeJsonConverter))] | ||
public DateTime TimeCreated { get; set; } | ||
|
||
[JsonProperty("time_updated")] | ||
[JsonConverter(typeof(UnixTimeJsonConverter))] | ||
public DateTime TimeUpdated { get; set; } | ||
|
||
[JsonProperty("visibility")] | ||
public uint Visibility { get; set; } | ||
|
||
[JsonProperty("banned")] | ||
public bool Banned { get; set; } | ||
|
||
[JsonProperty("ban_reason")] | ||
public string BanReason { get; set; } | ||
|
||
[JsonProperty("subscriptions")] | ||
public ulong Subscriptions { get; set; } | ||
|
||
[JsonProperty("favorited")] | ||
public ulong Favorited { get; set; } | ||
|
||
[JsonProperty("lifetime_subscriptions")] | ||
public ulong LifetimeSubscriptions { get; set; } | ||
|
||
[JsonProperty("lifetime_favorited")] | ||
public ulong LifetimeFavorited { get; set; } | ||
|
||
[JsonProperty("views")] | ||
public ulong Views { get; set; } | ||
|
||
[JsonProperty("tags")] | ||
[JsonConverter(typeof(TagsJsonConverter))] | ||
public IList<string> Tags { get; set; } | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/SteamWebAPI2/Utilities/JsonConverters/TagsJsonConverter.cs
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,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
using Newtonsoft.Json; | ||
|
||
namespace SteamWebAPI2.Utilities.JsonConverters | ||
{ | ||
/// <inheritdoc /> | ||
/// <summary> | ||
/// Converts the tags stored in a list of dictionaries to a list of the values of the dictionary. | ||
/// <remarks>The keys seem to always be the string "tag".</remarks> | ||
/// </summary> | ||
internal class TagsJsonConverter : JsonConverter | ||
{ | ||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
var original = serializer.Deserialize<List<Dictionary<string, string>>>(reader); | ||
var tags = new List<string>(); | ||
|
||
original.ForEach(tag => tags.AddRange(tag.Values)); | ||
|
||
return tags; | ||
} | ||
|
||
public override bool CanWrite => false; | ||
|
||
public override bool CanConvert(Type objectType) | ||
{ | ||
return typeof(IList<IDictionary<string, string>>).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo()); | ||
} | ||
} | ||
} |